From f3a019742d6c748e5009299366c6d00d86d4fb10 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 6 Mar 2018 17:01:18 -0600 Subject: [PATCH] Use unsafe memory pointers for detecting output report changes --- DS4Windows/DS4Library/DS4Device.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 331fc8e..5eb684b 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -1089,7 +1089,7 @@ namespace DS4Windows hDevice.flush_Queue(); } - private void sendOutputReport(bool synchronous) + private unsafe void sendOutputReport(bool synchronous) { setTestRumble(); setHapticState(); @@ -1161,8 +1161,14 @@ namespace DS4Windows else { bool output = outputPendCount > 0, change = false; - for (int i = 0, arlen = outputReport.Length; !change && i < arlen; i++) - change = outputReport[i] != outReportBuffer[i]; + fixed (byte* byteR = outputReport, byteB = outReportBuffer) + { + for (int i = 0, arlen = outputReport.Length; !change && i < arlen; i++) + change = byteR[i] != byteB[i]; + } + + //for (int i = 0, arlen = outputReport.Length; !change && i < arlen; i++) + // change = outputReport[i] != outReportBuffer[i]; if (output || change) {