From dba2b1bbb3bdae739cd5acf1cabbd1c7451eebe4 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sun, 16 Jul 2017 07:11:58 -0500 Subject: [PATCH] Tweaks to how imu data is used --- DS4Windows/DS4Control/DS4StateFieldMapping.cs | 12 ++++++------ DS4Windows/DS4Control/Mapping.cs | 16 ++++++++-------- DS4Windows/DS4Control/MouseCursor.cs | 4 ++-- DS4Windows/DS4Forms/Options.cs | 6 +++--- DS4Windows/DS4Library/DS4Sixaxis.cs | 12 ++++++------ DS4Windows/DS4Library/DS4State.cs | 2 +- DS4Windows/DS4Library/DS4StateExposed.cs | 4 ++-- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/DS4Windows/DS4Control/DS4StateFieldMapping.cs b/DS4Windows/DS4Control/DS4StateFieldMapping.cs index 6dca486..e8d88c7 100644 --- a/DS4Windows/DS4Control/DS4StateFieldMapping.cs +++ b/DS4Windows/DS4Control/DS4StateFieldMapping.cs @@ -90,13 +90,13 @@ namespace DS4Windows buttons[(int)DS4Controls.TouchUpper] = tp != null ? (!priorMouse ? tp.upperDown : tp.priorUpperDown) : false; buttons[(int)DS4Controls.TouchMulti] = tp != null ? (!priorMouse ? tp.multiDown : tp.priorMultiDown) : false; - int gyroX = exposeState.getAccelX(); - gryodirs[(int)DS4Controls.GyroXPos] = gyroX > 0 ? gyroX : 0; - gryodirs[(int)DS4Controls.GyroXNeg] = gyroX < 0 ? gyroX : 0; + int sixAxisX = -exposeState.getAccelX(); + gryodirs[(int)DS4Controls.GyroXPos] = sixAxisX > 0 ? sixAxisX : 0; + gryodirs[(int)DS4Controls.GyroXNeg] = sixAxisX < 0 ? sixAxisX : 0; - int gyroZ = exposeState.getAccelZ(); - gryodirs[(int)DS4Controls.GyroZPos] = gyroZ > 0 ? gyroZ : 0; - gryodirs[(int)DS4Controls.GyroZNeg] = gyroZ < 0 ? gyroZ : 0; + int sixAxisZ = exposeState.getAccelZ(); + gryodirs[(int)DS4Controls.GyroZPos] = sixAxisZ > 0 ? sixAxisZ : 0; + gryodirs[(int)DS4Controls.GyroZNeg] = sixAxisZ < 0 ? sixAxisZ : 0; swipedirs[(int)DS4Controls.SwipeLeft] = tp != null ? (!priorMouse ? tp.swipeLeftB : tp.priorSwipeLeftB): (byte)0; swipedirs[(int)DS4Controls.SwipeRight] = tp != null ? (!priorMouse ? tp.swipeRightB : tp.priorSwipeRightB) : (byte)0; diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index a7214ca..2513e51 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -2760,13 +2760,13 @@ namespace DS4Windows { case DS4Controls.GyroXPos: { - int gyroX = eState.AccelX; + int gyroX = -eState.AccelX; result = (byte)(!sOff && sxsens * gyroX > SXD * 10 ? Math.Min(255, sxsens * gyroX * 2) : 0); break; } case DS4Controls.GyroXNeg: { - int gyroX = eState.AccelX; + int gyroX = -eState.AccelX; result = (byte)(!sOff && sxsens * gyroX < -SXD * 10 ? Math.Min(255, sxsens * -gyroX * 2) : 0); break; } @@ -2882,8 +2882,8 @@ namespace DS4Windows switch (control) { - case DS4Controls.GyroXPos: result = !sOff ? SXSens[device] * eState.AccelX > 67 : false; break; - case DS4Controls.GyroXNeg: result = !sOff ? SXSens[device] * eState.AccelX < -67 : false; break; + case DS4Controls.GyroXPos: result = !sOff ? SXSens[device] * -eState.AccelX > 67 : false; break; + case DS4Controls.GyroXNeg: result = !sOff ? SXSens[device] * -eState.AccelX < -67 : false; break; case DS4Controls.GyroZPos: result = !sOff ? SZSens[device] * eState.AccelZ > 67 : false; break; case DS4Controls.GyroZNeg: result = !sOff ? SZSens[device] * eState.AccelZ < -67 : false; break; default: break; @@ -3548,18 +3548,18 @@ namespace DS4Windows { case DS4Controls.GyroXPos: { - if (!sOff && eState.AccelX > SXD * 10) + if (!sOff && -eState.AccelX > SXD * 10) { - if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * eState.AccelX); + if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * -eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * -eState.AccelX); } else result = falseVal; break; } case DS4Controls.GyroXNeg: { - if (!sOff && eState.AccelX < -SXD * 10) + if (!sOff && -eState.AccelX < -SXD * 10) { - if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * -eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * -eState.AccelX); + if (alt) result = (byte)Math.Min(255, 127 + SXSens[device] * eState.AccelX); else result = (byte)Math.Max(0, 127 - SXSens[device] * eState.AccelX); } else result = falseVal; break; diff --git a/DS4Windows/DS4Control/MouseCursor.cs b/DS4Windows/DS4Control/MouseCursor.cs index a7683aa..1cd64ad 100644 --- a/DS4Windows/DS4Control/MouseCursor.cs +++ b/DS4Windows/DS4Control/MouseCursor.cs @@ -21,7 +21,7 @@ namespace DS4Windows private double GYRO_MOUSE_COEFFICIENT = 0.0095; private int GYRO_MOUSE_DEADZONE = 12; private double GYRO_MOUSE_OFFSET = 0.1463; - private double GYRO_SMOOTH_MOUSE_OFFSET = 0.14698; + private double GYRO_SMOOTH_MOUSE_OFFSET = 0.14695; private const int SMOOTH_BUFFER_LEN = 3; private double[] xSmoothBuffer = new double[SMOOTH_BUFFER_LEN]; @@ -41,7 +41,7 @@ namespace DS4Windows deltaX = Global.getGyroMouseHorizontalAxis(deviceNumber) == 0 ? arg.sixAxis.gyroYawFull : arg.sixAxis.gyroRollFull; deltaY = -arg.sixAxis.gyroPitchFull; - tempDouble = arg.sixAxis.elapsed * 0.001 * 250.0; + tempDouble = arg.sixAxis.elapsed * 0.001 * 250.0; // Base default speed on 4 ms gyroSmooth = Global.getGyroSmoothing(deviceNumber); double gyroSmoothWeight = 0.0; diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index f36d37e..249a496 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -805,8 +805,8 @@ namespace DS4Windows SetDynamicTrackBarValue(tBsixaxisGyroX, (exposeState.GyroYaw + tBsixaxisGyroX.Value * 2) / 3); SetDynamicTrackBarValue(tBsixaxisGyroY, (exposeState.GyroPitch + tBsixaxisGyroY.Value * 2) / 3); SetDynamicTrackBarValue(tBsixaxisGyroZ, (exposeState.GyroRoll + tBsixaxisGyroZ.Value * 2) / 3); - SetDynamicTrackBarValue(tBsixaxisAccelX, (-exposeState.AccelX + tBsixaxisAccelX.Value * 2) / 3); - SetDynamicTrackBarValue(tBsixaxisAccelY, (-exposeState.AccelY + tBsixaxisAccelY.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisAccelX, (exposeState.AccelX + tBsixaxisAccelX.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisAccelY, (exposeState.AccelY + tBsixaxisAccelY.Value * 2) / 3); SetDynamicTrackBarValue(tBsixaxisAccelZ, (exposeState.AccelZ + tBsixaxisAccelZ.Value * 2) / 3); int x = baseState.LX; @@ -899,7 +899,7 @@ namespace DS4Windows (int)(tempRSS * (btnRSTrack.Location.Y - pnlRSTrack.Size.Height / 2f) + pnlRSTrack.Size.Height / 2f)); } - x = -exposeState.AccelX + 127; + x = exposeState.AccelX + 127; y = exposeState.AccelZ + 127; btnSATrack.Location = new Point((int)(dpix * Global.Clamp(0, x / 2.09, pnlSATrack.Size.Width)), (int)(dpiy * Global.Clamp(0, y / 2.09, pnlSATrack.Size.Height))); diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index 705c43b..d7840ca 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -23,18 +23,18 @@ namespace DS4Windows public readonly SixAxis previousAxis = null; public SixAxis(int X, int Y, int Z, int aX, int aY, int aZ, double milliseconds, SixAxis prevAxis = null) { - gyroX = X / 256; + gyroX = -X / 256; gyroY = Y / 256; - gyroZ = Z / 256; + gyroZ = -Z / 256; gyroYawFull = -X; gyroPitchFull = Y; gyroRollFull = -Z; - accelX = aX / 64; - accelY = aY / 64; + accelX = -aX / 64; + accelY = -aY / 64; accelZ = aZ / 64; - accelXFull = aX; - accelYFull = aY; + accelXFull = -aX; + accelYFull = -aY; accelZFull = aZ; elapsed = milliseconds; diff --git a/DS4Windows/DS4Library/DS4State.cs b/DS4Windows/DS4Library/DS4State.cs index 73ccb6a..21e1e55 100644 --- a/DS4Windows/DS4Library/DS4State.cs +++ b/DS4Windows/DS4Library/DS4State.cs @@ -46,7 +46,7 @@ namespace DS4Windows LYUnit = 0.0; RXUnit = 0.0; RYUnit = 0.0; - Motion = null; + Motion = new SixAxis(0, 0, 0, 0, 0, 0, 0.0); } public DS4State(DS4State state) diff --git a/DS4Windows/DS4Library/DS4StateExposed.cs b/DS4Windows/DS4Library/DS4StateExposed.cs index d5ef8b8..b675768 100644 --- a/DS4Windows/DS4Library/DS4StateExposed.cs +++ b/DS4Windows/DS4Library/DS4StateExposed.cs @@ -43,9 +43,9 @@ namespace DS4Windows byte R2 { get { return _state.R2; } } int Battery { get { return _state.Battery; } } - public int GyroYaw { get { return -_state.Motion.gyroX; } } + public int GyroYaw { get { return _state.Motion.gyroX; } } public int GyroPitch { get { return _state.Motion.gyroY; } } - public int GyroRoll { get { return -_state.Motion.gyroZ; } } + public int GyroRoll { get { return _state.Motion.gyroZ; } } public int AccelX { get { return _state.Motion.accelX; } } public int getAccelX()