Fixed volume updating when sending timeout output reports

This commit is contained in:
Travis Nickles 2019-01-16 04:08:51 -06:00
parent 5ec6bcb11a
commit df1ec44f1c

View File

@ -1117,6 +1117,7 @@ namespace DS4Windows
lock (outReportBuffer) lock (outReportBuffer)
{ {
bool output = outputPendCount > 0, change = force; bool output = outputPendCount > 0, change = force;
bool haptime = output || standbySw.ElapsedMilliseconds >= 4000L;
if (usingBT) if (usingBT)
{ {
@ -1137,6 +1138,8 @@ namespace DS4Windows
for (int i = 0, arlen = BT_OUTPUT_CHANGE_LENGTH; !change && i < arlen; i++) for (int i = 0, arlen = BT_OUTPUT_CHANGE_LENGTH; !change && i < arlen; i++)
change = byteR[i] != byteB[i]; change = byteR[i] != byteB[i];
} }
haptime = haptime || change;
} }
else else
{ {
@ -1157,7 +1160,8 @@ namespace DS4Windows
change = byteR[i] != byteB[i]; change = byteR[i] != byteB[i];
} }
if (change && audio != null) haptime = haptime || change;
if (haptime && audio != null)
{ {
// Headphone volume levels // Headphone volume levels
outReportBuffer[19] = outReportBuffer[20] = outReportBuffer[19] = outReportBuffer[20] =
@ -1169,8 +1173,7 @@ namespace DS4Windows
if (synchronous) if (synchronous)
{ {
output = output || standbySw.ElapsedMilliseconds >= 4000L; if (output || haptime)
if (output || change)
{ {
if (change) if (change)
{ {
@ -1218,8 +1221,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 || haptime)
if (output || change)
{ {
if (change) if (change)
{ {