mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-24 23:51:49 +01:00
Make sure lightbar rainbow mode works properly with multiple devices
This commit is contained in:
parent
133d092aab
commit
3c7aa0d477
@ -28,7 +28,7 @@ namespace DS4Windows
|
|||||||
public static double[] fadetimer = new double[4] { 0, 0, 0, 0 };
|
public static double[] fadetimer = new double[4] { 0, 0, 0, 0 };
|
||||||
public static Stopwatch[] fadewatches = { new Stopwatch(), new Stopwatch(), new Stopwatch(), new Stopwatch() };
|
public static Stopwatch[] fadewatches = { new Stopwatch(), new Stopwatch(), new Stopwatch(), new Stopwatch() };
|
||||||
static bool[] fadedirection = new bool[4] { false, false, false, false };
|
static bool[] fadedirection = new bool[4] { false, false, false, false };
|
||||||
static DateTime oldnow = DateTime.UtcNow;
|
static DateTime[] oldnow = { DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow };
|
||||||
public static bool[] forcelight = new bool[4] { false, false, false, false };
|
public static bool[] forcelight = new bool[4] { false, false, false, false };
|
||||||
public static DS4Color[] forcedColor = new DS4Color[4];
|
public static DS4Color[] forcedColor = new DS4Color[4];
|
||||||
public static byte[] forcedFlash = new byte[4];
|
public static byte[] forcedFlash = new byte[4];
|
||||||
@ -63,14 +63,15 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
// Display rainbow
|
// Display rainbow
|
||||||
DateTime now = DateTime.UtcNow;
|
DateTime now = DateTime.UtcNow;
|
||||||
if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion
|
if (now >= oldnow[deviceNum] + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion
|
||||||
{
|
{
|
||||||
oldnow = now;
|
oldnow[deviceNum] = now;
|
||||||
if (device.isCharging())
|
if (device.isCharging())
|
||||||
counters[deviceNum] -= 1.5 * 3 / rainbow;
|
counters[deviceNum] -= 1.5 * 3 / rainbow;
|
||||||
else
|
else
|
||||||
counters[deviceNum] += 1.5 * 3 / rainbow;
|
counters[deviceNum] += 1.5 * 3 / rainbow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counters[deviceNum] < 0)
|
if (counters[deviceNum] < 0)
|
||||||
counters[deviceNum] = 180000;
|
counters[deviceNum] = 180000;
|
||||||
else if (counters[deviceNum] > 180000)
|
else if (counters[deviceNum] > 180000)
|
||||||
@ -159,11 +160,11 @@ namespace DS4Windows
|
|||||||
TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks);
|
TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks);
|
||||||
double botratio = timeratio.TotalMilliseconds;
|
double botratio = timeratio.TotalMilliseconds;
|
||||||
double topratio = TimeSpan.FromSeconds(idleDisconnectTimeout).TotalMilliseconds;
|
double topratio = TimeSpan.FromSeconds(idleDisconnectTimeout).TotalMilliseconds;
|
||||||
double ratio = ((botratio / topratio) * 100);
|
double ratio = 100.0 * (botratio / topratio);
|
||||||
if (ratio >= 50 && ratio <= 100)
|
if (ratio >= 50.0 && ratio <= 100.0)
|
||||||
color = getTransitionedColor(color, new DS4Color(0, 0, 0), (uint)((ratio - 50) * 2));
|
color = getTransitionedColor(color, new DS4Color(0, 0, 0), (uint)((ratio - 50) * 2));
|
||||||
else if (ratio >= 100)
|
else if (ratio >= 100.0)
|
||||||
color = getTransitionedColor(color, new DS4Color(0, 0, 0), 100);
|
color = getTransitionedColor(color, new DS4Color(0, 0, 0), 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device.isCharging() && device.getBattery() < 100)
|
if (device.isCharging() && device.getBattery() < 100)
|
||||||
@ -193,7 +194,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
color = ChargingColor[deviceNum];
|
color = getChargingColor(deviceNum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
@ -218,7 +219,7 @@ namespace DS4Windows
|
|||||||
//distanceprofile = (ProfilePath[deviceNum].ToLower().Contains("distance") || tempprofilename[deviceNum].ToLower().Contains("distance"));
|
//distanceprofile = (ProfilePath[deviceNum].ToLower().Contains("distance") || tempprofilename[deviceNum].ToLower().Contains("distance"));
|
||||||
if (distanceprofile && !defaultLight)
|
if (distanceprofile && !defaultLight)
|
||||||
{
|
{
|
||||||
//Thing I did for Distance
|
// Thing I did for Distance
|
||||||
float rumble = device.getLeftHeavySlowRumble() / 2.55f;
|
float rumble = device.getLeftHeavySlowRumble() / 2.55f;
|
||||||
byte max = Max(color.red, Max(color.green, color.blue));
|
byte max = Max(color.red, Max(color.green, color.blue));
|
||||||
if (device.getLeftHeavySlowRumble() > 100)
|
if (device.getLeftHeavySlowRumble() > 100)
|
||||||
|
@ -366,6 +366,10 @@ namespace DS4Windows
|
|||||||
return m_Config.m_LowLeds[index];
|
return m_Config.m_LowLeds[index];
|
||||||
}
|
}
|
||||||
public static DS4Color[] ChargingColor => m_Config.m_ChargingLeds;
|
public static DS4Color[] ChargingColor => m_Config.m_ChargingLeds;
|
||||||
|
public static DS4Color getChargingColor(int index)
|
||||||
|
{
|
||||||
|
return m_Config.m_ChargingLeds[index];
|
||||||
|
}
|
||||||
public static DS4Color[] CustomColor => m_Config.m_CustomLeds;
|
public static DS4Color[] CustomColor => m_Config.m_CustomLeds;
|
||||||
public static DS4Color getCustomColor(int index)
|
public static DS4Color getCustomColor(int index)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user