Send output packet at least once every 4 seconds

Best attempt at resolving issue #399.
This commit is contained in:
Travis Nickles 2019-01-09 03:45:39 -06:00
parent 1a8548e5b9
commit cceaa31404

View File

@ -615,6 +615,7 @@ namespace DS4Windows
} }
private byte outputPendCount = 0; private byte outputPendCount = 0;
private readonly Stopwatch standbySw = new Stopwatch();
private unsafe void performDs4Output() private unsafe void performDs4Output()
{ {
try try
@ -658,6 +659,7 @@ namespace DS4Windows
} }
//outReportBuffer.CopyTo(outputReport, 0); //outReportBuffer.CopyTo(outputReport, 0);
outputPendCount--; outputPendCount--;
standbySw.Reset();
} }
currentRumble = true; currentRumble = true;
@ -742,6 +744,7 @@ namespace DS4Windows
int crcpos = BT_INPUT_REPORT_CRC32_POS; int crcpos = BT_INPUT_REPORT_CRC32_POS;
int crcoffset = 0; int crcoffset = 0;
long latencySum = 0; long latencySum = 0;
standbySw.Start();
while (!exitInputThread) while (!exitInputThread)
{ {
@ -1192,9 +1195,11 @@ namespace DS4Windows
if (synchronous) if (synchronous)
{ {
outputPendCount = 3; outputPendCount = 3;
output = output || standbySw.ElapsedMilliseconds >= 4000L;
if (change) if (output || change)
{ {
standbySw.Reset();
if (usingBT) if (usingBT)
{ {
Monitor.Enter(outputReport); Monitor.Enter(outputReport);
@ -1226,6 +1231,7 @@ namespace DS4Windows
//for (int i = 0, arlen = outputReport.Length; !change && i < arlen; i++) //for (int i = 0, arlen = outputReport.Length; !change && i < arlen; i++)
// change = outputReport[i] != outReportBuffer[i]; // change = outputReport[i] != outReportBuffer[i];
output = output || standbySw.ElapsedMilliseconds >= 4000L;
if (output || change) if (output || change)
{ {
if (change) if (change)