From 677191e8b4aa3a33d2c399161fe36f446b6c3d76 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 27 Oct 2017 02:09:42 -0500 Subject: [PATCH] Change to keep lightbar from sticking in some situations Hopefully resolves issue #126. --- DS4Windows/DS4Library/DS4Device.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 9b0ef71..93cc0c4 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -578,11 +578,13 @@ namespace DS4Windows } } + private byte outputPendCount = 0; private void performDs4Output() { try { int lastError = 0; + outputPendCount = 3; while (!exitOutputThread) { bool result = false; @@ -593,6 +595,7 @@ namespace DS4Windows { outputReportBuffer.CopyTo(outputReport, 0); outputRumble = false; + outputPendCount--; } result = writeOutput(); @@ -1096,12 +1099,17 @@ namespace DS4Windows } else { - bool output = false; + bool output = outputPendCount > 0; for (int i = 0, arlen = outputReport.Length; !output && i < arlen; i++) output = outputReport[i] != outputReportBuffer[i]; if (output) { + if (outputPendCount == 0) + { + outputPendCount = 3; + } + outputRumble = true; Monitor.Pulse(outputReportBuffer); }