From 8eb9d6391f02da376266d4d57f007a46e0938ad7 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 18 Jul 2017 15:37:01 -0500 Subject: [PATCH] Some optimizations --- DS4Windows/DS4Control/ControlService.cs | 12 +-- DS4Windows/DS4Control/DS4LightBar.cs | 15 ++-- DS4Windows/DS4Control/Mapping.cs | 109 ++++++++++------------- DS4Windows/DS4Control/MouseCursor.cs | 3 +- DS4Windows/DS4Forms/Options.cs | 16 ++-- DS4Windows/DS4Library/DS4Sixaxis.cs | 9 +- DS4Windows/DS4Library/DS4StateExposed.cs | 64 +++++++------ 7 files changed, 115 insertions(+), 113 deletions(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index b304c0c..896b2ca 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -249,7 +249,7 @@ namespace DS4Windows DS4LightBar.updateLightBar(DS4Controllers[i], i, CurrentState[i], ExposedState[i], touchPad[i]); tempDevice.IsRemoved = true; - System.Threading.Thread.Sleep(50); + Thread.Sleep(50); } CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change. @@ -264,7 +264,7 @@ namespace DS4Windows } if (anyUnplugged) - System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME); + Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME); x360Bus.UnplugAll(); x360Bus.Stop(); @@ -963,9 +963,11 @@ namespace DS4Windows return result; } - public bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false }; - public byte[] oldtouchvalue = { 0, 0, 0, 0 }; - public int[] oldscrollvalue = { 0, 0, 0, 0 }; + public bool[] touchreleased = new bool[4] { true, true, true, true }, + touchslid = new bool[4] { false, false, false, false }; + + public byte[] oldtouchvalue = new byte[4] { 0, 0, 0, 0 }; + public int[] oldscrollvalue = new int[4] { 0, 0, 0, 0 }; protected virtual void CheckForTouchToggle(int deviceID, DS4State cState, DS4State pState) { diff --git a/DS4Windows/DS4Control/DS4LightBar.cs b/DS4Windows/DS4Control/DS4LightBar.cs index 78899e1..1e33ec9 100644 --- a/DS4Windows/DS4Control/DS4LightBar.cs +++ b/DS4Windows/DS4Control/DS4LightBar.cs @@ -18,13 +18,18 @@ namespace DS4Windows { 140, 140 }, { 168, 112 }, { 196, 84 }, - { 224, 56}, // on 80% of the time at 80, etc. + { 224, 56 }, // on 80% of the time at 80, etc. { 252, 28 } // on 90% of the time at 90 }; + static double[] counters = new double[4] { 0, 0, 0, 0 }; - public static Stopwatch[] fadewatches = { new Stopwatch(), new Stopwatch(), new Stopwatch(), new Stopwatch() }; + public static Stopwatch[] fadewatches = new Stopwatch[4] + { new Stopwatch(), new Stopwatch(), new Stopwatch(), new Stopwatch() }; + static bool[] fadedirection = new bool[4] { false, false, false, false }; - static DateTime[] oldnow = { DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow }; + static DateTime[] oldnow = new DateTime[4] + { DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow }; + public static bool[] forcelight = new bool[4] { false, false, false, false }; public static DS4Color[] forcedColor = new DS4Color[4]; public static byte[] forcedFlash = new byte[4]; @@ -291,10 +296,6 @@ namespace DS4Windows if (tempLightBarOnDuration != haptics.LightBarFlashDurationOn && tempLightBarOnDuration != 1 && haptics.LightBarFlashDurationOn == 0) haptics.LightBarFlashDurationOff = haptics.LightBarFlashDurationOn = 1; - // Comment out code for now. This condition gets hit too often and bogs down the GUI - //if (device.LightBarOnDuration == 1) //helps better reset the color - // System.Threading.Thread.Sleep(5); - device.pushHapticState(haptics); } diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 2c64ace..731ce3c 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -59,7 +59,9 @@ namespace DS4Windows } public static SyntheticState globalState = new SyntheticState(); - public static SyntheticState[] deviceState = { new SyntheticState(), new SyntheticState(), new SyntheticState(), new SyntheticState() }; + public static SyntheticState[] deviceState = new SyntheticState[4] + { new SyntheticState(), new SyntheticState(), new SyntheticState(), + new SyntheticState() }; // TODO When we disconnect, process a null/dead state to release any keys or buttons. public static DateTime oldnow = DateTime.UtcNow; @@ -71,8 +73,8 @@ namespace DS4Windows static bool[] macroControl = new bool[25]; //actions - public static int[] fadetimer = { 0, 0, 0, 0 }; - public static int[] prevFadetimer = { 0, 0, 0, 0 }; + public static int[] fadetimer = new int[4] { 0, 0, 0, 0 }; + public static int[] prevFadetimer = new int[4] { 0, 0, 0, 0 }; public static DS4Color[] lastColor = new DS4Color[4]; public static List actionDone = new List(); //public static List[] actionDone = { new List(), new List(), new List(), new List() }; @@ -80,16 +82,17 @@ namespace DS4Windows public static SpecialAction[] untriggeraction = new SpecialAction[4]; public static DateTime[] nowAction = { DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue }; public static DateTime[] oldnowAction = { DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue }; - public static int[] untriggerindex = { -1, -1, -1, -1 }; - public static DateTime[] oldnowKeyAct = { DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue }; - //private static bool tappedOnce = false, firstTouch = false, secondtouchbegin = false; - //private static DateTime pastTime, firstTap, TimeofEnd; + public static int[] untriggerindex = new int[4] { -1, -1, -1, -1 }; + public static DateTime[] oldnowKeyAct = new DateTime[4] { DateTime.MinValue, + DateTime.MinValue, DateTime.MinValue, DateTime.MinValue }; + private static DS4Controls[] shiftTriggerMapping = { DS4Controls.None, DS4Controls.Cross, DS4Controls.Circle, DS4Controls.Square, DS4Controls.Triangle, DS4Controls.Options, DS4Controls.Share, DS4Controls.DpadUp, DS4Controls.DpadDown, DS4Controls.DpadLeft, DS4Controls.DpadRight, DS4Controls.PS, DS4Controls.L1, DS4Controls.R1, DS4Controls.L2, DS4Controls.R2, DS4Controls.L3, DS4Controls.R3, DS4Controls.TouchLeft, DS4Controls.TouchUpper, DS4Controls.TouchMulti, DS4Controls.TouchRight, DS4Controls.GyroZNeg, DS4Controls.GyroZPos, DS4Controls.GyroXPos, DS4Controls.GyroXNeg }; + private static int[] ds4ControlMapping = { 0, // DS4Control.None 16, // DS4Controls.LXNeg 20, // DS4Controls.LXPos @@ -128,13 +131,14 @@ namespace DS4Windows // Define here to save some time processing. // It is enough to feel a difference during gameplay. - private static int[] rsOutCurveModeArray = { 0, 0, 0, 0 }; - private static int[] lsOutCurveModeArray = { 0, 0, 0, 0 }; + private static int[] rsOutCurveModeArray = new int[4] { 0, 0, 0, 0 }; + private static int[] lsOutCurveModeArray = new int[4] { 0, 0, 0, 0 }; static bool tempBool = false; // Special macros static bool altTabDone = true; - static DateTime altTabNow = DateTime.UtcNow, oldAltTabNow = DateTime.UtcNow - TimeSpan.FromSeconds(1); + static DateTime altTabNow = DateTime.UtcNow, + oldAltTabNow = DateTime.UtcNow - TimeSpan.FromSeconds(1); // Mouse public static int mcounter = 34; @@ -347,6 +351,7 @@ namespace DS4Windows } state.SavePrevious(true); } + public enum Click { None, Left, Middle, Right, Fourth, Fifth, WUP, WDOWN }; public static void MapClick(int device, Click mouseClick) { @@ -394,17 +399,6 @@ namespace DS4Windows return value1 * percent + value2 * (1 - percent); } - /*static double Clamp(double min, double value, double max) - { - if (value > max) - return max; - else if (value < min) - return min; - else - return value; - } - */ - private static int ClampInt(int min, int value, int max) { return (value < min) ? min : (value > max) ? max : value; @@ -536,16 +530,16 @@ namespace DS4Windows double currentY = Global.Clamp(maxZoneYNegValue, dState.LY, maxZoneYPosValue); //currentX = (byte)((dState.LX >= 127.5f) ? Math.Min(dState.LX, maxZoneX) : Math.Max(dState.LX, maxZoneX)); //currentY = (byte)((dState.LY >= 127.5f) ? Math.Min(dState.LY, maxZoneY) : Math.Max(dState.LY, maxZoneY)); - tempOutputX = ((currentX - 127.5f - tempLsXDead) / (double)(maxZoneX - tempLsXDead)); - tempOutputY = ((currentY - 127.5f - tempLsYDead) / (double)(maxZoneY - tempLsYDead)); + tempOutputX = ((currentX - 127.5f - tempLsXDead) / (maxZoneX - tempLsXDead)); + tempOutputY = ((currentY - 127.5f - tempLsYDead) / (maxZoneY - tempLsYDead)); } } else { double currentX = Global.Clamp(maxZoneXNegValue, dState.LX, maxZoneXPosValue); double currentY = Global.Clamp(maxZoneYNegValue, dState.LY, maxZoneYPosValue); - tempOutputX = (currentX - 127.5f) / (double)(maxZoneX); - tempOutputY = (currentY - 127.5f) / (double)(maxZoneY); + tempOutputX = (currentX - 127.5f) / maxZoneX; + tempOutputY = (currentY - 127.5f) / maxZoneY; } double tempLsXAntiDeadPercent = 0.0, tempLsYAntiDeadPercent = 0.0; @@ -613,8 +607,8 @@ namespace DS4Windows double currentX = Global.Clamp(maxZoneXNegValue, dState.RX, maxZoneXPosValue); double currentY = Global.Clamp(maxZoneYNegValue, dState.RY, maxZoneYPosValue); - tempOutputX = ((currentX - 127.5f - tempRsXDead) / (double)(maxZoneX - tempRsXDead)); - tempOutputY = ((currentY - 127.5f - tempRsYDead) / (double)(maxZoneY - tempRsYDead)); + tempOutputX = ((currentX - 127.5f - tempRsXDead) / (maxZoneX - tempRsXDead)); + tempOutputY = ((currentY - 127.5f - tempRsYDead) / (maxZoneY - tempRsYDead)); //tempOutputX = ((dState.RX - 127.5f - tempRsXDead) / (double)(maxXValue - tempRsXDead)); //tempOutputY = ((dState.RY - 127.5f - tempRsYDead) / (double)(maxYValue - tempRsYDead)); } @@ -624,8 +618,8 @@ namespace DS4Windows double currentX = Global.Clamp(maxZoneXNegValue, dState.RX, maxZoneXPosValue); double currentY = Global.Clamp(maxZoneYNegValue, dState.RY, maxZoneYPosValue); - tempOutputX = (currentX - 127.5f) / (double)(maxZoneX); - tempOutputY = (currentY - 127.5f) / (double)(maxZoneY); + tempOutputX = (currentX - 127.5f) / maxZoneX; + tempOutputY = (currentY - 127.5f) / maxZoneY; //tempOutputX = ((dState.RX - 127.5f) / (double)(maxXValue)); //tempOutputY = ((dState.RY - 127.5f) / (double)(maxYValue)); } @@ -672,7 +666,7 @@ namespace DS4Windows if (cState.L2 > l2Deadzone) { double current = Global.Clamp(0, dState.L2, maxValue); - tempL2Output = ((current - l2Deadzone) / (double)(maxValue - l2Deadzone)); + tempL2Output = ((current - l2Deadzone) / (maxValue - l2Deadzone)); } else { @@ -710,7 +704,7 @@ namespace DS4Windows if (cState.R2 > r2Deadzone) { double current = Global.Clamp(0, dState.R2, maxValue); - tempR2Output = ((current - r2Deadzone) / (double)(maxValue - r2Deadzone)); + tempR2Output = ((current - r2Deadzone) / (maxValue - r2Deadzone)); } else { @@ -875,8 +869,8 @@ namespace DS4Windows } } - bool sOff = isUsingSAforMouse(device); - if (!sOff) + bool sOff = tempBool = isUsingSAforMouse(device); + if (sOff == false) { double SXD = 10 * getSXDeadzone(device); double SZD = 10 * getSZDeadzone(device); @@ -968,6 +962,7 @@ namespace DS4Windows X360Controls x3c; if (Enum.TryParse(key, true, out x3c)) return x3c; + switch (key) { case "Back": return X360Controls.Back; @@ -1011,8 +1006,9 @@ namespace DS4Windows case "Mouse Left": return X360Controls.MouseLeft; case "Mouse Right": return X360Controls.MouseRight; case "Unbound": return X360Controls.Unbound; - + default: break; } + return X360Controls.Unbound; } @@ -1088,7 +1084,6 @@ namespace DS4Windows } else if (actionType == DS4ControlSettings.ActionType.Key) { - //ushort value = ushort.Parse(action.ToString()); ushort value = Convert.ToUInt16(action); if (getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping)) { @@ -2587,7 +2582,7 @@ namespace DS4Windows mcounter = 34; } - value *= 1 + (double)Math.Min(20000, (mouseaccel)) / 10000d; + value *= 1 + Math.Min(20000, (mouseaccel)) / 10000d; prevmouseaccel = mouseaccel; } @@ -2685,40 +2680,32 @@ namespace DS4Windows } else if (controlType == DS4StateFieldMapping.ControlType.GyroDir) { - //double SXD = getSXDeadzone(device); - //double SZD = getSZDeadzone(device); bool sOff = isUsingSAforMouse(device); - //double sxsens = getSXSens(device); - //double szsens = getSZSens(device); switch (control) { case DS4Controls.GyroXPos: { int gyroX = fieldMap.gryodirs[controlNum]; - //result = (byte)(!sOff && sxsens * gyroX > SXD * 10 ? Math.Min(255, sxsens * gyroX * 2) : 0); - result = (byte)(!sOff ? Math.Min(255, gyroX * 2) : 0); + result = (byte)(sOff == false ? Math.Min(255, gyroX * 2) : 0); break; } case DS4Controls.GyroXNeg: { int gyroX = fieldMap.gryodirs[controlNum]; - //result = (byte)(!sOff && sxsens * gyroX < -SXD * 10 ? Math.Min(255, sxsens * -gyroX * 2) : 0); - result = (byte)(!sOff ? Math.Min(255, -gyroX * 2) : 0); + result = (byte)(sOff == false ? Math.Min(255, -gyroX * 2) : 0); break; } case DS4Controls.GyroZPos: { int gyroZ = fieldMap.gryodirs[controlNum]; - //result = (byte)(!sOff && szsens * gyroZ > SZD * 10 ? Math.Min(255, szsens * gyroZ * 2) : 0); - result = (byte)(!sOff ? Math.Min(255, gyroZ * 2) : 0); + result = (byte)(sOff == false ? Math.Min(255, gyroZ * 2) : 0); break; } case DS4Controls.GyroZNeg: { int gyroZ = fieldMap.gryodirs[controlNum]; - //result = (byte)(!sOff && szsens * gyroZ < -SZD * 10 ? Math.Min(255, szsens * -gyroZ * 2) : 0); - result = (byte)(!sOff ? Math.Min(255, -gyroZ * 2) : 0); + result = (byte)(sOff == false ? Math.Min(255, -gyroZ * 2) : 0); break; } default: break; @@ -3002,14 +2989,14 @@ namespace DS4Windows switch (control) { - case DS4Controls.GyroXPos: safeTest = SXSens[device] * fieldMap.gryodirs[controlNum] > 67; break; - case DS4Controls.GyroXNeg: safeTest = SXSens[device] * fieldMap.gryodirs[controlNum] < -67; break; - case DS4Controls.GyroZPos: safeTest = SZSens[device] * fieldMap.gryodirs[controlNum] > 67; break; - case DS4Controls.GyroZNeg: safeTest = SZSens[device] * fieldMap.gryodirs[controlNum] < -67; break; + case DS4Controls.GyroXPos: safeTest = fieldMap.gryodirs[controlNum] > 67; break; + case DS4Controls.GyroXNeg: safeTest = fieldMap.gryodirs[controlNum] < -67; break; + case DS4Controls.GyroZPos: safeTest = fieldMap.gryodirs[controlNum] > 67; break; + case DS4Controls.GyroZNeg: safeTest = fieldMap.gryodirs[controlNum] < -67; break; default: break; } - result = !sOff ? safeTest : false; + result = sOff == false ? safeTest : false; } return result; @@ -3171,7 +3158,7 @@ namespace DS4Windows default: break; } - result = !sOff ? safeTest : false; + result = sOff == false ? safeTest : false; } return result; @@ -3421,7 +3408,7 @@ namespace DS4Windows if (controlType == DS4StateFieldMapping.ControlType.Button) { - result = (byte)(fieldMap.buttons[controlNum] ? trueVal : falseVal); + result = fieldMap.buttons[controlNum] ? trueVal : falseVal; } else if (controlType == DS4StateFieldMapping.ControlType.AxisDir) { @@ -3449,7 +3436,7 @@ namespace DS4Windows } else if (controlType == DS4StateFieldMapping.ControlType.Touch) { - result = (byte)(fieldMap.buttons[controlNum] ? trueVal : falseVal); + result = fieldMap.buttons[controlNum] ? trueVal : falseVal; } else if (controlType == DS4StateFieldMapping.ControlType.SwipeDir) { @@ -3464,15 +3451,13 @@ namespace DS4Windows } else if (controlType == DS4StateFieldMapping.ControlType.GyroDir) { - //double SXD = getSXDeadzone(device); - //double SZD = getSZDeadzone(device); bool sOff = isUsingSAforMouse(device); switch (control) { case DS4Controls.GyroXPos: { - if (!sOff && fieldMap.gryodirs[controlNum] > 0) + if (sOff == false && fieldMap.gryodirs[controlNum] > 0) { if (alt) result = (byte)Math.Min(255, 127 + fieldMap.gryodirs[controlNum]); else result = (byte)Math.Max(0, 127 - fieldMap.gryodirs[controlNum]); } @@ -3481,7 +3466,7 @@ namespace DS4Windows } case DS4Controls.GyroXNeg: { - if (!sOff && fieldMap.gryodirs[controlNum] < 0) + if (sOff == false && fieldMap.gryodirs[controlNum] < 0) { if (alt) result = (byte)Math.Min(255, 127 + -fieldMap.gryodirs[controlNum]); else result = (byte)Math.Max(0, 127 - -fieldMap.gryodirs[controlNum]); } @@ -3490,7 +3475,7 @@ namespace DS4Windows } case DS4Controls.GyroZPos: { - if (!sOff && fieldMap.gryodirs[controlNum] > 0) + if (sOff == false && fieldMap.gryodirs[controlNum] > 0) { if (alt) result = (byte)Math.Min(255, 127 + fieldMap.gryodirs[controlNum]); else result = (byte)Math.Max(0, 127 - fieldMap.gryodirs[controlNum]); } @@ -3499,7 +3484,7 @@ namespace DS4Windows } case DS4Controls.GyroZNeg: { - if (!sOff && fieldMap.gryodirs[controlNum] < 0) + if (sOff == false && fieldMap.gryodirs[controlNum] < 0) { if (alt) result = (byte)Math.Min(255, 127 + -fieldMap.gryodirs[controlNum]); else result = (byte)Math.Max(0, 127 - -fieldMap.gryodirs[controlNum]); } diff --git a/DS4Windows/DS4Control/MouseCursor.cs b/DS4Windows/DS4Control/MouseCursor.cs index 51805e1..60835e8 100644 --- a/DS4Windows/DS4Control/MouseCursor.cs +++ b/DS4Windows/DS4Control/MouseCursor.cs @@ -15,7 +15,8 @@ namespace DS4Windows /** Indicate x/y direction for doing jitter compensation, etc. */ public enum Direction { Negative, Neutral, Positive } // Track direction vector separately and very trivially for now. - private Direction horizontalDirection = Direction.Neutral, verticalDirection = Direction.Neutral; + private Direction horizontalDirection = Direction.Neutral, + verticalDirection = Direction.Neutral; private Direction hDirection = Direction.Neutral, vDirection = Direction.Neutral; private double GYRO_MOUSE_COEFFICIENT = 0.0095; diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 0bc16f4..45c6678 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -802,12 +802,12 @@ namespace DS4Windows DS4StateExposed exposeState = Program.rootHub.ExposedState[tempDeviceNum]; DS4State baseState = Program.rootHub.getDS4State(tempDeviceNum); - 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(tBsixaxisAccelZ, (exposeState.AccelZ + tBsixaxisAccelZ.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisGyroX, (exposeState.getGyroYaw() + tBsixaxisGyroX.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisGyroY, (exposeState.getGyroPitch() + tBsixaxisGyroY.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisGyroZ, (exposeState.getGyroRoll() + tBsixaxisGyroZ.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisAccelX, (exposeState.getAccelX() + tBsixaxisAccelX.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisAccelY, (exposeState.getAccelY() + tBsixaxisAccelY.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisAccelZ, (exposeState.getAccelZ() + tBsixaxisAccelZ.Value * 2) / 3); int x = baseState.LX; int y = baseState.LY; @@ -899,8 +899,8 @@ namespace DS4Windows (int)(tempRSS * (btnRSTrack.Location.Y - pnlRSTrack.Size.Height / 2f) + pnlRSTrack.Size.Height / 2f)); } - x = exposeState.AccelX + 127; - y = exposeState.AccelZ + 127; + x = exposeState.getAccelX() + 127; + y = exposeState.getAccelZ() + 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))); double tempSXS = (double)nUDSXS.Value; diff --git a/DS4Windows/DS4Library/DS4Sixaxis.cs b/DS4Windows/DS4Library/DS4Sixaxis.cs index 14c6aa6..0639c75 100644 --- a/DS4Windows/DS4Library/DS4Sixaxis.cs +++ b/DS4Windows/DS4Library/DS4Sixaxis.cs @@ -53,20 +53,19 @@ namespace DS4Windows public class DS4SixAxis { - // no status change for the touchpad itself... but other sensors may have changed, or you may just want to do some processing public event EventHandler SixAccelMoved = null; internal int lastGyroYaw, lastGyroPitch, lastGyroRoll, - lastAX, lastAY, lastAZ; // tracks 0, 1 or 2 touches; we maintain touch 1 and 2 separately + lastAX, lastAY, lastAZ; internal double lastMilliseconds; internal byte[] previousPacket = new byte[8]; public void handleSixaxis(byte[] gyro, byte[] accel, DS4State state, double milliseconds) { - int currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]); // Gyro Yaw - int currentPitch = (short)((ushort)(gyro[1] << 8) | gyro[0]); // Gyro Pitch - int currentRoll = (short)((ushort)(gyro[5] << 8) | gyro[4]); // Gyro Roll + int currentYaw = (short)((ushort)(gyro[3] << 8) | gyro[2]); + int currentPitch = (short)((ushort)(gyro[1] << 8) | gyro[0]); + int currentRoll = (short)((ushort)(gyro[5] << 8) | gyro[4]); int AccelX = (short)((ushort)(accel[1] << 8) | accel[0]); int AccelY = (short)((ushort)(accel[3] << 8) | accel[2]); int AccelZ = (short)((ushort)(accel[5] << 8) | accel[4]); diff --git a/DS4Windows/DS4Library/DS4StateExposed.cs b/DS4Windows/DS4Library/DS4StateExposed.cs index c2ccd27..56361d4 100644 --- a/DS4Windows/DS4Library/DS4StateExposed.cs +++ b/DS4Windows/DS4Library/DS4StateExposed.cs @@ -15,37 +15,51 @@ namespace DS4Windows _state = state; } - bool Square { get { return _state.Square; } } - bool Triangle { get { return _state.Triangle; } } - bool Circle { get { return _state.Circle; } } - bool Cross { get { return _state.Cross; } } - bool DpadUp { get { return _state.DpadUp; } } - bool DpadDown { get { return _state.DpadDown; } } - bool DpadLeft { get { return _state.DpadLeft; } } - bool DpadRight { get { return _state.DpadRight; } } - bool L1 { get { return _state.L1; } } - bool L3 { get { return _state.L3; } } - bool R1 { get { return _state.R1; } } - bool R3 { get { return _state.R3; } } - bool Share { get { return _state.Share; } } - bool Options { get { return _state.Options; } } - bool PS { get { return _state.PS; } } - bool Touch1 { get { return _state.Touch1; } } - bool Touch2 { get { return _state.Touch2; } } - bool TouchButton { get { return _state.TouchButton; } } - bool Touch1Finger { get { return _state.Touch1Finger; } } + bool Square { get { return _state.Square; } } + bool Triangle { get { return _state.Triangle; } } + bool Circle { get { return _state.Circle; } } + bool Cross { get { return _state.Cross; } } + bool DpadUp { get { return _state.DpadUp; } } + bool DpadDown { get { return _state.DpadDown; } } + bool DpadLeft { get { return _state.DpadLeft; } } + bool DpadRight { get { return _state.DpadRight; } } + bool L1 { get { return _state.L1; } } + bool L3 { get { return _state.L3; } } + bool R1 { get { return _state.R1; } } + bool R3 { get { return _state.R3; } } + bool Share { get { return _state.Share; } } + bool Options { get { return _state.Options; } } + bool PS { get { return _state.PS; } } + bool Touch1 { get { return _state.Touch1; } } + bool Touch2 { get { return _state.Touch2; } } + bool TouchButton { get { return _state.TouchButton; } } + bool Touch1Finger { get { return _state.Touch1Finger; } } bool Touch2Fingers { get { return _state.Touch2Fingers; } } - byte LX { get { return _state.LX; } } - byte RX { get { return _state.RX; } } - byte LY { get { return _state.LY; } } - byte RY { get { return _state.RY; } } - byte L2 { get { return _state.L2; } } - byte R2 { get { return _state.R2; } } + byte LX { get { return _state.LX; } } + byte RX { get { return _state.RX; } } + byte LY { get { return _state.LY; } } + byte RY { get { return _state.RY; } } + byte L2 { get { return _state.L2; } } + byte R2 { get { return _state.R2; } } int Battery { get { return _state.Battery; } } public int GyroYaw { get { return _state.Motion.gyroYaw; } } + public int getGyroYaw() + { + return _state.Motion.gyroYaw; + } + public int GyroPitch { get { return _state.Motion.gyroPitch; } } + public int getGyroPitch() + { + return _state.Motion.gyroPitch; + } + public int GyroRoll { get { return _state.Motion.gyroRoll; } } + public int getGyroRoll() + { + return _state.Motion.gyroRoll; + } public int AccelX { get { return _state.Motion.accelX; } } public int getAccelX()