Changes to how output reports are sent. Mainly affects USB and SONYWA

This commit is contained in:
Travis Nickles 2017-12-10 05:09:15 -06:00
parent 132d411b24
commit 567aa393ae

View File

@ -1028,10 +1028,10 @@ namespace DS4Windows
setHapticState(); setHapticState();
bool quitOutputThread = false; bool quitOutputThread = false;
lock (outputReportBuffer) bool usingBT = conType == ConnectionType.BT;
{ if (usingBT)
if (conType == ConnectionType.BT)
{ {
Monitor.Enter(outputReportBuffer);
outputReportBuffer[0] = 0x11; outputReportBuffer[0] = 0x11;
outputReportBuffer[1] = (byte)(0x80 | btPollRate); // input report rate outputReportBuffer[1] = (byte)(0x80 | btPollRate); // input report rate
// enable rumble (0x01), lightbar (0x02), flash (0x04) // enable rumble (0x01), lightbar (0x02), flash (0x04)
@ -1072,9 +1072,8 @@ namespace DS4Windows
outputRumble = false; outputRumble = false;
outputPendCount = 3; outputPendCount = 3;
if (usingBT) { Monitor.Enter(outputReport); }
try try
{
lock (outputReport)
{ {
if (!writeOutput()) if (!writeOutput())
{ {
@ -1082,8 +1081,9 @@ namespace DS4Windows
quitOutputThread = true; quitOutputThread = true;
} }
} }
}
catch { } // If it's dead already, don't worry about it. catch { } // If it's dead already, don't worry about it.
if (usingBT) { Monitor.Exit(outputReport); }
} }
else else
{ {
@ -1094,14 +1094,16 @@ namespace DS4Windows
if (output || change) if (output || change)
{ {
if (change) if (change)
{
outputPendCount = 3; outputPendCount = 3;
}
outputRumble = true; outputRumble = true;
Monitor.Pulse(outputReportBuffer); Monitor.Pulse(outputReportBuffer);
} }
} }
}
if (usingBT) { Monitor.Exit(outputReportBuffer); }
if (quitOutputThread) if (quitOutputThread)
{ {
StopOutputUpdate(); StopOutputUpdate();