From e99e0afe17f5a6bde67d6a71739c6ab679497dbc Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 20 Jul 2018 04:52:45 -0500 Subject: [PATCH] Use unsafe for accessing gyro and accel arrays --- DS4Windows/DS4Library/DS4Device.cs | 2 +- DS4Windows/DS4Library/DS4Sixaxis.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index b52444b..023df85 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -983,7 +983,7 @@ namespace DS4Windows } } - sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime); + fixed (byte* pGyro = gyro, pAccel = accel) sixAxis.handleSixaxis(pGyro, pAccel, cState, elapsedDeltaTime); /* Debug output of incoming HID data: if (cState.L2 == 0xff && cState.R2 == 0xff) diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index 62353b5..8da297e 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -220,7 +220,7 @@ namespace DS4Windows accelZ = temInt = (int)(temInt * (current.sensNumer / (float)current.sensDenom)); } - public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state, + public unsafe void handleSixaxis(byte* gyro, byte* accel, DS4State state, double elapsedDelta) { int currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]);