From 1a8fb309ee34cdcd4eeb92f6247922566c17a932 Mon Sep 17 00:00:00 2001 From: jays2kings Date: Mon, 23 Jun 2014 18:27:14 -0400 Subject: [PATCH] Sixaxis tilts can now mapped, map them to the analog sticks, buttons, keyboards, and even macros Better Support of multiple action being mapped to analog sticks Fixed crash with an empty macro UI Fixes --- DS4Control/Control.cs | 68 +++++----- DS4Control/Mapping.cs | 246 +++++++++++++++++++++--------------- DS4Control/Mouse.cs | 2 +- DS4Control/ScpUtil.cs | 6 +- DS4Tool/Hotkeys.Designer.cs | 16 ++- DS4Tool/Hotkeys.cs | 7 +- DS4Tool/Options.Designer.cs | 106 +++++++++++++--- DS4Tool/Options.cs | 76 ++++++++--- DS4Tool/ScpForm.cs | 6 +- 9 files changed, 354 insertions(+), 179 deletions(-) diff --git a/DS4Control/Control.cs b/DS4Control/Control.cs index 5fe098b..553af73 100644 --- a/DS4Control/Control.cs +++ b/DS4Control/Control.cs @@ -409,7 +409,7 @@ namespace DS4Control if (Global.getHasCustomKeysorButtons(ind)) { - Mapping.MapCustom(ind, cState, MappedState[ind]); + Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind]); cState = MappedState[ind]; } @@ -441,38 +441,42 @@ namespace DS4Control public string GetInputkeys(int ind) { DS4State cState = CurrentState[ind]; + DS4StateExposed eState = ExposedState[ind]; if (DS4Controllers[ind] != null) - if (Mapping.getBoolMapping(DS4Controls.Cross, cState)) return "Cross"; - else if (Mapping.getBoolMapping(DS4Controls.Circle, cState)) return "Circle"; - else if (Mapping.getBoolMapping(DS4Controls.Triangle, cState)) return "Triangle"; - else if (Mapping.getBoolMapping(DS4Controls.Square, cState)) return "Square"; - else if (Mapping.getBoolMapping(DS4Controls.L1, cState)) return "L1"; - else if (Mapping.getBoolMapping(DS4Controls.R1, cState)) return "R1"; - else if (Mapping.getBoolMapping(DS4Controls.L2, cState)) return "L2"; - else if (Mapping.getBoolMapping(DS4Controls.R2, cState)) return "R2"; - else if (Mapping.getBoolMapping(DS4Controls.L3, cState)) return "L3"; - else if (Mapping.getBoolMapping(DS4Controls.R3, cState)) return "R3"; - else if (Mapping.getBoolMapping(DS4Controls.DpadUp, cState)) return "Up"; - else if (Mapping.getBoolMapping(DS4Controls.DpadDown, cState)) return "Down"; - else if (Mapping.getBoolMapping(DS4Controls.DpadLeft, cState)) return "Left"; - else if (Mapping.getBoolMapping(DS4Controls.DpadRight, cState)) return "Right"; - else if (Mapping.getBoolMapping(DS4Controls.Share, cState)) return "Share"; - else if (Mapping.getBoolMapping(DS4Controls.Options, cState)) return "Options"; - else if (Mapping.getBoolMapping(DS4Controls.PS, cState)) return "PS"; - else if (Mapping.getBoolMapping(DS4Controls.LXPos, cState)) return "LS Right"; - else if (Mapping.getBoolMapping(DS4Controls.LXNeg, cState)) return "LS Left"; - else if (Mapping.getBoolMapping(DS4Controls.LYPos, cState)) return "LS Down"; - else if (Mapping.getBoolMapping(DS4Controls.LYNeg, cState)) return "LS Up"; - else if (Mapping.getBoolMapping(DS4Controls.RXPos, cState)) return "RS Right"; - else if (Mapping.getBoolMapping(DS4Controls.RXNeg, cState)) return "RS Left"; - else if (Mapping.getBoolMapping(DS4Controls.RYPos, cState)) return "RS Down"; - else if (Mapping.getBoolMapping(DS4Controls.RYNeg, cState)) return "RS Up"; - else if (Mapping.getBoolMapping(DS4Controls.TouchLeft, cState)) return "Touch Left"; - else if (Mapping.getBoolMapping(DS4Controls.TouchRight, cState)) return "Touch Right"; - else if (Mapping.getBoolMapping(DS4Controls.TouchMulti, cState)) return "Touch Multi"; - else if (Mapping.getBoolMapping(DS4Controls.TouchUpper, cState)) return "Touch Upper"; - else return "nothing"; - else return "nothing"; + if (Mapping.getBoolMapping(DS4Controls.Cross, cState, eState)) return "Cross"; + else if (Mapping.getBoolMapping(DS4Controls.Circle, cState, eState)) return "Circle"; + else if (Mapping.getBoolMapping(DS4Controls.Triangle, cState, eState)) return "Triangle"; + else if (Mapping.getBoolMapping(DS4Controls.Square, cState, eState)) return "Square"; + else if (Mapping.getBoolMapping(DS4Controls.L1, cState, eState)) return "L1"; + else if (Mapping.getBoolMapping(DS4Controls.R1, cState, eState)) return "R1"; + else if (Mapping.getBoolMapping(DS4Controls.L2, cState, eState)) return "L2"; + else if (Mapping.getBoolMapping(DS4Controls.R2, cState, eState)) return "R2"; + else if (Mapping.getBoolMapping(DS4Controls.L3, cState, eState)) return "L3"; + else if (Mapping.getBoolMapping(DS4Controls.R3, cState, eState)) return "R3"; + else if (Mapping.getBoolMapping(DS4Controls.DpadUp, cState, eState)) return "Up"; + else if (Mapping.getBoolMapping(DS4Controls.DpadDown, cState, eState)) return "Down"; + else if (Mapping.getBoolMapping(DS4Controls.DpadLeft, cState, eState)) return "Left"; + else if (Mapping.getBoolMapping(DS4Controls.DpadRight, cState, eState)) return "Right"; + else if (Mapping.getBoolMapping(DS4Controls.Share, cState, eState)) return "Share"; + else if (Mapping.getBoolMapping(DS4Controls.Options, cState, eState)) return "Options"; + else if (Mapping.getBoolMapping(DS4Controls.PS, cState, eState)) return "PS"; + else if (Mapping.getBoolMapping(DS4Controls.LXPos, cState, eState)) return "LS Right"; + else if (Mapping.getBoolMapping(DS4Controls.LXNeg, cState, eState)) return "LS Left"; + else if (Mapping.getBoolMapping(DS4Controls.LYPos, cState, eState)) return "LS Down"; + else if (Mapping.getBoolMapping(DS4Controls.LYNeg, cState, eState)) return "LS Up"; + else if (Mapping.getBoolMapping(DS4Controls.RXPos, cState, eState)) return "RS Right"; + else if (Mapping.getBoolMapping(DS4Controls.RXNeg, cState, eState)) return "RS Left"; + else if (Mapping.getBoolMapping(DS4Controls.RYPos, cState, eState)) return "RS Down"; + else if (Mapping.getBoolMapping(DS4Controls.RYNeg, cState, eState)) return "RS Up"; + else if (Mapping.getBoolMapping(DS4Controls.TouchLeft, cState, eState)) return "Touch Left"; + else if (Mapping.getBoolMapping(DS4Controls.TouchRight, cState, eState)) return "Touch Right"; + else if (Mapping.getBoolMapping(DS4Controls.TouchMulti, cState, eState)) return "Touch Multi"; + else if (Mapping.getBoolMapping(DS4Controls.TouchUpper, cState, eState)) return "Touch Upper"; + /*else if (Mapping.getBoolMapping(DS4Controls.GyroXPos, cState, eState)) return "GyroXP"; + else if (Mapping.getBoolMapping(DS4Controls.GyroXNeg, cState, eState)) return "GyroXN"; + else if (Mapping.getBoolMapping(DS4Controls.GyroZPos, cState, eState)) return "GyroZP"; + else if (Mapping.getBoolMapping(DS4Controls.GyroZNeg, cState, eState)) return "GyroZN";*/ + return "nothing"; } bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false }; diff --git a/DS4Control/Mapping.cs b/DS4Control/Mapping.cs index 6c57434..e940c52 100644 --- a/DS4Control/Mapping.cs +++ b/DS4Control/Mapping.cs @@ -200,7 +200,6 @@ namespace DS4Control { oldnow = DateTime.UtcNow; InputMethods.performKeyPress(kvp.Key); - Console.WriteLine(((System.Windows.Forms.Keys)kvp.Key).ToString()); pressagain = false; keyshelddown = kvp.Key; } @@ -463,14 +462,14 @@ namespace DS4Control public static bool[] pressedonce = new bool[261], macrodone = new bool[30]; public static int test = 0; /** Map DS4 Buttons/Axes to other DS4 Buttons/Axes (largely the same as Xinput ones) and to keyboard and mouse buttons. */ - public static async void MapCustom(int device, DS4State cState, DS4State MappedState) + public static async void MapCustom(int device, DS4State cState, DS4State MappedState, DS4StateExposed eState) { cState.CopyTo(MappedState); SyntheticState deviceState = Mapping.deviceState[device]; foreach (KeyValuePair customKey in Global.getCustomMacros(device)) //with delays { DS4KeyType keyType = Global.getCustomKeyType(device, customKey.Key); - if (getBoolMapping(customKey.Key, cState)) + if (getBoolMapping(customKey.Key, cState, eState)) { resetToDefaultValue(customKey.Key, MappedState); bool LXChanged = (Math.Abs(127 - MappedState.LX) < 5); @@ -492,33 +491,33 @@ namespace DS4Control for (int i = 0; i < keys.Length; i++) keys[i] = ushort.Parse(skeys[i]); bool[] keydown = new bool[261]; - if (keys[0] > 260 && keys[0] < 300) + if (keys.Length > 0 && keys[0] > 260 && keys[0] < 300) { - if (keys[0] == 261 && !MappedState.Cross) MappedState.Cross = getBoolMapping(customKey.Key, cState); - if (keys[0] == 262 && !MappedState.Circle) MappedState.Circle = getBoolMapping(customKey.Key, cState); - if (keys[0] == 263 && !MappedState.Square) MappedState.Square = getBoolMapping(customKey.Key, cState); - if (keys[0] == 264 && !MappedState.Triangle) MappedState.Triangle = getBoolMapping(customKey.Key, cState); - if (keys[0] == 265 && !MappedState.DpadUp) MappedState.DpadUp = getBoolMapping(customKey.Key, cState); - if (keys[0] == 266 && !MappedState.DpadDown) MappedState.DpadDown = getBoolMapping(customKey.Key, cState); - if (keys[0] == 267 && !MappedState.DpadLeft) MappedState.DpadLeft = getBoolMapping(customKey.Key, cState); - if (keys[0] == 268 && !MappedState.DpadRight) MappedState.DpadRight = getBoolMapping(customKey.Key, cState); - if (keys[0] == 269 && !MappedState.Options) MappedState.Options = getBoolMapping(customKey.Key, cState); - if (keys[0] == 270 && !MappedState.Share) MappedState.Share = getBoolMapping(customKey.Key, cState); - if (keys[0] == 271 && !MappedState.PS) MappedState.PS = getBoolMapping(customKey.Key, cState); - if (keys[0] == 272 && !MappedState.L1) MappedState.L1 = getBoolMapping(customKey.Key, cState); - if (keys[0] == 273 && !MappedState.R1) MappedState.R1 = getBoolMapping(customKey.Key, cState); - if (keys[0] == 274 && MappedState.L2 == 0) MappedState.L2 = getByteMapping(customKey.Key, cState); - if (keys[0] == 275 && MappedState.R2 == 0) MappedState.R2 = getByteMapping(customKey.Key, cState); - if (keys[0] == 276 && !MappedState.L3) MappedState.L3 = getBoolMapping(customKey.Key, cState); - if (keys[0] == 277 && !MappedState.R3) MappedState.R3 = getBoolMapping(customKey.Key, cState); - if (keys[0] == 278 && LYChanged) MappedState.LY = getXYAxisMapping(customKey.Key, cState); - if (keys[0] == 279 && LYChanged) MappedState.LY = getXYAxisMapping(customKey.Key, cState, true); - if (keys[0] == 280 && LXChanged) MappedState.LX = getXYAxisMapping(customKey.Key, cState); - if (keys[0] == 281 && LXChanged) MappedState.LX = getXYAxisMapping(customKey.Key, cState, true); - if (keys[0] == 282 && RYChanged) MappedState.RY = getXYAxisMapping(customKey.Key, cState); - if (keys[0] == 283 && RYChanged) MappedState.RY = getXYAxisMapping(customKey.Key, cState, true); - if (keys[0] == 284 && RXChanged) MappedState.RX = getXYAxisMapping(customKey.Key, cState); - if (keys[0] == 285 && RXChanged) MappedState.RX = getXYAxisMapping(customKey.Key, cState, true); + if (keys[0] == 261 && !MappedState.Cross) MappedState.Cross = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 262 && !MappedState.Circle) MappedState.Circle = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 263 && !MappedState.Square) MappedState.Square = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 264 && !MappedState.Triangle) MappedState.Triangle = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 265 && !MappedState.DpadUp) MappedState.DpadUp = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 266 && !MappedState.DpadDown) MappedState.DpadDown = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 267 && !MappedState.DpadLeft) MappedState.DpadLeft = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 268 && !MappedState.DpadRight) MappedState.DpadRight = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 269 && !MappedState.Options) MappedState.Options = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 270 && !MappedState.Share) MappedState.Share = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 271 && !MappedState.PS) MappedState.PS = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 272 && !MappedState.L1) MappedState.L1 = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 273 && !MappedState.R1) MappedState.R1 = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 274 && MappedState.L2 == 0) MappedState.L2 = getByteMapping(customKey.Key, cState, eState); + if (keys[0] == 275 && MappedState.R2 == 0) MappedState.R2 = getByteMapping(customKey.Key, cState, eState); + if (keys[0] == 276 && !MappedState.L3) MappedState.L3 = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 277 && !MappedState.R3) MappedState.R3 = getBoolMapping(customKey.Key, cState, eState); + if (keys[0] == 278 && LYChanged) MappedState.LY = getXYAxisMapping(customKey.Key, cState, eState); + if (keys[0] == 279 && LYChanged) MappedState.LY = getXYAxisMapping(customKey.Key, cState, eState, true); + if (keys[0] == 280 && LXChanged) MappedState.LX = getXYAxisMapping(customKey.Key, cState, eState); + if (keys[0] == 281 && LXChanged) MappedState.LX = getXYAxisMapping(customKey.Key, cState, eState, true); + if (keys[0] == 282 && RYChanged) MappedState.RY = getXYAxisMapping(customKey.Key, cState, eState); + if (keys[0] == 283 && RYChanged) MappedState.RY = getXYAxisMapping(customKey.Key, cState, eState, true); + if (keys[0] == 284 && RXChanged) MappedState.RX = getXYAxisMapping(customKey.Key, cState, eState); + if (keys[0] == 285 && RXChanged) MappedState.RX = getXYAxisMapping(customKey.Key, cState, eState, true); } if (!macrodone[DS4ControltoInt(customKey.Key)]) { @@ -569,13 +568,13 @@ namespace DS4Control } } } - else if (!getBoolMapping(customKey.Key, cState)) + else if (!getBoolMapping(customKey.Key, cState, eState)) macrodone[DS4ControltoInt(customKey.Key)] = false; } foreach (KeyValuePair customKey in Global.getCustomKeys(device)) { DS4KeyType keyType = Global.getCustomKeyType(device, customKey.Key); - if (getBoolMapping(customKey.Key, cState)) + if (getBoolMapping(customKey.Key, cState, eState)) { resetToDefaultValue(customKey.Key, MappedState); SyntheticState.KeyPresses kp; @@ -626,7 +625,7 @@ namespace DS4Control } if (keyType.HasFlag(DS4KeyType.Toggle)) { - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) { resetToDefaultValue(customButton.Key, MappedState); if (!pressedonce[keyvalue]) @@ -642,213 +641,216 @@ namespace DS4Control pressedonce[keyvalue] = false; } } - bool LXChanged = (Math.Abs(127 - MappedState.LX) < 5); - bool LYChanged = (Math.Abs(127 - MappedState.LY) < 5); - bool RXChanged = (Math.Abs(127 - MappedState.RX) < 5); - bool RYChanged = (Math.Abs(127 - MappedState.RY) < 5); + bool LXChanged = Math.Abs(127 - MappedState.LX) <= 5; + bool LYChanged = Math.Abs(127 - MappedState.LY) <= 5; + bool RXChanged = Math.Abs(127 - MappedState.RX) <= 5; + bool RYChanged = Math.Abs(127 - MappedState.RY) <= 5; + + //once++; + resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped switch (customButton.Value) { case X360Controls.A: if (!MappedState.Cross) - MappedState.Cross = getBoolMapping(customButton.Key, cState); + MappedState.Cross = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.B: if (!MappedState.Circle) - MappedState.Circle = getBoolMapping(customButton.Key, cState); + MappedState.Circle = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.X: if (!MappedState.Square) - MappedState.Square = getBoolMapping(customButton.Key, cState); + MappedState.Square = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.Y: if (!MappedState.Triangle) - MappedState.Triangle = getBoolMapping(customButton.Key, cState); + MappedState.Triangle = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.LB: if (!MappedState.L1) - MappedState.L1 = getBoolMapping(customButton.Key, cState); + MappedState.L1 = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.LS: if (!MappedState.L3) - MappedState.L3 = getBoolMapping(customButton.Key, cState); + MappedState.L3 = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.RB: if (!MappedState.R1) - MappedState.R1 = getBoolMapping(customButton.Key, cState); + MappedState.R1 = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.RS: if (!MappedState.R3) - MappedState.R3 = getBoolMapping(customButton.Key, cState); + MappedState.R3 = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.DpadUp: if (!MappedState.DpadUp) - MappedState.DpadUp = getBoolMapping(customButton.Key, cState); + MappedState.DpadUp = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.DpadDown: if (!MappedState.DpadDown) - MappedState.DpadDown = getBoolMapping(customButton.Key, cState); + MappedState.DpadDown = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.DpadLeft: if (!MappedState.DpadLeft) - MappedState.DpadLeft = getBoolMapping(customButton.Key, cState); + MappedState.DpadLeft = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.DpadRight: if (!MappedState.DpadRight) - MappedState.DpadRight = getBoolMapping(customButton.Key, cState); + MappedState.DpadRight = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.Guide: if (!MappedState.PS) - MappedState.PS = getBoolMapping(customButton.Key, cState); + MappedState.PS = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.Back: if (!MappedState.Share) - MappedState.Share = getBoolMapping(customButton.Key, cState); + MappedState.Share = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.Start: if (!MappedState.Options) - MappedState.Options = getBoolMapping(customButton.Key, cState); + MappedState.Options = getBoolMapping(customButton.Key, cState, eState); break; case X360Controls.LXNeg: if (LXChanged) { - MappedState.LX = getXYAxisMapping(customButton.Key, cState); - LX = true; + MappedState.LX = getXYAxisMapping(customButton.Key, cState, eState); + LX = true; } break; case X360Controls.LYNeg: if (LYChanged) { - MappedState.LY = getXYAxisMapping(customButton.Key, cState); - LY = true; + MappedState.LY = getXYAxisMapping(customButton.Key, cState, eState); + LY = true; } break; case X360Controls.RXNeg: if (RXChanged) { - MappedState.RX = getXYAxisMapping(customButton.Key, cState); - RX = true; + MappedState.RX = getXYAxisMapping(customButton.Key, cState, eState); + if (MappedState.RX != 127) + RX = true; } break; case X360Controls.RYNeg: if (RYChanged) { - MappedState.RY = getXYAxisMapping(customButton.Key, cState); - RY = true; + MappedState.RY = getXYAxisMapping(customButton.Key, cState, eState); + RY = true; } break; case X360Controls.LXPos: if (LXChanged) { - MappedState.LX = getXYAxisMapping(customButton.Key, cState, true); - LX = true; + MappedState.LX = getXYAxisMapping(customButton.Key, cState, eState, true); + //Console.WriteLine(MappedState.LX + ""); + LX = true; } break; case X360Controls.LYPos: if (LYChanged) { - MappedState.LY = getXYAxisMapping(customButton.Key, cState, true); - LY = true; + MappedState.LY = getXYAxisMapping(customButton.Key, cState, eState, true); + //Console.WriteLine(MappedState.LY + ""); + LY = true; } break; case X360Controls.RXPos: if (RXChanged) { - MappedState.RX = getXYAxisMapping(customButton.Key, cState, true); - RX = true; + MappedState.RX = getXYAxisMapping(customButton.Key, cState, eState, true); + RX = true; } break; case X360Controls.RYPos: if (RYChanged) { - MappedState.RY = getXYAxisMapping(customButton.Key, cState, true); - RY = true; + MappedState.RY = getXYAxisMapping(customButton.Key, cState, eState, true); + RY = true; } break; case X360Controls.LT: if (MappedState.L2 == 0) - MappedState.L2 = getByteMapping(customButton.Key, cState); + MappedState.L2 = getByteMapping(customButton.Key, cState, eState); break; case X360Controls.RT: if (MappedState.R2 == 0) - MappedState.R2 = getByteMapping(customButton.Key, cState); + MappedState.R2 = getByteMapping(customButton.Key, cState, eState); break; case X360Controls.LeftMouse: - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) deviceState.currentClicks.leftCount++; break; case X360Controls.RightMouse: - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) deviceState.currentClicks.rightCount++; break; case X360Controls.MiddleMouse: - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) deviceState.currentClicks.middleCount++; break; case X360Controls.FourthMouse: - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) deviceState.currentClicks.fourthCount++; break; case X360Controls.FifthMouse: - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) deviceState.currentClicks.fifthCount++; break; case X360Controls.WUP: - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) deviceState.currentClicks.wUpCount++; break; case X360Controls.WDOWN: - if (getBoolMapping(customButton.Key, cState)) + if (getBoolMapping(customButton.Key, cState, eState)) deviceState.currentClicks.wDownCount++; break; case X360Controls.MouseUp: if (MouseDeltaY == 0) { - MouseDeltaY = getMouseMapping(device, customButton.Key, cState, 0); + MouseDeltaY = getMouseMapping(device, customButton.Key, cState, eState, 0); MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY)); } break; case X360Controls.MouseDown: if (MouseDeltaY == 0) { - MouseDeltaY = getMouseMapping(device, customButton.Key, cState, 1); + MouseDeltaY = getMouseMapping(device, customButton.Key, cState, eState, 1); MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY)); } break; case X360Controls.MouseLeft: if (MouseDeltaX == 0) { - MouseDeltaX = getMouseMapping(device, customButton.Key, cState, 2); + MouseDeltaX = getMouseMapping(device, customButton.Key, cState, eState, 2); MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX)); } break; case X360Controls.MouseRight: if (MouseDeltaX == 0) { - MouseDeltaX = getMouseMapping(device, customButton.Key, cState, 3); + MouseDeltaX = getMouseMapping(device, customButton.Key, cState, eState, 3); MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX)); } break; } } - - if (!LX) + //Console.WriteLine(MappedState.LY + " " + LY); + //if (!LX) + if (Math.Abs(127 - MappedState.LX) <= 5)// || (Math.Abs(127 - cState.LX) > 5)) MappedState.LX = cState.LX; - if (!LY) + if (Math.Abs(127 - MappedState.LY) <= 5) MappedState.LY = cState.LY; - if (!RX) + if (Math.Abs(127 - MappedState.RX) <= 5) MappedState.RX = cState.RX; - if (!RY) + if (Math.Abs(127 - MappedState.RY) <= 5) MappedState.RY = cState.RY; - /*if (!L2) - MappedState.L2 = cState.L2; - if (!R2) - MappedState.R2 = cState.R2;//*/ InputMethods.MoveCursorBy(MouseDeltaX, MouseDeltaY); } public static DateTime[] mousenow = { DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow, DateTime.UtcNow }; public static double mvalue = 0; - private static int getMouseMapping(int device, DS4Controls control, DS4State cState, int mnum) + private static int getMouseMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, int mnum) { int deadzone = 10; @@ -909,9 +911,18 @@ namespace DS4Control case DS4Controls.L2: value = Math.Pow(root + speed / divide, cState.L2 / 2d) - 1; break; case DS4Controls.R2: value = Math.Pow(root + speed / divide, cState.R2 / 2d) - 1; break; } - //if (value != 0) - //mvalue = value; - + if (eState != null) + switch (control) + { + case DS4Controls.GyroXPos: return (byte)(eState.GyroX > 1800 ? + Math.Pow(root + speed / divide, eState.GyroX / 48) : 0); + case DS4Controls.GyroXNeg: return (byte)(eState.GyroX < -1800 ? + Math.Pow(root + speed / divide, -eState.GyroX / 48) : 0); + case DS4Controls.GyroZPos: return (byte)(eState.GyroZ > 1800 ? + Math.Pow(root + speed / divide, eState.GyroZ / 48) : 0); + case DS4Controls.GyroZNeg: return (byte)(eState.GyroZ < -1800 ? + Math.Pow(root + speed / divide, -eState.GyroZ / 48) : 0); + } bool LXChanged = (Math.Abs(127 - cState.LX) < deadzone); bool LYChanged = (Math.Abs(127 - cState.LY) < deadzone); bool RXChanged = (Math.Abs(127 - cState.RX) < deadzone); @@ -943,7 +954,7 @@ namespace DS4Control static bool[] touchArea = { true, true, true, true }; - public static byte getByteMapping(DS4Controls control, DS4State cState) + public static byte getByteMapping(DS4Controls control, DS4State cState, DS4StateExposed eState) { if (!cState.TouchButton) for (int i = 0; i < 4; i++) @@ -987,6 +998,14 @@ namespace DS4Control case DS4Controls.L2: return (byte)cState.L2; case DS4Controls.R2: return (byte)cState.R2; } + if (eState != null) + switch (control) + { + case DS4Controls.GyroXPos: return (byte)(eState.GyroX > 1800 ? Math.Min(255, eState.GyroX / 24) : 0); + case DS4Controls.GyroXNeg: return (byte)(eState.GyroX < -1800 ? Math.Min(255,-eState.GyroX / 24) : 0); + case DS4Controls.GyroZPos: return (byte)(eState.GyroZ > 1800 ? Math.Min(255, eState.GyroZ / 24) : 0); + case DS4Controls.GyroZNeg: return (byte)(eState.GyroZ < -1800 ? Math.Min(255, -eState.GyroZ / 24) : 0); + } if (cState.TouchButton) { if (control == DS4Controls.TouchMulti) @@ -1004,7 +1023,7 @@ namespace DS4Control } return 0; } - public static bool getBoolMapping(DS4Controls control, DS4State cState) + public static bool getBoolMapping(DS4Controls control, DS4State cState, DS4StateExposed eState) { if (!cState.TouchButton) for (int i = 0; i < 4; i++) @@ -1047,8 +1066,15 @@ namespace DS4Control case DS4Controls.RYPos: return cState.RY > 127 + 55; case DS4Controls.L2: return cState.L2 > 100; case DS4Controls.R2: return cState.R2 > 100; - } + if (eState != null) + switch (control) + { + case DS4Controls.GyroXPos: return eState.GyroX > 5000; + case DS4Controls.GyroXNeg: return eState.GyroX < -5000; + case DS4Controls.GyroZPos: return eState.GyroZ > 5000; + case DS4Controls.GyroZNeg: return eState.GyroZ < -5000; + } if (cState.TouchButton) { if (control == DS4Controls.TouchMulti) @@ -1067,14 +1093,12 @@ namespace DS4Control return false; } - public static byte getXYAxisMapping(DS4Controls control, DS4State cState, bool alt = false) + public static byte getXYAxisMapping(DS4Controls control, DS4State cState, DS4StateExposed eState, bool alt = false) { byte trueVal = 0; byte falseVal = 127; if (alt) - { trueVal = 255; - } if (!cState.TouchButton) for (int i = 0; i < 4; i++) touchArea[i] = false; @@ -1106,10 +1130,28 @@ namespace DS4Control case DS4Controls.Square: return (byte)(cState.Square ? trueVal : falseVal); case DS4Controls.Triangle: return (byte)(cState.Triangle ? trueVal : falseVal); case DS4Controls.Circle: return (byte)(cState.Circle ? trueVal : falseVal); - case DS4Controls.L2: return (byte)(cState.L2 == 255 ? trueVal : falseVal); - case DS4Controls.R2: return (byte)(cState.R2 == 255 ? trueVal : falseVal); + case DS4Controls.L2: if (alt) return (byte)(127 + cState.L2 / 2); else return (byte)(127 - cState.L2 / 2); + case DS4Controls.R2: if (alt) return (byte)(127 + cState.R2 / 2); else return (byte)(127 - cState.R2 / 2); + } + if (eState != null) + { + switch (control) + { + case DS4Controls.GyroXPos: if (eState.GyroX > 1800) + if (alt) return (byte)Math.Min(255, 127 + eState.GyroX / 48); else return (byte)Math.Max(0, 127 - eState.GyroX / 48); + else return falseVal; + case DS4Controls.GyroXNeg: if (eState.GyroX < -1800) + if (alt) return (byte)Math.Min(255, 127 + -eState.GyroX / 48); else return (byte)Math.Max(0, 127 - -eState.GyroX / 48); + else return falseVal; + case DS4Controls.GyroZPos: if (eState.GyroZ > 1800) + if (alt) return (byte)Math.Min(255, 127 + eState.GyroZ / 48); else return (byte)Math.Max(0, 127 - eState.GyroZ / 48); + else return falseVal; + case DS4Controls.GyroZNeg: if (eState.GyroZ < -1800) + if (alt) return (byte)Math.Min(255, 127 + -eState.GyroZ / 48); else return (byte)Math.Max(0, 127 - -eState.GyroZ / 48); + else return falseVal; + } + //Console.Write(eState.GyroX.ToString()); } - if (!alt) { switch (control) diff --git a/DS4Control/Mouse.cs b/DS4Control/Mouse.cs index e925292..20376c2 100644 --- a/DS4Control/Mouse.cs +++ b/DS4Control/Mouse.cs @@ -115,7 +115,7 @@ namespace DS4Control private DS4State remapped = new DS4State(); private void synthesizeMouseButtons() { - Mapping.MapCustom(deviceNum, s, remapped); + Mapping.MapCustom(deviceNum, s, remapped, null); if (leftDown) Mapping.MapTouchpadButton(deviceNum, DS4Controls.TouchLeft, Mapping.Click.Left, remapped); if (upperDown) diff --git a/DS4Control/ScpUtil.cs b/DS4Control/ScpUtil.cs index 16ef465..b2135ed 100644 --- a/DS4Control/ScpUtil.cs +++ b/DS4Control/ScpUtil.cs @@ -13,7 +13,7 @@ namespace DS4Control [Flags] public enum DS4KeyType : byte { None = 0, ScanCode = 1, Toggle = 2, Unbound = 4, Macro = 8, HoldMacro = 16, RepeatMacro = 32 }; //Increment by exponents of 2*, starting at 2^0 public enum Ds3PadId : byte { None = 0xFF, One = 0x00, Two = 0x01, Three = 0x02, Four = 0x03, All = 0x04 }; - public enum DS4Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, L1, L2, L3, R1, R2, R3, Square, Triangle, Circle, Cross, DpadUp, DpadRight, DpadDown, DpadLeft, PS, TouchLeft, TouchUpper, TouchMulti, TouchRight, Share, Options }; + public enum DS4Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, L1, L2, L3, R1, R2, R3, Square, Triangle, Circle, Cross, DpadUp, DpadRight, DpadDown, DpadLeft, PS, TouchLeft, TouchUpper, TouchMulti, TouchRight, Share, Options, GyroXPos, GyroXNeg, GyroZPos, GyroZNeg }; public enum X360Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, LB, LT, LS, RB, RT, RS, X, Y, B, A, DpadUp, DpadRight, DpadDown, DpadLeft, Guide, Back, Start, LeftMouse, RightMouse, MiddleMouse, FourthMouse, FifthMouse, WUP, WDOWN, MouseUp, MouseDown, MouseLeft, MouseRight, Unbound }; public class DebugEventArgs : EventArgs @@ -836,6 +836,10 @@ namespace DS4Control case "bnTouchMulti": return DS4Controls.TouchMulti; case "bnTouchUpper": return DS4Controls.TouchUpper; case "bnTouchRight": return DS4Controls.TouchRight; + case "bnGyroXP": return DS4Controls.GyroXPos; + case "bnGyroXN": return DS4Controls.GyroXNeg; + case "bnGyroZP": return DS4Controls.GyroZPos; + case "bnGyroZN": return DS4Controls.GyroZNeg; } return 0; } diff --git a/DS4Tool/Hotkeys.Designer.cs b/DS4Tool/Hotkeys.Designer.cs index f522e8d..4f441a1 100644 --- a/DS4Tool/Hotkeys.Designer.cs +++ b/DS4Tool/Hotkeys.Designer.cs @@ -67,6 +67,7 @@ this.label30 = new System.Windows.Forms.Label(); this.label31 = new System.Windows.Forms.Label(); this.lLChangelog = new System.Windows.Forms.LinkLabel(); + this.linkDonate = new System.Windows.Forms.LinkLabel(); this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -153,7 +154,7 @@ // label23 // this.label23.AutoSize = true; - this.label23.Location = new System.Drawing.Point(458, 9); + this.label23.Location = new System.Drawing.Point(6, 333); this.label23.Name = "label23"; this.label23.Size = new System.Drawing.Size(58, 13); this.label23.TabIndex = 3; @@ -497,6 +498,17 @@ this.lLChangelog.Text = "Changelog"; this.lLChangelog.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lLChangelog_LinkClicked); // + // linkDonate + // + this.linkDonate.AutoSize = true; + this.linkDonate.Location = new System.Drawing.Point(422, 9); + this.linkDonate.Name = "linkDonate"; + this.linkDonate.Size = new System.Drawing.Size(94, 13); + this.linkDonate.TabIndex = 21; + this.linkDonate.TabStop = true; + this.linkDonate.Text = "Donate via Paypal"; + this.linkDonate.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkDonate_LinkClicked); + // // Hotkeys // this.AcceptButton = this.button1; @@ -504,6 +516,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button1; this.ClientSize = new System.Drawing.Size(520, 413); + this.Controls.Add(this.linkDonate); this.Controls.Add(this.lLChangelog); this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.linkJhebbel); @@ -567,5 +580,6 @@ private System.Windows.Forms.Label label30; private System.Windows.Forms.Label label31; private System.Windows.Forms.LinkLabel lLChangelog; + private System.Windows.Forms.LinkLabel linkDonate; } } \ No newline at end of file diff --git a/DS4Tool/Hotkeys.cs b/DS4Tool/Hotkeys.cs index 9291e16..2c86667 100644 --- a/DS4Tool/Hotkeys.cs +++ b/DS4Tool/Hotkeys.cs @@ -44,7 +44,7 @@ namespace ScpServer private void linkJhebbel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - System.Diagnostics.Process.Start("https://code.google.com/r/jhebbel-ds4tool/source/browse/"); + System.Diagnostics.Process.Start("http://dsdcs.com/index.php/portfolio/software-development/4-ds4windows"); } private void lLChangelog_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -52,5 +52,10 @@ namespace ScpServer System.Diagnostics.Process.Start("https://docs.google.com/document/d/1l4xcgVQkGUskc5CQ0p069yW22Cd5WAH_yE3Fz2hXo0E/edit?usp=sharing"); } + private void linkDonate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2FTZ9BZEHSQ8Q&lc=US&item_name=DS4Windows¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"); + } + } } diff --git a/DS4Tool/Options.Designer.cs b/DS4Tool/Options.Designer.cs index 8a44955..cee5594 100644 --- a/DS4Tool/Options.Designer.cs +++ b/DS4Tool/Options.Designer.cs @@ -120,6 +120,7 @@ this.FullPanel = new System.Windows.Forms.Panel(); this.lowBatteryPanel = new System.Windows.Forms.Panel(); this.SixaxisPanel = new System.Windows.Forms.Panel(); + this.bnGyroZP = new System.Windows.Forms.Button(); this.lBProfileTip = new System.Windows.Forms.Label(); this.tBProfile = new System.Windows.Forms.TextBox(); this.btnSaveProfile = new System.Windows.Forms.Button(); @@ -147,6 +148,10 @@ this.gBRumble = new System.Windows.Forms.GroupBox(); this.gBDeadzone = new System.Windows.Forms.GroupBox(); this.btnCancel = new System.Windows.Forms.Button(); + this.bnGyroXP = new System.Windows.Forms.Button(); + this.bnGyroXN = new System.Windows.Forms.Button(); + this.bnGyroZN = new System.Windows.Forms.Button(); + this.fLPTiltControls = new System.Windows.Forms.FlowLayoutPanel(); this.advColorDialog = new ScpServer.AdvancedColorDialog(); this.MainPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pBController)).BeginInit(); @@ -188,6 +193,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDflashLED)).BeginInit(); this.gBRumble.SuspendLayout(); this.gBDeadzone.SuspendLayout(); + this.fLPTiltControls.SuspendLayout(); this.SuspendLayout(); // // bnTouchUpper @@ -893,7 +899,7 @@ // lBControlTip // this.lBControlTip.AutoSize = true; - this.lBControlTip.Location = new System.Drawing.Point(25, 9); + this.lBControlTip.Location = new System.Drawing.Point(25, 3); this.lBControlTip.Name = "lBControlTip"; this.lBControlTip.Size = new System.Drawing.Size(219, 26); this.lBControlTip.TabIndex = 181; @@ -933,7 +939,11 @@ "Right Stick Up :", "Right Stick Down :", "Right Stick Left :", - "Right Stick Right :"}); + "Right Stick Right :", + "Sixaxis Up :", + "Sixaxis Down :", + "Sixaxis Left :", + "Sixaxis Right :"}); this.lBControls.Location = new System.Drawing.Point(258, 9); this.lBControls.Name = "lBControls"; this.lBControls.Size = new System.Drawing.Size(169, 173); @@ -1252,7 +1262,7 @@ // nUDIdleDisconnect // this.nUDIdleDisconnect.DecimalPlaces = 1; - this.nUDIdleDisconnect.Location = new System.Drawing.Point(108, 46); + this.nUDIdleDisconnect.Location = new System.Drawing.Point(109, 46); this.nUDIdleDisconnect.Maximum = new decimal(new int[] { 60, 0, @@ -1286,8 +1296,7 @@ // this.tBsixaxisAccelZ.AutoSize = false; this.tBsixaxisAccelZ.BackColor = System.Drawing.Color.White; - this.tBsixaxisAccelZ.Enabled = false; - this.tBsixaxisAccelZ.Location = new System.Drawing.Point(382, 6); + this.tBsixaxisAccelZ.Location = new System.Drawing.Point(315, 3); this.tBsixaxisAccelZ.Maximum = 32767; this.tBsixaxisAccelZ.Minimum = -32768; this.tBsixaxisAccelZ.Name = "tBsixaxisAccelZ"; @@ -1312,8 +1321,7 @@ // this.tBsixaxisAccelY.AutoSize = false; this.tBsixaxisAccelY.BackColor = System.Drawing.Color.White; - this.tBsixaxisAccelY.Enabled = false; - this.tBsixaxisAccelY.Location = new System.Drawing.Point(335, 6); + this.tBsixaxisAccelY.Location = new System.Drawing.Point(268, 3); this.tBsixaxisAccelY.Maximum = 32767; this.tBsixaxisAccelY.Minimum = -32768; this.tBsixaxisAccelY.Name = "tBsixaxisAccelY"; @@ -1334,8 +1342,7 @@ // this.tBsixaxisAccelX.AutoSize = false; this.tBsixaxisAccelX.BackColor = System.Drawing.Color.White; - this.tBsixaxisAccelX.Enabled = false; - this.tBsixaxisAccelX.Location = new System.Drawing.Point(289, 6); + this.tBsixaxisAccelX.Location = new System.Drawing.Point(222, 3); this.tBsixaxisAccelX.Maximum = 32767; this.tBsixaxisAccelX.Minimum = -32768; this.tBsixaxisAccelX.Name = "tBsixaxisAccelX"; @@ -1356,8 +1363,7 @@ // this.tBsixaxisGyroZ.AutoSize = false; this.tBsixaxisGyroZ.BackColor = System.Drawing.Color.White; - this.tBsixaxisGyroZ.Enabled = false; - this.tBsixaxisGyroZ.Location = new System.Drawing.Point(163, 6); + this.tBsixaxisGyroZ.Location = new System.Drawing.Point(96, 3); this.tBsixaxisGyroZ.Maximum = 32767; this.tBsixaxisGyroZ.Minimum = -32768; this.tBsixaxisGyroZ.Name = "tBsixaxisGyroZ"; @@ -1378,8 +1384,7 @@ // this.tBsixaxisGyroY.AutoSize = false; this.tBsixaxisGyroY.BackColor = System.Drawing.Color.White; - this.tBsixaxisGyroY.Enabled = false; - this.tBsixaxisGyroY.Location = new System.Drawing.Point(116, 6); + this.tBsixaxisGyroY.Location = new System.Drawing.Point(49, 3); this.tBsixaxisGyroY.Maximum = 32767; this.tBsixaxisGyroY.Minimum = -32768; this.tBsixaxisGyroY.Name = "tBsixaxisGyroY"; @@ -1391,8 +1396,7 @@ // this.tBsixaxisGyroX.AutoSize = false; this.tBsixaxisGyroX.BackColor = System.Drawing.Color.White; - this.tBsixaxisGyroX.Enabled = false; - this.tBsixaxisGyroX.Location = new System.Drawing.Point(69, 6); + this.tBsixaxisGyroX.Location = new System.Drawing.Point(2, 3); this.tBsixaxisGyroX.Maximum = 32767; this.tBsixaxisGyroX.Minimum = -32768; this.tBsixaxisGyroX.Name = "tBsixaxisGyroX"; @@ -1421,7 +1425,7 @@ // lB6Accel // this.lB6Accel.AutoSize = true; - this.lB6Accel.Location = new System.Drawing.Point(220, 6); + this.lB6Accel.Location = new System.Drawing.Point(153, 3); this.lB6Accel.Name = "lB6Accel"; this.lB6Accel.Size = new System.Drawing.Size(72, 13); this.lB6Accel.TabIndex = 215; @@ -1443,11 +1447,12 @@ // lB6Gryo // this.lB6Gryo.AutoSize = true; - this.lB6Gryo.Location = new System.Drawing.Point(5, 6); + this.lB6Gryo.Location = new System.Drawing.Point(4, 197); this.lB6Gryo.Name = "lB6Gryo"; this.lB6Gryo.Size = new System.Drawing.Size(67, 13); this.lB6Gryo.TabIndex = 216; this.lB6Gryo.Text = "Sixaxis Gyro:"; + this.lB6Gryo.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lB6Gryo_MouseClick); // // nUDLightRumble // @@ -1597,17 +1602,27 @@ // SixaxisPanel // this.SixaxisPanel.Controls.Add(this.tBsixaxisAccelX); - this.SixaxisPanel.Controls.Add(this.lB6Gryo); this.SixaxisPanel.Controls.Add(this.lB6Accel); this.SixaxisPanel.Controls.Add(this.tBsixaxisGyroX); this.SixaxisPanel.Controls.Add(this.tBsixaxisGyroY); this.SixaxisPanel.Controls.Add(this.tBsixaxisGyroZ); this.SixaxisPanel.Controls.Add(this.tBsixaxisAccelY); this.SixaxisPanel.Controls.Add(this.tBsixaxisAccelZ); - this.SixaxisPanel.Location = new System.Drawing.Point(1, 193); + this.SixaxisPanel.Location = new System.Drawing.Point(70, 195); this.SixaxisPanel.Name = "SixaxisPanel"; - this.SixaxisPanel.Size = new System.Drawing.Size(435, 27); + this.SixaxisPanel.Size = new System.Drawing.Size(371, 28); this.SixaxisPanel.TabIndex = 236; + this.SixaxisPanel.Visible = false; + // + // bnGyroZP + // + this.bnGyroZP.Location = new System.Drawing.Point(89, 3); + this.bnGyroZP.Name = "bnGyroZP"; + this.bnGyroZP.Size = new System.Drawing.Size(80, 23); + this.bnGyroZP.TabIndex = 250; + this.bnGyroZP.Text = "Tilt Down"; + this.bnGyroZP.UseVisualStyleBackColor = true; + this.bnGyroZP.Click += new System.EventHandler(this.Show_ControlsBn); // // lBProfileTip // @@ -1991,6 +2006,47 @@ this.btnCancel.Visible = false; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // + // bnGyroXP + // + this.bnGyroXP.Location = new System.Drawing.Point(175, 3); + this.bnGyroXP.Name = "bnGyroXP"; + this.bnGyroXP.Size = new System.Drawing.Size(80, 23); + this.bnGyroXP.TabIndex = 250; + this.bnGyroXP.Text = "Tilt Left"; + this.bnGyroXP.UseVisualStyleBackColor = true; + this.bnGyroXP.Click += new System.EventHandler(this.Show_ControlsBn); + // + // bnGyroXN + // + this.bnGyroXN.Location = new System.Drawing.Point(261, 3); + this.bnGyroXN.Name = "bnGyroXN"; + this.bnGyroXN.Size = new System.Drawing.Size(80, 23); + this.bnGyroXN.TabIndex = 250; + this.bnGyroXN.Text = "Tilt Right"; + this.bnGyroXN.UseVisualStyleBackColor = true; + this.bnGyroXN.Click += new System.EventHandler(this.Show_ControlsBn); + // + // bnGyroZN + // + this.bnGyroZN.Location = new System.Drawing.Point(3, 3); + this.bnGyroZN.Name = "bnGyroZN"; + this.bnGyroZN.Size = new System.Drawing.Size(80, 23); + this.bnGyroZN.TabIndex = 250; + this.bnGyroZN.Text = "Tilt Up"; + this.bnGyroZN.UseVisualStyleBackColor = true; + this.bnGyroZN.Click += new System.EventHandler(this.Show_ControlsBn); + // + // fLPTiltControls + // + this.fLPTiltControls.Controls.Add(this.bnGyroZN); + this.fLPTiltControls.Controls.Add(this.bnGyroZP); + this.fLPTiltControls.Controls.Add(this.bnGyroXP); + this.fLPTiltControls.Controls.Add(this.bnGyroXN); + this.fLPTiltControls.Location = new System.Drawing.Point(84, 190); + this.fLPTiltControls.Name = "fLPTiltControls"; + this.fLPTiltControls.Size = new System.Drawing.Size(350, 31); + this.fLPTiltControls.TabIndex = 252; + // // advColorDialog // this.advColorDialog.AnyColor = true; @@ -2006,11 +2062,11 @@ this.CancelButton = this.btnCancel; this.ClientSize = new System.Drawing.Size(888, 295); this.Controls.Add(this.btnCancel); + this.Controls.Add(this.lB6Gryo); this.Controls.Add(this.gBDeadzone); this.Controls.Add(this.gBRumble); this.Controls.Add(this.gBLightbar); this.Controls.Add(this.gBTouchpad); - this.Controls.Add(this.SixaxisPanel); this.Controls.Add(this.lBProfileTip); this.Controls.Add(this.tBProfile); this.Controls.Add(this.btnSaveProfile); @@ -2019,6 +2075,8 @@ this.Controls.Add(this.MainPanel); this.Controls.Add(this.SticksPanel); this.Controls.Add(this.gBOther); + this.Controls.Add(this.fLPTiltControls); + this.Controls.Add(this.SixaxisPanel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; @@ -2074,6 +2132,7 @@ this.gBRumble.PerformLayout(); this.gBDeadzone.ResumeLayout(false); this.gBDeadzone.PerformLayout(); + this.fLPTiltControls.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -2203,6 +2262,11 @@ private System.Windows.Forms.Button btnChargingColor; private System.Windows.Forms.RadioButton rBColor; private System.Windows.Forms.CheckBox cBIdleDisconnect; + private System.Windows.Forms.Button bnGyroXP; + private System.Windows.Forms.Button bnGyroXN; + private System.Windows.Forms.Button bnGyroZP; + private System.Windows.Forms.Button bnGyroZN; + private System.Windows.Forms.FlowLayoutPanel fLPTiltControls; } }  \ No newline at end of file diff --git a/DS4Tool/Options.cs b/DS4Tool/Options.cs index 06bf1ae..dea02e3 100644 --- a/DS4Tool/Options.cs +++ b/DS4Tool/Options.cs @@ -107,18 +107,15 @@ namespace ScpServer } else Set(); - sixaxisTimer.Start(); - #region watch sixaxis data - - sixaxisTimer.Tick += sixaxisTimer_Tick; - - sixaxisTimer.Interval = 1000 / 60; - #endregion - foreach (System.Windows.Forms.Control control in this.MainPanel.Controls) + foreach (System.Windows.Forms.Control control in MainPanel.Controls) if (control is Button) if (!((Button)control).Name.Contains("btn")) buttons.Add((Button)control); - foreach (System.Windows.Forms.Control control in this.SticksPanel.Controls) + foreach (System.Windows.Forms.Control control in SticksPanel.Controls) + if (control is Button) + if (!((Button)control).Name.Contains("btn")) + buttons.Add((Button)control); + foreach (System.Windows.Forms.Control control in fLPTiltControls.Controls) if (control is Button) if (!((Button)control).Name.Contains("btn")) buttons.Add((Button)control); @@ -133,12 +130,21 @@ namespace ScpServer tp.SetToolTip(pBRainbow, "Always on Rainbow Mode"); tp.SetToolTip(cBFlushHIDQueue, "Flush HID Queue after each reading"); tp.SetToolTip(cBLightbyBattery, "Also dim light by idle timeout if on"); + tp.SetToolTip(lB6Gryo, "Click to see readout of Sixaxis Gyro"); + tp.SetToolTip(tBsixaxisGyroX, "GyroX, Left and Right Tilt"); + tp.SetToolTip(tBsixaxisGyroY, "GyroY, Forward and Back Tilt"); + tp.SetToolTip(tBsixaxisGyroZ, "GyroZ, Up and Down Tilt"); + tp.SetToolTip(tBsixaxisAccelX, "AccelX"); + tp.SetToolTip(tBsixaxisAccelY, "AccelY"); + tp.SetToolTip(tBsixaxisAccelZ, "AccelZ"); advColorDialog.OnUpdateColor += advColorDialog_OnUpdateColor; btnLeftStick.Enter += btnSticks_Enter; btnRightStick.Enter += btnSticks_Enter; UpdateLists(); inputtimer.Start(); inputtimer.Tick += InputDS4; + sixaxisTimer.Tick += sixaxisTimer_Tick; + sixaxisTimer.Interval = 1000 / 60; } void sixaxisTimer_Tick(object sender, EventArgs e) @@ -146,7 +152,7 @@ namespace ScpServer // MEMS gyro data is all calibrated to roughly -1G..1G for values -0x2000..0x1fff // Enough additional acceleration and we are no longer mostly measuring Earth's gravity... // We should try to indicate setpoints of the calibration when exposing this measurement.... - SetDynamicTrackBarValue(tBsixaxisGyroX, (scpDevice.ExposedState[(int)nUDSixaxis.Value -1].GyroX + tBsixaxisGyroX.Value * 2) / 3); + SetDynamicTrackBarValue(tBsixaxisGyroX, (scpDevice.ExposedState[(int)nUDSixaxis.Value - 1].GyroX + tBsixaxisGyroX.Value * 2) / 3); SetDynamicTrackBarValue(tBsixaxisGyroY, (scpDevice.ExposedState[(int)nUDSixaxis.Value - 1].GyroY + tBsixaxisGyroY.Value * 2) / 3); SetDynamicTrackBarValue(tBsixaxisGyroZ, (scpDevice.ExposedState[(int)nUDSixaxis.Value - 1].GyroZ + tBsixaxisGyroZ.Value * 2) / 3); SetDynamicTrackBarValue(tBsixaxisAccelX, (scpDevice.ExposedState[(int)nUDSixaxis.Value - 1].AccelX + tBsixaxisAccelX.Value * 2) / 3); @@ -188,6 +194,10 @@ namespace ScpServer case ("RS Down"): Show_ControlsBn(bnRSDown, e); break; case ("RS Left"): Show_ControlsBn(bnRSLeft, e); break; case ("RS Right"): Show_ControlsBn(bnRSRight, e); break; + case ("GyroXP"): Show_ControlsBn(bnGyroXP, e); break; + case ("GyroXN"): Show_ControlsBn(bnGyroXN, e); break; + case ("GyroZP"): Show_ControlsBn(bnGyroZP, e); break; + case ("GyroZN"): Show_ControlsBn(bnGyroZN, e); break; } #endregion } @@ -225,6 +235,11 @@ namespace ScpServer case ("bnRSDown"): lBControls.SelectedIndex = 26; break; case ("bnRSLeft"): lBControls.SelectedIndex = 27; break; case ("bnRSRight"): lBControls.SelectedIndex = 28; break; + case ("bnGyroZN"): lBControls.SelectedIndex = 29; break; + case ("bnGyroZP"): lBControls.SelectedIndex = 30; break; + case ("bnGyroXP"): lBControls.SelectedIndex = 31; break; + case ("bnGyroXN"): lBControls.SelectedIndex = 32; break; + #endregion } } @@ -704,8 +719,29 @@ namespace ScpServer lBControls.Items[26] = "RS Down : " + bnRSDown.Text; lBControls.Items[27] = "RS Left : " + bnRSLeft.Text; lBControls.Items[28] = "RS Right : " + bnRSRight.Text; + lBControls.Items[29] = "Tilt Up : " + UpdateGyroList(bnGyroZN); + lBControls.Items[30] = "Tilt Down : " + UpdateGyroList(bnGyroZP); + lBControls.Items[31] = "Tilt Left : " + UpdateGyroList(bnGyroXP); + lBControls.Items[32] = "Tilt Right : " + UpdateGyroList(bnGyroXN); + bnGyroZN.Text = "Tilt Up"; + bnGyroZP.Text = "Tilt Down"; + bnGyroXP.Text = "Tilt Left"; + bnGyroXN.Text = "Tilt Right"; } + private string UpdateGyroList(Button button) + { + if (button.Tag is String && (String)button.Tag == "Unbound") + return "Unbound"; + else if (button.Tag is IEnumerable || button.Tag is Int32[] || button.Tag is UInt16[]) + return "Macro"; + else if (button.Tag is Int32 || button.Tag is UInt16) + return ((Keys)(ushort)button.Tag).ToString(); + else if (button.Tag is string) + return button.Tag.ToString(); + else + return string.Empty; + } private void Show_ControlsList(object sender, EventArgs e) { if (lBControls.SelectedIndex == 0) Show_ControlsBn(bnCross, e); @@ -739,6 +775,11 @@ namespace ScpServer if (lBControls.SelectedIndex == 26) Show_ControlsBn(bnRSDown, e); if (lBControls.SelectedIndex == 27) Show_ControlsBn(bnRSLeft, e); if (lBControls.SelectedIndex == 28) Show_ControlsBn(bnRSRight, e); + + if (lBControls.SelectedIndex == 29) Show_ControlsBn(bnGyroZN, e); + if (lBControls.SelectedIndex == 30) Show_ControlsBn(bnGyroZP, e); + if (lBControls.SelectedIndex == 31) Show_ControlsBn(bnGyroXP, e); + if (lBControls.SelectedIndex == 32) Show_ControlsBn(bnGyroXN, e); } private void List_MouseDoubleClick(object sender, MouseEventArgs e) @@ -828,10 +869,6 @@ namespace ScpServer Global.setRightTriggerMiddle(device, (byte)(nUDR2.Value * 255)); } - private void flashLed_CheckedChanged(object sender, EventArgs e) - { - - } Image L = Properties.Resources.LeftTouch; Image R = Properties.Resources.RightTouch; Image M = Properties.Resources.MultiTouch; @@ -925,7 +962,14 @@ namespace ScpServer btnChargingColor.Visible = true; } - - + private void lB6Gryo_MouseClick(object sender, MouseEventArgs e) + { + fLPTiltControls.Visible = !fLPTiltControls.Visible; + SixaxisPanel.Visible = !SixaxisPanel.Visible; + if (SixaxisPanel.Visible) + sixaxisTimer.Start(); + else + sixaxisTimer.Stop(); + } } } diff --git a/DS4Tool/ScpForm.cs b/DS4Tool/ScpForm.cs index 0e4e30b..bb2b138 100644 --- a/DS4Tool/ScpForm.cs +++ b/DS4Tool/ScpForm.cs @@ -17,7 +17,7 @@ namespace ScpServer { public partial class ScpForm : Form { - double version = 10.55; + double version = 10.6; private DS4Control.Control rootHub; delegate void LogDebugDelegate(DateTime Time, String Data); @@ -257,7 +257,7 @@ namespace ScpServer private void test_Tick(object sender, EventArgs e) { lBTest.Visible = true; - lBTest.Text = Mapping.getByteMapping(DS4Controls.R1, rootHub.getDS4State(0)).ToString() + " " + rootHub.getDS4StateMapped(0).R2.ToString(); + lBTest.Text = rootHub.getDS4StateMapped(0).LY.ToString(); } void Hotkeys(object sender, EventArgs e) { @@ -838,12 +838,10 @@ namespace ScpServer lBProfiles.SendToBack(); toolStrip1.SendToBack(); tSOptions.SendToBack(); - FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; opt.FormClosed += delegate { opt = null; RefreshProfiles(); - FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; this.Size = oldsize; oldsize = new System.Drawing.Size(0, 0); tSOptions.Visible = false;