Tweak updating of pending output report

This commit is contained in:
Travis Nickles 2017-10-07 00:55:14 -05:00
parent 3425a0edb3
commit 957ad3b1d5

View File

@ -569,8 +569,6 @@ namespace DS4Windows
}
private void performDs4Output()
{
lock (outputReport)
{
try
{
@ -578,12 +576,20 @@ namespace DS4Windows
while (!exitOutputThread)
{
bool result = false;
if (outputRumble)
{
lock (outputReportBuffer)
{
outputReportBuffer.CopyTo(outputReport, 0);
outputRumble = false;
}
result = writeOutput();
if (!result)
{
outputRumble = true;
int thisError = Marshal.GetLastWin32Error();
if (lastError != thisError)
{
@ -592,16 +598,16 @@ namespace DS4Windows
lastError = thisError;
}
}
else
{
outputRumble = false;
}
}
if (!outputRumble)
{
lastError = 0;
Monitor.Wait(outputReport);
lock (outputReportBuffer)
{
Monitor.Wait(outputReportBuffer);
}
/*if (testRumble.IsRumbleSet()) // repeat test rumbles periodically; rumble has auto-shut-off in the DS4 firmware
Monitor.Wait(outputReport, 10000); // DS4 firmware stops it after 5 seconds, so let the motors rest for that long, too.
else
@ -612,8 +618,6 @@ namespace DS4Windows
}
catch (ThreadInterruptedException)
{
}
}
}
@ -1020,6 +1024,9 @@ namespace DS4Windows
setTestRumble();
setHapticState();
bool quitOutputThread = false;
lock (outputReportBuffer)
{
if (conType == ConnectionType.BT)
{
outputReportBuffer[0] = 0x11;
@ -1058,10 +1065,6 @@ namespace DS4Windows
}
}
bool quitOutputThread = false;
lock (outputReport)
{
if (synchronous)
{
outputRumble = false;
@ -1090,8 +1093,7 @@ namespace DS4Windows
if (output)
{
outputRumble = true;
outputReportBuffer.CopyTo(outputReport, 0);
Monitor.Pulse(outputReport);
Monitor.Pulse(outputReportBuffer);
}
}
}