mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
Lightbar idle fade now works in all regions, possibly fixed bug with nullexeception, use of utcnow instead of now across the board
This commit is contained in:
parent
36f01ac30c
commit
25612fa9a1
@ -22,13 +22,13 @@ namespace DS4Control
|
|||||||
};
|
};
|
||||||
static double[] counters = new double[4] {0,0,0,0};
|
static double[] counters = new double[4] {0,0,0,0};
|
||||||
|
|
||||||
static DateTime oldnow = DateTime.Now;
|
static DateTime oldnow = DateTime.UtcNow;
|
||||||
public static void updateLightBar(DS4Device device, int deviceNum)
|
public static void updateLightBar(DS4Device device, int deviceNum)
|
||||||
{
|
{
|
||||||
DS4Color color;
|
DS4Color color;
|
||||||
if (Global.getRainbow(deviceNum) > 0)
|
if (Global.getRainbow(deviceNum) > 0)
|
||||||
{// Display rainbow
|
{// Display rainbow
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.UtcNow;
|
||||||
if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion
|
if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion
|
||||||
{
|
{
|
||||||
oldnow = now;
|
oldnow = now;
|
||||||
@ -74,7 +74,7 @@ namespace DS4Control
|
|||||||
|
|
||||||
if (Global.getIdleDisconnectTimeout(deviceNum) > 0)
|
if (Global.getIdleDisconnectTimeout(deviceNum) > 0)
|
||||||
{//Fade lightbar by idle time
|
{//Fade lightbar by idle time
|
||||||
TimeSpan timeratio = new TimeSpan(DateTime.Now.Ticks - device.lastActive.Ticks) + new TimeSpan(4, 0, 0); //The nows are off by 4 hours, not sure why...
|
TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks);
|
||||||
double botratio = timeratio.TotalMilliseconds;
|
double botratio = timeratio.TotalMilliseconds;
|
||||||
double topratio = TimeSpan.FromSeconds(Global.getIdleDisconnectTimeout(deviceNum)).TotalMilliseconds;
|
double topratio = TimeSpan.FromSeconds(Global.getIdleDisconnectTimeout(deviceNum)).TotalMilliseconds;
|
||||||
double ratio = ((botratio / topratio) * 100);
|
double ratio = ((botratio / topratio) * 100);
|
||||||
|
@ -44,7 +44,7 @@ namespace DS4Control
|
|||||||
private static SyntheticState[] deviceState = { new SyntheticState(), new SyntheticState(), new SyntheticState(), new SyntheticState() };
|
private static SyntheticState[] deviceState = { new SyntheticState(), new SyntheticState(), new SyntheticState(), new SyntheticState() };
|
||||||
|
|
||||||
// TODO When we disconnect, process a null/dead state to release any keys or buttons.
|
// TODO When we disconnect, process a null/dead state to release any keys or buttons.
|
||||||
public static DateTime oldnow = DateTime.Now;
|
public static DateTime oldnow = DateTime.UtcNow;
|
||||||
private static bool pressagain = false;
|
private static bool pressagain = false;
|
||||||
private static int wheel = 0, keyshelddown = 0;
|
private static int wheel = 0, keyshelddown = 0;
|
||||||
public static void Commit(int device)
|
public static void Commit(int device)
|
||||||
@ -86,7 +86,7 @@ namespace DS4Control
|
|||||||
if (globalState.currentClicks.wUpCount != 0 && globalState.previousClicks.wUpCount == 0)
|
if (globalState.currentClicks.wUpCount != 0 && globalState.previousClicks.wUpCount == 0)
|
||||||
{
|
{
|
||||||
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, 100);
|
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, 100);
|
||||||
oldnow = DateTime.Now;
|
oldnow = DateTime.UtcNow;
|
||||||
wheel = 100;
|
wheel = 100;
|
||||||
}
|
}
|
||||||
else if (globalState.currentClicks.wUpCount == 0 && globalState.previousClicks.wUpCount != 0)
|
else if (globalState.currentClicks.wUpCount == 0 && globalState.previousClicks.wUpCount != 0)
|
||||||
@ -96,7 +96,7 @@ namespace DS4Control
|
|||||||
if (globalState.currentClicks.wDownCount != 0 && globalState.previousClicks.wDownCount == 0)
|
if (globalState.currentClicks.wDownCount != 0 && globalState.previousClicks.wDownCount == 0)
|
||||||
{
|
{
|
||||||
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -100);
|
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -100);
|
||||||
oldnow = DateTime.Now;
|
oldnow = DateTime.UtcNow;
|
||||||
wheel = -100;
|
wheel = -100;
|
||||||
}
|
}
|
||||||
if (globalState.currentClicks.wDownCount == 0 && globalState.previousClicks.wDownCount != 0)
|
if (globalState.currentClicks.wDownCount == 0 && globalState.previousClicks.wDownCount != 0)
|
||||||
@ -104,7 +104,7 @@ namespace DS4Control
|
|||||||
|
|
||||||
if (wheel != 0) //Continue mouse wheel movement
|
if (wheel != 0) //Continue mouse wheel movement
|
||||||
{
|
{
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.UtcNow;
|
||||||
if (now >= oldnow + TimeSpan.FromMilliseconds(100) && !pressagain)
|
if (now >= oldnow + TimeSpan.FromMilliseconds(100) && !pressagain)
|
||||||
{
|
{
|
||||||
oldnow = now;
|
oldnow = now;
|
||||||
@ -134,14 +134,14 @@ namespace DS4Control
|
|||||||
{
|
{
|
||||||
if (gkp.current.scanCodeCount != 0)
|
if (gkp.current.scanCodeCount != 0)
|
||||||
{
|
{
|
||||||
oldnow = DateTime.Now;
|
oldnow = DateTime.UtcNow;
|
||||||
InputMethods.performSCKeyPress(kvp.Key);
|
InputMethods.performSCKeyPress(kvp.Key);
|
||||||
pressagain = false;
|
pressagain = false;
|
||||||
keyshelddown = kvp.Key;
|
keyshelddown = kvp.Key;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oldnow = DateTime.Now;
|
oldnow = DateTime.UtcNow;
|
||||||
InputMethods.performKeyPress(kvp.Key);
|
InputMethods.performKeyPress(kvp.Key);
|
||||||
pressagain = false;
|
pressagain = false;
|
||||||
keyshelddown = kvp.Key;
|
keyshelddown = kvp.Key;
|
||||||
@ -152,7 +152,7 @@ namespace DS4Control
|
|||||||
{
|
{
|
||||||
if (keyshelddown == kvp.Key)
|
if (keyshelddown == kvp.Key)
|
||||||
{
|
{
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.UtcNow;
|
||||||
if (now >= oldnow + TimeSpan.FromMilliseconds(500) && !pressagain)
|
if (now >= oldnow + TimeSpan.FromMilliseconds(500) && !pressagain)
|
||||||
{
|
{
|
||||||
oldnow = now;
|
oldnow = now;
|
||||||
@ -160,7 +160,7 @@ namespace DS4Control
|
|||||||
}
|
}
|
||||||
if (pressagain && gkp.current.scanCodeCount != 0)
|
if (pressagain && gkp.current.scanCodeCount != 0)
|
||||||
{
|
{
|
||||||
now = DateTime.Now;
|
now = DateTime.UtcNow;
|
||||||
if (now >= oldnow + TimeSpan.FromMilliseconds(25) && pressagain)
|
if (now >= oldnow + TimeSpan.FromMilliseconds(25) && pressagain)
|
||||||
{
|
{
|
||||||
oldnow = now;
|
oldnow = now;
|
||||||
@ -169,7 +169,7 @@ namespace DS4Control
|
|||||||
}
|
}
|
||||||
else if (pressagain)
|
else if (pressagain)
|
||||||
{
|
{
|
||||||
now = DateTime.Now;
|
now = DateTime.UtcNow;
|
||||||
if (now >= oldnow + TimeSpan.FromMilliseconds(25) && pressagain)
|
if (now >= oldnow + TimeSpan.FromMilliseconds(25) && pressagain)
|
||||||
{
|
{
|
||||||
oldnow = now;
|
oldnow = now;
|
||||||
|
@ -14,7 +14,7 @@ namespace ScpServer
|
|||||||
{
|
{
|
||||||
private DS4Control.Control rootHub;
|
private DS4Control.Control rootHub;
|
||||||
delegate void LogDebugDelegate(DateTime Time, String Data);
|
delegate void LogDebugDelegate(DateTime Time, String Data);
|
||||||
double version = 7.4;
|
double version = 7.412;
|
||||||
|
|
||||||
protected Label[] Pads;
|
protected Label[] Pads;
|
||||||
protected ComboBox[] cbs;
|
protected ComboBox[] cbs;
|
||||||
@ -123,6 +123,16 @@ namespace ScpServer
|
|||||||
RegistryKey KeyLoc = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
|
RegistryKey KeyLoc = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
|
||||||
StartWindowsCheckBox.Checked = (KeyLoc.GetValue("DS4Tool") != null);
|
StartWindowsCheckBox.Checked = (KeyLoc.GetValue("DS4Tool") != null);
|
||||||
|
|
||||||
|
Pads = new Label[4] { lbPad1, lbPad2, lbPad3, lbPad4 };
|
||||||
|
cbs = new ComboBox[4] { cBController1, cBController2, cBController3, cBController4 };
|
||||||
|
ebns = new Button[4] { bnEditC1, bnEditC2, bnEditC3, bnEditC4 };
|
||||||
|
dbns = new Button[4] { bnDeleteC1, bnDeleteC2, bnDeleteC3, bnDeleteC4 };
|
||||||
|
protexts = new Label[4] { lbSelPro1, lbSelPro2, lbSelPro3, lbSelPro4 };
|
||||||
|
|
||||||
|
shortcuts = new ToolStripMenuItem[4] { (ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[0],
|
||||||
|
(ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[1],
|
||||||
|
(ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[2],
|
||||||
|
(ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[3] };
|
||||||
if (startMinimizedCheckBox.Checked)
|
if (startMinimizedCheckBox.Checked)
|
||||||
{
|
{
|
||||||
this.WindowState = FormWindowState.Minimized;
|
this.WindowState = FormWindowState.Minimized;
|
||||||
|
Loading…
Reference in New Issue
Block a user