From 37bb576aa679c0e53dafe06718981c969d8bcc5d Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 6 Mar 2018 23:20:26 -0600 Subject: [PATCH] Use unsafe memory pointers for copying imu data --- DS4Windows/DS4Library/DS4Device.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 9bf473c..f47d237 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -958,8 +958,20 @@ namespace DS4Windows catch { currerror = "Index out of bounds: touchpad"; } // Store Gyro and Accel values - Array.Copy(inputReport, 13, gyro, 0, 6); - Array.Copy(inputReport, 19, accel, 0, 6); + //Array.Copy(inputReport, 13, gyro, 0, 6); + //Array.Copy(inputReport, 19, accel, 0, 6); + fixed (byte* pbInput = inputReport, pbGyro = gyro, pbAccel = accel) + { + for (int i = 0; i < 6; i++) + { + pbGyro[i] = pbInput[i]; + } + + for (int i = 6; i < 12; i++) + { + pbAccel[i] = pbInput[i]; + } + } sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime); /* Debug output of incoming HID data: