mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 19:14:20 +01:00
Make lightbar pulse mode time dependent.
Duration might change later. Related to issue #18.
This commit is contained in:
parent
52e7c2309b
commit
133d092aab
@ -5,6 +5,8 @@ using System.Text;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using static System.Math;
|
using static System.Math;
|
||||||
using static DS4Windows.Global;
|
using static DS4Windows.Global;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace DS4Windows
|
namespace DS4Windows
|
||||||
{
|
{
|
||||||
public class DS4LightBar
|
public class DS4LightBar
|
||||||
@ -24,11 +26,13 @@ namespace DS4Windows
|
|||||||
};
|
};
|
||||||
static double[] counters = new double[4] { 0, 0, 0, 0 };
|
static double[] counters = new double[4] { 0, 0, 0, 0 };
|
||||||
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() };
|
||||||
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;
|
||||||
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];
|
||||||
|
internal const int PULSE_FLASH_DURATION = 2000;
|
||||||
|
|
||||||
public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState,
|
public static void updateLightBar(DS4Device device, int deviceNum, DS4State cState,
|
||||||
DS4StateExposed eState, Mouse tp)
|
DS4StateExposed eState, Mouse tp)
|
||||||
@ -104,17 +108,46 @@ namespace DS4Windows
|
|||||||
|
|
||||||
if (getFlashType(deviceNum) == 1)
|
if (getFlashType(deviceNum) == 1)
|
||||||
{
|
{
|
||||||
if (fadetimer[deviceNum] <= 0.0)
|
double ratio = 0.0;
|
||||||
fadedirection[deviceNum] = true;
|
|
||||||
else if (fadetimer[deviceNum] >= 100.0)
|
if (!fadewatches[deviceNum].IsRunning)
|
||||||
fadedirection[deviceNum] = false;
|
{
|
||||||
|
bool temp = fadedirection[deviceNum];
|
||||||
|
fadedirection[deviceNum] = !temp;
|
||||||
|
fadewatches[deviceNum].Restart();
|
||||||
|
ratio = temp ? 100.0 : 0.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long elapsed = fadewatches[deviceNum].ElapsedMilliseconds;
|
||||||
|
|
||||||
if (fadedirection[deviceNum])
|
if (fadedirection[deviceNum])
|
||||||
fadetimer[deviceNum] += 1;
|
{
|
||||||
|
if (elapsed < PULSE_FLASH_DURATION)
|
||||||
|
{
|
||||||
|
ratio = 100.0 * (elapsed / (double)PULSE_FLASH_DURATION);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fadetimer[deviceNum] -= 1;
|
{
|
||||||
|
ratio = 100.0;
|
||||||
|
fadewatches[deviceNum].Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (elapsed < PULSE_FLASH_DURATION)
|
||||||
|
{
|
||||||
|
ratio = (0 - 100.0) * (elapsed / (double)PULSE_FLASH_DURATION) + 100.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ratio = 0.0;
|
||||||
|
fadewatches[deviceNum].Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
color = getTransitionedColor(color, new DS4Color(0, 0, 0), fadetimer[deviceNum]);
|
color = getTransitionedColor(color, new DS4Color(0, 0, 0), ratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user