Added wait event to use for refreshing controller readings

Only display state change when device is waiting for new report
This commit is contained in:
Travis Nickles 2020-03-14 15:34:59 -05:00
parent f7a08fae6e
commit 08018d27a1
2 changed files with 11 additions and 0 deletions

View File

@ -183,6 +183,8 @@ namespace DS4WinWPF.DS4Forms
Dispatcher.Invoke(() =>
{
ds.ReadWaitEv.Wait();
ds.ReadWaitEv.Reset();
int x = baseState.LX;
int y = baseState.LY;
@ -272,6 +274,7 @@ namespace DS4WinWPF.DS4Forms
}
prevWarnMode = warnMode;
ds.ReadWaitEv.Set();
});
}

View File

@ -429,6 +429,9 @@ namespace DS4Windows
return runCalib;
}
private ManualResetEventSlim readWaitEv = new ManualResetEventSlim();
public ManualResetEventSlim ReadWaitEv { get => readWaitEv; }
public DS4Device(HidDevice hidDevice, string disName)
{
hDevice = hidDevice;
@ -809,6 +812,8 @@ namespace DS4Windows
//Latency = latencyQueue.Average();
Latency = latencySum / tempLatencyCount;
readWaitEv.Set();
if (conType == ConnectionType.BT)
{
//HidDevice.ReadStatus res = hDevice.ReadFile(btInputReport);
@ -893,6 +898,9 @@ namespace DS4Windows
}
}
readWaitEv.Wait();
readWaitEv.Reset();
curtime = Stopwatch.GetTimestamp();
testelapsed = curtime - oldtime;
lastTimeElapsedDouble = testelapsed * (1.0 / Stopwatch.Frequency) * 1000.0;