Change to keep lightbar from sticking in some situations

Hopefully resolves issue #126.
This commit is contained in:
Travis Nickles 2017-10-27 02:09:42 -05:00
parent a7f4dec009
commit 677191e8b4

View File

@ -578,11 +578,13 @@ namespace DS4Windows
} }
} }
private byte outputPendCount = 0;
private void performDs4Output() private void performDs4Output()
{ {
try try
{ {
int lastError = 0; int lastError = 0;
outputPendCount = 3;
while (!exitOutputThread) while (!exitOutputThread)
{ {
bool result = false; bool result = false;
@ -593,6 +595,7 @@ namespace DS4Windows
{ {
outputReportBuffer.CopyTo(outputReport, 0); outputReportBuffer.CopyTo(outputReport, 0);
outputRumble = false; outputRumble = false;
outputPendCount--;
} }
result = writeOutput(); result = writeOutput();
@ -1096,12 +1099,17 @@ namespace DS4Windows
} }
else else
{ {
bool output = false; bool output = outputPendCount > 0;
for (int i = 0, arlen = outputReport.Length; !output && i < arlen; i++) for (int i = 0, arlen = outputReport.Length; !output && i < arlen; i++)
output = outputReport[i] != outputReportBuffer[i]; output = outputReport[i] != outputReportBuffer[i];
if (output) if (output)
{ {
if (outputPendCount == 0)
{
outputPendCount = 3;
}
outputRumble = true; outputRumble = true;
Monitor.Pulse(outputReportBuffer); Monitor.Pulse(outputReportBuffer);
} }