From cceaa31404c8a0cddeaacd552e5e84d065d477bd Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 9 Jan 2019 03:45:39 -0600 Subject: [PATCH] Send output packet at least once every 4 seconds Best attempt at resolving issue #399. --- DS4Windows/DS4Library/DS4Device.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index aba9179..e8b81a7 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -615,6 +615,7 @@ namespace DS4Windows } private byte outputPendCount = 0; + private readonly Stopwatch standbySw = new Stopwatch(); private unsafe void performDs4Output() { try @@ -658,6 +659,7 @@ namespace DS4Windows } //outReportBuffer.CopyTo(outputReport, 0); outputPendCount--; + standbySw.Reset(); } currentRumble = true; @@ -742,6 +744,7 @@ namespace DS4Windows int crcpos = BT_INPUT_REPORT_CRC32_POS; int crcoffset = 0; long latencySum = 0; + standbySw.Start(); while (!exitInputThread) { @@ -1192,9 +1195,11 @@ namespace DS4Windows if (synchronous) { outputPendCount = 3; - - if (change) + output = output || standbySw.ElapsedMilliseconds >= 4000L; + if (output || change) { + standbySw.Reset(); + if (usingBT) { Monitor.Enter(outputReport); @@ -1226,6 +1231,7 @@ namespace DS4Windows //for (int i = 0, arlen = outputReport.Length; !change && i < arlen; i++) // change = outputReport[i] != outReportBuffer[i]; + output = output || standbySw.ElapsedMilliseconds >= 4000L; if (output || change) { if (change)