From 1e9bc19fc1c7b541b9cbcfe6c1ec5ea4ae83499c Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Thu, 22 Aug 2019 22:03:03 -0500 Subject: [PATCH 1/7] Initial mouse joystick test --- DS4Windows/DS4Control/Mapping.cs | 9 + DS4Windows/DS4Control/Mouse.cs | 188 ++++++- DS4Windows/DS4Control/ProfilePropGroups.cs | 15 + DS4Windows/DS4Control/ScpUtil.cs | 199 ++++++- DS4Windows/DS4Forms/Options.Designer.cs | 259 ++++++++- DS4Windows/DS4Forms/Options.cs | 386 ++++++++++++-- DS4Windows/DS4Forms/Options.resx | 590 ++++++++++++++++++--- 7 files changed, 1509 insertions(+), 137 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 5cdbc85..5f2a619 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -160,6 +160,9 @@ namespace DS4Windows static DS4SquareStick[] outSqrStk = new DS4SquareStick[4] { new DS4SquareStick(), new DS4SquareStick(), new DS4SquareStick(), new DS4SquareStick()}; + public static byte[] gyroStickX = new byte[4] { 128, 128, 128, 128 }; + public static byte[] gyroStickY = new byte[4] { 128, 128, 128, 128 }; + static ReaderWriterLockSlim syncStateLock = new ReaderWriterLockSlim(); public static SyntheticState globalState = new SyntheticState(); @@ -1870,6 +1873,12 @@ namespace DS4Windows MappedState.SASteeringWheelEmulationUnit = Mapping.Scale360degreeGyroAxis(device, eState, ctrl); } + ref byte gyroTempX = ref gyroStickX[device]; + if (gyroTempX != 128) MappedState.RX = gyroTempX; + ref byte gyroTempY = ref gyroStickY[device]; + if (gyroTempY != 128) MappedState.RY = gyroTempY; + gyroTempX = gyroTempY = 128; + calculateFinalMouseMovement(ref tempMouseDeltaX, ref tempMouseDeltaY, out mouseDeltaX, out mouseDeltaY); if (mouseDeltaX != 0 || mouseDeltaY != 0) diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index 3438559..6d1a21c 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -75,7 +75,8 @@ namespace DS4Windows public virtual void sixaxisMoved(DS4SixAxis sender, SixAxisEventArgs arg) { - if (Global.isUsingSAforMouse(deviceNum) && Global.getGyroSensitivity(deviceNum) > 0) + GyroOutMode outMode = Global.GetGyroOutMode(deviceNum); + if (outMode == GyroOutMode.Mouse && Global.getGyroSensitivity(deviceNum) > 0) { s = dev.getCurrentStateRef(); @@ -124,7 +125,192 @@ namespace DS4Windows cursor.sixaxisMoved(arg); else cursor.mouseRemainderReset(); + } + else if (outMode == GyroOutMode.MouseJoystick) + { + s = dev.getCurrentStateRef(); + + useReverseRatchet = Global.GetGyroMouseStickTriggerTurns(deviceNum); + int i = 0; + string[] ss = Global.GetSAMousestickTriggers(deviceNum).Split(','); + bool andCond = Global.GetSAMouseStickTriggerCond(deviceNum); + triggeractivated = andCond ? true : false; + if (!string.IsNullOrEmpty(ss[0])) + { + string s = string.Empty; + for (int index = 0, arlen = ss.Length; index < arlen; index++) + { + s = ss[index]; + if (andCond && !(int.TryParse(s, out i) && getDS4ControlsByName(i))) + { + triggeractivated = false; + break; + } + else if (!andCond && int.TryParse(s, out i) && getDS4ControlsByName(i)) + { + triggeractivated = true; + break; + } + } + } + + previousTriggerActivated = triggeractivated; + if (toggleGyroMouse) + { + if (triggeractivated && triggeractivated != previousTriggerActivated) + { + currentToggleGyroM = !currentToggleGyroM; + } + + previousTriggerActivated = triggeractivated; + triggeractivated = currentToggleGyroM; + } + else + { + previousTriggerActivated = triggeractivated; + } + + if (useReverseRatchet && triggeractivated) + SixMouseStick(arg); + else if (!useReverseRatchet && !triggeractivated) + SixMouseStick(arg); + //else + // SixMouseReset(arg); + } + } + + /*private const int GyroMouseStickDeadZone = 50; + private const int GyroMouseStickMaxZone = 880; + private const int GyroMouseStickFuzz = 20; + private const int SMOOTH_BUFFER_LEN = 3; + private int[] xSmoothBuffer = new int[SMOOTH_BUFFER_LEN]; + private int[] ySmoothBuffer = new int[SMOOTH_BUFFER_LEN]; + private int smoothBufferTail = 0; + + private void SixMouseReset(SixAxisEventArgs args) + { + int iIndex = smoothBufferTail % SMOOTH_BUFFER_LEN; + xSmoothBuffer[iIndex] = 0; + ySmoothBuffer[iIndex] = 0; + smoothBufferTail = iIndex + 1; + } + */ + + private void SixMouseStick(SixAxisEventArgs arg) + { + int deltaX = 0, deltaY = 0; + deltaX = Global.getGyroMouseStickHorizontalAxis(0) == 0 ? arg.sixAxis.gyroYawFull : + arg.sixAxis.gyroRollFull; + deltaY = -arg.sixAxis.gyroPitchFull; + //int inputX = deltaX, inputY = deltaY; + int maxDirX = deltaX >= 0 ? 127 : -128; + int maxDirY = deltaY >= 0 ? 127 : -128; + + GyroMouseStickInfo msinfo = Global.GetGyroMouseStickInfo(deviceNum); + + double tempAngle = Math.Atan2(-deltaY, deltaX); + double normX = Math.Abs(Math.Cos(tempAngle)); + double normY = Math.Abs(Math.Sin(tempAngle)); + int signX = Math.Sign(deltaX); + int signY = Math.Sign(deltaY); + + int deadzoneX = (int)Math.Abs(normX * msinfo.deadZone); + int deadzoneY = (int)Math.Abs(normY * msinfo.deadZone); + + int maxValX = signX * msinfo.maxZone; + int maxValY = signY * msinfo.maxZone; + + double xratio = 0.0, yratio = 0.0; + double antiX = msinfo.antiDeadX * normX; + double antiY = msinfo.antiDeadY * normY; + + if (Math.Abs(deltaX) > deadzoneX) + { + deltaX -= signX * deadzoneX; + deltaX = (deltaX < 0 && deltaX < maxValX) ? maxValX : + (deltaX > 0 && deltaX > maxValX) ? maxValX : deltaX; + //if (deltaX != maxValX) deltaX -= deltaX % (signX * GyroMouseFuzz); + } + else + { + deltaX = 0; + } + + if (Math.Abs(deltaY) > deadzoneY) + { + deltaY -= signY * deadzoneY; + deltaY = (deltaY < 0 && deltaY < maxValY) ? maxValY : + (deltaY > 0 && deltaY > maxValY) ? maxValY : deltaY; + //if (deltaY != maxValY) deltaY -= deltaY % (signY * GyroMouseFuzz); + } + else + { + deltaY = 0; + } + + /*int iIndex = smoothBufferTail % SMOOTH_BUFFER_LEN; + xSmoothBuffer[iIndex] = deltaX; + ySmoothBuffer[iIndex] = deltaY; + smoothBufferTail = iIndex + 1; + + double currentWeight = 1.0; + double finalWeight = 0.0; + double x_out = 0.0, y_out = 0.0; + int idx = 0; + for (int i = 0; i < SMOOTH_BUFFER_LEN; i++) + { + idx = (smoothBufferTail - i - 1 + SMOOTH_BUFFER_LEN) % SMOOTH_BUFFER_LEN; + x_out += xSmoothBuffer[idx] * currentWeight; + y_out += ySmoothBuffer[idx] * currentWeight; + finalWeight += currentWeight; + currentWeight *= 0.5; + } + + x_out /= finalWeight; + deltaX = (int)x_out; + y_out /= finalWeight; + deltaY = (int)y_out; + + maxValX = deltaX < 0 ? -msinfo.maxZone : msinfo.maxZone; + maxValY = deltaY < 0 ? -msinfo.maxZone : msinfo.maxZone; + maxDirX = deltaX >= 0 ? 127 : -128; + maxDirY = deltaY >= 0 ? 127 : -128; + */ + + if (deltaX != 0) xratio = deltaX / (double)maxValX; + if (deltaY != 0) yratio = deltaY / (double)maxValY; + + double xNorm = 0.0, yNorm = 0.0; + if (xratio != 0.0) + { + xNorm = (1.0 - antiX) * xratio + antiX; + } + + if (yratio != 0.0) + { + yNorm = (1.0 - antiY) * yratio + antiY; + } + + if (msinfo.inverted != 0) + { + if ((msinfo.inverted & 1) == 1) + { + // Invert max dir value + maxDirX = deltaX >= 0 ? -128 : 127; + } + + if ((msinfo.inverted & 2) == 2) + { + // Invert max dir value + maxDirY = deltaY >= 0 ? -128 : 127; + } + } + + byte axisXOut = (byte)(xNorm * maxDirX + 128.0); + byte axisYOut = (byte)(yNorm * maxDirY + 128.0); + Mapping.gyroStickX[deviceNum] = axisXOut; + Mapping.gyroStickY[deviceNum] = axisYOut; } private bool getDS4ControlsByName(int key) diff --git a/DS4Windows/DS4Control/ProfilePropGroups.cs b/DS4Windows/DS4Control/ProfilePropGroups.cs index b4fca06..eb3dad3 100644 --- a/DS4Windows/DS4Control/ProfilePropGroups.cs +++ b/DS4Windows/DS4Control/ProfilePropGroups.cs @@ -22,4 +22,19 @@ namespace DS4Windows public int antiDeadZone; public int maxZone = 100; } + + public class GyroMouseInfo + { + + } + + public class GyroMouseStickInfo + { + public int deadZone; + public int maxZone; + public double antiDeadX; + public double antiDeadY; + // Flags representing invert axis choices + public uint inverted; + } } \ No newline at end of file diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index cdd8faf..68e2ba3 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -23,6 +23,14 @@ namespace DS4Windows public enum SASteeringWheelEmulationAxisType: byte { None = 0, LX, LY, RX, RY, L2R2, VJoy1X, VJoy1Y, VJoy1Z, VJoy2X, VJoy2Y, VJoy2Z }; public enum OutContType : uint { None = 0, X360, DS4 } + public enum GyroOutMode : uint + { + None, + Controls, + Mouse, + MouseJoystick, + } + public class DS4ControlSettings { public DS4Controls control; @@ -827,7 +835,7 @@ namespace DS4Windows public static bool[] UseSAforMouse => m_Config.useSAforMouse; public static bool isUsingSAforMouse(int index) { - return m_Config.useSAforMouse[index]; + return m_Config.gyroOutMode[index] == DS4Windows.GyroOutMode.Mouse; } public static string[] SATriggers => m_Config.sATriggers; @@ -846,6 +854,48 @@ namespace DS4Windows m_Config.SetSaTriggerCond(index, text); } + + public static GyroOutMode[] GyroOutputMode => m_Config.gyroOutMode; + public static GyroOutMode GetGyroOutMode(int device) + { + return m_Config.gyroOutMode[device]; + } + + public static string[] SAMousestickTriggers => m_Config.sAMouseStickTriggers; + public static string GetSAMousestickTriggers(int device) + { + return m_Config.sAMouseStickTriggers[device]; + } + + public static bool[] SAMouseStickTriggerCond => m_Config.sAMouseStickTriggerCond; + public static bool GetSAMouseStickTriggerCond(int device) + { + return m_Config.sAMouseStickTriggerCond[device]; + } + public static void SetSaMouseStickTriggerCond(int index, string text) + { + m_Config.SetSaMouseStickTriggerCond(index, text); + } + + public static bool[] GyroMouseStickTriggerTurns = m_Config.gyroMouseStickTriggerTurns; + public static bool GetGyroMouseStickTriggerTurns(int device) + { + return m_Config.gyroMouseStickTriggerTurns[device]; + } + + public static int[] GyroMouseStickHorizontalAxis => + m_Config.gyroMouseStickHorizontalAxis; + public static int getGyroMouseStickHorizontalAxis(int index) + { + return m_Config.gyroMouseStickHorizontalAxis[index]; + } + + public static GyroMouseStickInfo[] GyroMouseStickInf => m_Config.gyroMStickInfo; + public static GyroMouseStickInfo GetGyroMouseStickInfo(int device) + { + return m_Config.gyroMStickInfo[device]; + } + public static SASteeringWheelEmulationAxisType[] SASteeringWheelEmulationAxis => m_Config.sASteeringWheelEmulationAxis; public static SASteeringWheelEmulationAxisType GetSASteeringWheelEmulationAxis(int index) { @@ -1831,8 +1881,20 @@ namespace DS4Windows public bool[] startTouchpadOff = new bool[5] { false, false, false, false, false }; public bool[] useTPforControls = new bool[5] { false, false, false, false, false }; public bool[] useSAforMouse = new bool[5] { false, false, false, false, false }; + public GyroOutMode[] gyroOutMode = new GyroOutMode[5] { GyroOutMode.Controls, GyroOutMode.Controls, + GyroOutMode.Controls, GyroOutMode.Controls, GyroOutMode.Controls }; public string[] sATriggers = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + public string[] sAMouseStickTriggers = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; public bool[] sATriggerCond = new bool[5] { true, true, true, true, true }; + public bool[] sAMouseStickTriggerCond = new bool[5] { true, true, true, true, true }; + public bool[] gyroMouseStickTriggerTurns = new bool[5] { true, true, true, true, true }; + public GyroMouseStickInfo[] gyroMStickInfo = new GyroMouseStickInfo[5] + { + new GyroMouseStickInfo(), new GyroMouseStickInfo(), + new GyroMouseStickInfo(), new GyroMouseStickInfo(), + new GyroMouseStickInfo() + }; + public SASteeringWheelEmulationAxisType[] sASteeringWheelEmulationAxis = new SASteeringWheelEmulationAxisType[5] { SASteeringWheelEmulationAxisType.None, SASteeringWheelEmulationAxisType.None, SASteeringWheelEmulationAxisType.None, SASteeringWheelEmulationAxisType.None, SASteeringWheelEmulationAxisType.None }; public int[] sASteeringWheelEmulationRange = new int[5] { 360, 360, 360, 360, 360 }; public int[][] touchDisInvertTriggers = new int[5][] { new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, @@ -1892,6 +1954,9 @@ namespace DS4Windows public bool[] gyroSmoothing = new bool[5] { false, false, false, false, false }; public double[] gyroSmoothWeight = new double[5] { 0.5, 0.5, 0.5, 0.5, 0.5 }; public int[] gyroMouseHorizontalAxis = new int[5] { 0, 0, 0, 0, 0 }; + + public int[] gyroMouseStickHorizontalAxis = new int[5] { 0, 0, 0, 0, 0 }; + public bool[] trackballMode = new bool[5] { false, false, false, false, false }; public double[] trackballFriction = new double[5] { 10.0, 10.0, 10.0, 10.0, 10.0 }; public OutContType[] outputDevType = new OutContType[5] { OutContType.X360, @@ -1986,6 +2051,11 @@ namespace DS4Windows sATriggerCond[index] = SaTriggerCondValue(text); } + public void SetSaMouseStickTriggerCond(int index, string text) + { + sAMouseStickTriggerCond[index] = SaTriggerCondValue(text); + } + public void SetGyroMouseDZ(int index, int value, ControlService control) { gyroMouseDZ[index] = value; @@ -2028,6 +2098,56 @@ namespace DS4Windows return id; } + private void PortOldGyroSettings(int device) + { + if (gyroOutMode[device] == GyroOutMode.None) + { + gyroOutMode[device] = GyroOutMode.Controls; + } + } + + private string GetGyroOutModeString(GyroOutMode mode) + { + string result = "None"; + switch(mode) + { + case GyroOutMode.Controls: + result = "Controls"; + break; + case GyroOutMode.Mouse: + result = "Mouse"; + break; + case GyroOutMode.MouseJoystick: + result = "MouseJoystick"; + break; + default: + break; + } + + return result; + } + + private GyroOutMode GetGyroOutModeType(string modeString) + { + GyroOutMode result = GyroOutMode.None; + switch(modeString) + { + case "Controls": + result = GyroOutMode.Controls; + break; + case "Mouse": + result = GyroOutMode.Mouse; + break; + case "MouseJoystick": + result = GyroOutMode.MouseJoystick; + break; + default: + break; + } + + return result; + } + public bool SaveProfile(int device, string propath) { bool Saved = true; @@ -2119,6 +2239,8 @@ namespace DS4Windows XmlNode xmlSASteeringWheelEmulationAxis = m_Xdoc.CreateNode(XmlNodeType.Element, "SASteeringWheelEmulationAxis", null); xmlSASteeringWheelEmulationAxis.InnerText = sASteeringWheelEmulationAxis[device].ToString("G"); Node.AppendChild(xmlSASteeringWheelEmulationAxis); XmlNode xmlSASteeringWheelEmulationRange = m_Xdoc.CreateNode(XmlNodeType.Element, "SASteeringWheelEmulationRange", null); xmlSASteeringWheelEmulationRange.InnerText = sASteeringWheelEmulationRange[device].ToString(); Node.AppendChild(xmlSASteeringWheelEmulationRange); + + XmlNode xmlTouchDisInvTriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "TouchDisInvTriggers", null); string tempTouchDisInv = string.Join(",", touchDisInvertTriggers[device]); xmlTouchDisInvTriggers.InnerText = tempTouchDisInv; @@ -2133,6 +2255,18 @@ namespace DS4Windows XmlNode xmlGyroMouseHAxis = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseHAxis", null); xmlGyroMouseHAxis.InnerText = gyroMouseHorizontalAxis[device].ToString(); Node.AppendChild(xmlGyroMouseHAxis); XmlNode xmlGyroMouseDZ = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseDeadZone", null); xmlGyroMouseDZ.InnerText = gyroMouseDZ[device].ToString(); Node.AppendChild(xmlGyroMouseDZ); XmlNode xmlGyroMouseToggle = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseToggle", null); xmlGyroMouseToggle.InnerText = gyroMouseToggle[device].ToString(); Node.AppendChild(xmlGyroMouseToggle); + + XmlNode xmlGyroOutMode = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroOutputMode", null); xmlGyroOutMode.InnerText = GetGyroOutModeString(gyroOutMode[device]); Node.AppendChild(xmlGyroOutMode); + XmlNode xmlGyroMStickTriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickTriggers", null); xmlGyroMStickTriggers.InnerText = sAMouseStickTriggers[device].ToString(); Node.AppendChild(xmlGyroMStickTriggers); + XmlNode xmlGyroMStickTriggerCond = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickTriggerCond", null); xmlGyroMStickTriggerCond.InnerText = SaTriggerCondString(sAMouseStickTriggerCond[device]); Node.AppendChild(xmlGyroMStickTriggerCond); + XmlNode xmlGyroMStickTriggerTurns = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMousestickTriggerTurns", null); xmlGyroMStickTriggerTurns.InnerText = gyroMouseStickTriggerTurns[device].ToString(); Node.AppendChild(xmlGyroMStickTriggerTurns); + XmlNode xmlGyroMStickHAxis = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickHAxis", null); xmlGyroMStickHAxis.InnerText = gyroMouseStickHorizontalAxis[device].ToString(); Node.AppendChild(xmlGyroMStickHAxis); + XmlNode xmlGyroMStickDZ = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickDeadZone", null); xmlGyroMStickDZ.InnerText = gyroMStickInfo[device].deadZone.ToString(); Node.AppendChild(xmlGyroMStickDZ); + XmlNode xmlGyroMStickMaxZ = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickMaxZone", null); xmlGyroMStickMaxZ.InnerText = gyroMStickInfo[device].maxZone.ToString(); Node.AppendChild(xmlGyroMStickMaxZ); + XmlNode xmlGyroMStickAntiDX = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickAntiDeadX", null); xmlGyroMStickAntiDX.InnerText = gyroMStickInfo[device].antiDeadX.ToString(); Node.AppendChild(xmlGyroMStickAntiDX); + XmlNode xmlGyroMStickAntiDY = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickAntiDeadY", null); xmlGyroMStickAntiDY.InnerText = gyroMStickInfo[device].antiDeadY.ToString(); Node.AppendChild(xmlGyroMStickAntiDY); + XmlNode xmlGyroMStickInvert = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickInvert", null); xmlGyroMStickInvert.InnerText = gyroMStickInfo[device].inverted.ToString(); Node.AppendChild(xmlGyroMStickInvert); + XmlNode xmlLSC = m_Xdoc.CreateNode(XmlNodeType.Element, "LSCurve", null); xmlLSC.InnerText = lsCurve[device].ToString(); Node.AppendChild(xmlLSC); XmlNode xmlRSC = m_Xdoc.CreateNode(XmlNodeType.Element, "RSCurve", null); xmlRSC.InnerText = rsCurve[device].ToString(); Node.AppendChild(xmlRSC); XmlNode xmlProfileActions = m_Xdoc.CreateNode(XmlNodeType.Element, "ProfileActions", null); xmlProfileActions.InnerText = string.Join("/", profileActions[device]); Node.AppendChild(xmlProfileActions); @@ -2973,8 +3107,13 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/UseTPforControls"); bool.TryParse(Item.InnerText, out useTPforControls[device]); } catch { useTPforControls[device] = false; missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/UseSAforMouse"); bool.TryParse(Item.InnerText, out useSAforMouse[device]); } - catch { useSAforMouse[device] = false; missingSetting = true; } + try + { + Item = m_Xdoc.SelectSingleNode("/" + rootname + "/UseSAforMouse"); + bool.TryParse(Item.InnerText, out bool temp); + if (temp) gyroOutMode[device] = GyroOutMode.Mouse; + } + catch { gyroOutMode[device] = GyroOutMode.Controls; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SATriggers"); sATriggers[device] = Item.InnerText; } catch { sATriggers[device] = ""; missingSetting = true; } @@ -2988,6 +3127,52 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SASteeringWheelEmulationRange"); int.TryParse(Item.InnerText, out sASteeringWheelEmulationRange[device]); } catch { sASteeringWheelEmulationRange[device] = 360; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroOutputMode"); GyroOutMode.TryParse(Item.InnerText, out gyroOutMode[device]); } + catch { PortOldGyroSettings(device); missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickTriggers"); sAMouseStickTriggers[device] = Item.InnerText; } + catch { sAMouseStickTriggers[device] = ""; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickTriggerCond"); sAMouseStickTriggerCond[device] = SaTriggerCondValue(Item.InnerText); } + catch { sAMouseStickTriggerCond[device] = true; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMousestickTriggerTurns"); bool.TryParse(Item.InnerText, out gyroTriggerTurns[device]); } + catch { gyroMouseStickTriggerTurns[device] = true; missingSetting = true; } + + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickHAxis"); int temp = 0; int.TryParse(Item.InnerText, out temp); gyroMouseStickHorizontalAxis[device] = Math.Min(Math.Max(0, temp), 1); } + catch { gyroMouseStickHorizontalAxis[device] = 0; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickDeadZone"); int.TryParse(Item.InnerText, out int temp); + gyroMStickInfo[device].deadZone = temp; } + catch { gyroMStickInfo[device].deadZone = 50; missingSetting = true; } + + try + { + Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickMaxZone"); int.TryParse(Item.InnerText, out int temp); + gyroMStickInfo[device].maxZone = temp; + } + catch { gyroMStickInfo[device].maxZone = 880; missingSetting = true; } + + try + { + Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickAntiDeadX"); double.TryParse(Item.InnerText, out double temp); + gyroMStickInfo[device].antiDeadX = temp; + } + catch { gyroMStickInfo[device].antiDeadX = 0.35; missingSetting = true; } + + try + { + Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickAntiDeadY"); double.TryParse(Item.InnerText, out double temp); + gyroMStickInfo[device].antiDeadY = temp; + } + catch { gyroMStickInfo[device].antiDeadY = 0.35; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickInvert"); uint.TryParse(Item.InnerText, out gyroMStickInfo[device].inverted); } + catch { gyroMStickInfo[device].inverted = 0; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/TouchDisInvTriggers"); @@ -3367,6 +3552,8 @@ namespace DS4Windows containsCustomAction[device] = HasCustomActions(device); containsCustomExtras[device] = HasCustomExtras(device); + Program.rootHub.touchPad[device]?.ResetToggleGyroM(); + // If a device exists, make sure to transfer relevant profile device // options to device instance if (postLoad && device < 4) @@ -4361,6 +4548,12 @@ namespace DS4Windows useSAforMouse[device] = false; sATriggers[device] = string.Empty; sATriggerCond[device] = true; + gyroOutMode[device] = GyroOutMode.Controls; + sAMouseStickTriggers[device] = string.Empty; + sAMouseStickTriggerCond[device] = false; + gyroMStickInfo[device].deadZone = 50; gyroMStickInfo[device].maxZone = 880; + gyroMStickInfo[device].antiDeadX = 0.35; gyroMStickInfo[device].antiDeadY = 0.35; + gyroMStickInfo[device].inverted = 0; sASteeringWheelEmulationAxis[device] = SASteeringWheelEmulationAxisType.None; sASteeringWheelEmulationRange[device] = 360; touchDisInvertTriggers[device] = new int[1] { -1 }; diff --git a/DS4Windows/DS4Forms/Options.Designer.cs b/DS4Windows/DS4Forms/Options.Designer.cs index cbaab03..790209d 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -195,6 +195,24 @@ this.lblSteeringWheelEmulationRange = new System.Windows.Forms.Label(); this.cBSteeringWheelEmulationRange = new System.Windows.Forms.ComboBox(); this.btnSteeringWheelEmulationCalibrate = new System.Windows.Forms.Button(); + this.gyroMouseJoyFLP = new System.Windows.Forms.FlowLayoutPanel(); + this.label36 = new System.Windows.Forms.Label(); + this.btnGyroMStickTrig = new System.Windows.Forms.Button(); + this.gyroMStickTrigBehaveCk = new System.Windows.Forms.CheckBox(); + this.label29 = new System.Windows.Forms.Label(); + this.gyroMouseStickDZ = new System.Windows.Forms.NumericUpDown(); + this.label30 = new System.Windows.Forms.Label(); + this.gyroMouseStickMaxZ = new System.Windows.Forms.NumericUpDown(); + this.label31 = new System.Windows.Forms.Label(); + this.gyroMouseStickAntiDeadX = new System.Windows.Forms.NumericUpDown(); + this.label32 = new System.Windows.Forms.Label(); + this.gyroMouseStickAntiDeadY = new System.Windows.Forms.NumericUpDown(); + this.label35 = new System.Windows.Forms.Label(); + this.gyroMouseStickEvalCombo = new System.Windows.Forms.ComboBox(); + this.label33 = new System.Windows.Forms.Label(); + this.gyroMousestickXAxisCom = new System.Windows.Forms.ComboBox(); + this.gyroMouseStickInvertXCk = new System.Windows.Forms.CheckBox(); + this.gyroMouseStickInvertYCk = new System.Windows.Forms.CheckBox(); this.tCControls = new System.Windows.Forms.TabControl(); this.tPControls = new System.Windows.Forms.TabPage(); this.lBControls = new System.Windows.Forms.ListBox(); @@ -326,8 +344,8 @@ this.label13 = new System.Windows.Forms.Label(); this.fLPSettings = new System.Windows.Forms.FlowLayoutPanel(); this.gBGyro = new System.Windows.Forms.GroupBox(); - this.rBSAControls = new System.Windows.Forms.RadioButton(); - this.rBSAMouse = new System.Windows.Forms.RadioButton(); + this.label34 = new System.Windows.Forms.Label(); + this.gyroOutputMode = new System.Windows.Forms.ComboBox(); this.pnlSAMouse = new System.Windows.Forms.Panel(); this.toggleGyroMCb = new System.Windows.Forms.CheckBox(); this.label27 = new System.Windows.Forms.Label(); @@ -452,6 +470,11 @@ this.pnlLSTrack.SuspendLayout(); this.pnlRSTrack.SuspendLayout(); this.fLPTiltControls.SuspendLayout(); + this.gyroMouseJoyFLP.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickDZ)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickMaxZ)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadY)).BeginInit(); this.tCControls.SuspendLayout(); this.tPControls.SuspendLayout(); this.pnlController.SuspendLayout(); @@ -2008,6 +2031,180 @@ this.btnSteeringWheelEmulationCalibrate.UseVisualStyleBackColor = true; this.btnSteeringWheelEmulationCalibrate.Click += new System.EventHandler(this.btnSteeringWheelEmulationCalibrate_Click); // + // gyroMouseJoyFLP + // + this.gyroMouseJoyFLP.Controls.Add(this.label36); + this.gyroMouseJoyFLP.Controls.Add(this.btnGyroMStickTrig); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMStickTrigBehaveCk); + this.gyroMouseJoyFLP.Controls.Add(this.label29); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickDZ); + this.gyroMouseJoyFLP.Controls.Add(this.label30); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickMaxZ); + this.gyroMouseJoyFLP.Controls.Add(this.label31); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickAntiDeadX); + this.gyroMouseJoyFLP.Controls.Add(this.label32); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickAntiDeadY); + this.gyroMouseJoyFLP.Controls.Add(this.label35); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickEvalCombo); + this.gyroMouseJoyFLP.Controls.Add(this.label33); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMousestickXAxisCom); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickInvertXCk); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickInvertYCk); + resources.ApplyResources(this.gyroMouseJoyFLP, "gyroMouseJoyFLP"); + this.gyroMouseJoyFLP.Name = "gyroMouseJoyFLP"; + // + // label36 + // + resources.ApplyResources(this.label36, "label36"); + this.label36.Name = "label36"; + // + // btnGyroMStickTrig + // + resources.ApplyResources(this.btnGyroMStickTrig, "btnGyroMStickTrig"); + this.btnGyroMStickTrig.Name = "btnGyroMStickTrig"; + this.btnGyroMStickTrig.UseVisualStyleBackColor = true; + this.btnGyroMStickTrig.Click += new System.EventHandler(this.BtnGyroMStickTrig_Click); + // + // gyroMStickTrigBehaveCk + // + this.gyroMStickTrigBehaveCk.Checked = true; + this.gyroMStickTrigBehaveCk.CheckState = System.Windows.Forms.CheckState.Checked; + resources.ApplyResources(this.gyroMStickTrigBehaveCk, "gyroMStickTrigBehaveCk"); + this.gyroMStickTrigBehaveCk.Name = "gyroMStickTrigBehaveCk"; + this.gyroMStickTrigBehaveCk.UseVisualStyleBackColor = true; + this.gyroMStickTrigBehaveCk.CheckedChanged += new System.EventHandler(this.GyroMStickTrigBehaveCk_CheckedChanged); + // + // label29 + // + resources.ApplyResources(this.label29, "label29"); + this.label29.Name = "label29"; + // + // gyroMouseStickDZ + // + resources.ApplyResources(this.gyroMouseStickDZ, "gyroMouseStickDZ"); + this.gyroMouseStickDZ.Maximum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); + this.gyroMouseStickDZ.Name = "gyroMouseStickDZ"; + this.gyroMouseStickDZ.Value = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.gyroMouseStickDZ.ValueChanged += new System.EventHandler(this.GyroMouseStickDZ_ValueChanged); + // + // label30 + // + resources.ApplyResources(this.label30, "label30"); + this.label30.Name = "label30"; + // + // gyroMouseStickMaxZ + // + resources.ApplyResources(this.gyroMouseStickMaxZ, "gyroMouseStickMaxZ"); + this.gyroMouseStickMaxZ.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.gyroMouseStickMaxZ.Name = "gyroMouseStickMaxZ"; + this.gyroMouseStickMaxZ.Value = new decimal(new int[] { + 880, + 0, + 0, + 0}); + this.gyroMouseStickMaxZ.ValueChanged += new System.EventHandler(this.GyroMouseStickMaxZ_ValueChanged); + // + // label31 + // + resources.ApplyResources(this.label31, "label31"); + this.label31.Name = "label31"; + // + // gyroMouseStickAntiDeadX + // + this.gyroMouseStickAntiDeadX.DecimalPlaces = 2; + resources.ApplyResources(this.gyroMouseStickAntiDeadX, "gyroMouseStickAntiDeadX"); + this.gyroMouseStickAntiDeadX.Maximum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.gyroMouseStickAntiDeadX.Name = "gyroMouseStickAntiDeadX"; + this.gyroMouseStickAntiDeadX.Value = new decimal(new int[] { + 35, + 0, + 0, + 131072}); + this.gyroMouseStickAntiDeadX.ValueChanged += new System.EventHandler(this.GyroMouseStickAntiDeadX_ValueChanged); + // + // label32 + // + resources.ApplyResources(this.label32, "label32"); + this.label32.Name = "label32"; + // + // gyroMouseStickAntiDeadY + // + this.gyroMouseStickAntiDeadY.DecimalPlaces = 2; + resources.ApplyResources(this.gyroMouseStickAntiDeadY, "gyroMouseStickAntiDeadY"); + this.gyroMouseStickAntiDeadY.Maximum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.gyroMouseStickAntiDeadY.Name = "gyroMouseStickAntiDeadY"; + this.gyroMouseStickAntiDeadY.Value = new decimal(new int[] { + 35, + 0, + 0, + 131072}); + this.gyroMouseStickAntiDeadY.ValueChanged += new System.EventHandler(this.GyroMouseSStickAntiDeadY_ValueChanged); + // + // label35 + // + resources.ApplyResources(this.label35, "label35"); + this.label35.Name = "label35"; + // + // gyroMouseStickEvalCombo + // + this.gyroMouseStickEvalCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.gyroMouseStickEvalCombo.FormattingEnabled = true; + this.gyroMouseStickEvalCombo.Items.AddRange(new object[] { + resources.GetString("gyroMouseStickEvalCombo.Items"), + resources.GetString("gyroMouseStickEvalCombo.Items1")}); + resources.ApplyResources(this.gyroMouseStickEvalCombo, "gyroMouseStickEvalCombo"); + this.gyroMouseStickEvalCombo.Name = "gyroMouseStickEvalCombo"; + this.gyroMouseStickEvalCombo.SelectedIndexChanged += new System.EventHandler(this.GyroMouseStickEvalCombo_SelectedIndexChanged); + // + // label33 + // + resources.ApplyResources(this.label33, "label33"); + this.label33.Name = "label33"; + // + // gyroMousestickXAxisCom + // + this.gyroMousestickXAxisCom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.gyroMousestickXAxisCom.FormattingEnabled = true; + this.gyroMousestickXAxisCom.Items.AddRange(new object[] { + resources.GetString("gyroMousestickXAxisCom.Items"), + resources.GetString("gyroMousestickXAxisCom.Items1")}); + resources.ApplyResources(this.gyroMousestickXAxisCom, "gyroMousestickXAxisCom"); + this.gyroMousestickXAxisCom.Name = "gyroMousestickXAxisCom"; + // + // gyroMouseStickInvertXCk + // + resources.ApplyResources(this.gyroMouseStickInvertXCk, "gyroMouseStickInvertXCk"); + this.gyroMouseStickInvertXCk.Name = "gyroMouseStickInvertXCk"; + this.gyroMouseStickInvertXCk.UseVisualStyleBackColor = true; + this.gyroMouseStickInvertXCk.CheckedChanged += new System.EventHandler(this.GyroMouseStickInvert_CheckedChanged); + // + // gyroMouseStickInvertYCk + // + resources.ApplyResources(this.gyroMouseStickInvertYCk, "gyroMouseStickInvertYCk"); + this.gyroMouseStickInvertYCk.Name = "gyroMouseStickInvertYCk"; + this.gyroMouseStickInvertYCk.UseVisualStyleBackColor = true; + this.gyroMouseStickInvertYCk.CheckedChanged += new System.EventHandler(this.GyroMouseStickInvert_CheckedChanged); + // // tCControls // this.tCControls.Controls.Add(this.tPControls); @@ -3553,29 +3750,31 @@ // gBGyro // this.gBGyro.BackColor = System.Drawing.SystemColors.Control; - this.gBGyro.Controls.Add(this.rBSAControls); - this.gBGyro.Controls.Add(this.rBSAMouse); + this.gBGyro.Controls.Add(this.gyroMouseJoyFLP); + this.gBGyro.Controls.Add(this.label34); + this.gBGyro.Controls.Add(this.gyroOutputMode); this.gBGyro.Controls.Add(this.fLPTiltControls); this.gBGyro.Controls.Add(this.pnlSAMouse); resources.ApplyResources(this.gBGyro, "gBGyro"); this.gBGyro.Name = "gBGyro"; this.gBGyro.TabStop = false; // - // rBSAControls + // label34 // - resources.ApplyResources(this.rBSAControls, "rBSAControls"); - this.rBSAControls.Name = "rBSAControls"; - this.rBSAControls.TabStop = true; - this.rBSAControls.UseVisualStyleBackColor = true; - this.rBSAControls.CheckedChanged += new System.EventHandler(this.useSAforMouse_CheckedChanged); + resources.ApplyResources(this.label34, "label34"); + this.label34.Name = "label34"; // - // rBSAMouse + // gyroOutputMode // - resources.ApplyResources(this.rBSAMouse, "rBSAMouse"); - this.rBSAMouse.Name = "rBSAMouse"; - this.rBSAMouse.TabStop = true; - this.rBSAMouse.UseVisualStyleBackColor = true; - this.rBSAMouse.CheckedChanged += new System.EventHandler(this.useSAforMouse_CheckedChanged); + this.gyroOutputMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.gyroOutputMode.FormattingEnabled = true; + this.gyroOutputMode.Items.AddRange(new object[] { + resources.GetString("gyroOutputMode.Items"), + resources.GetString("gyroOutputMode.Items1"), + resources.GetString("gyroOutputMode.Items2")}); + resources.ApplyResources(this.gyroOutputMode, "gyroOutputMode"); + this.gyroOutputMode.Name = "gyroOutputMode"; + this.gyroOutputMode.SelectedIndexChanged += new System.EventHandler(this.GyroOutputMode_SelectedIndexChanged); // // pnlSAMouse // @@ -4412,6 +4611,12 @@ this.pnlRSTrack.ResumeLayout(false); this.fLPTiltControls.ResumeLayout(false); this.fLPTiltControls.PerformLayout(); + this.gyroMouseJoyFLP.ResumeLayout(false); + this.gyroMouseJoyFLP.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickDZ)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickMaxZ)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadY)).EndInit(); this.tCControls.ResumeLayout(false); this.tPControls.ResumeLayout(false); this.pnlController.ResumeLayout(false); @@ -4641,8 +4846,6 @@ private System.Windows.Forms.Label lbSwipeLeft; private System.Windows.Forms.Label lbSwipeRight; private System.Windows.Forms.Panel pnlTPMouse; - private System.Windows.Forms.RadioButton rBSAControls; - private System.Windows.Forms.RadioButton rBSAMouse; private System.Windows.Forms.Label lbGyroZN; private System.Windows.Forms.Label lbGyroZP; private System.Windows.Forms.Label lbGyroXP; @@ -4854,5 +5057,25 @@ private System.Windows.Forms.NumericUpDown RoundnessNUpDown; private System.Windows.Forms.LinkLabel lbCurveEditorURL; private System.Windows.Forms.TextBox tBCustomOutputCurve; + private System.Windows.Forms.FlowLayoutPanel gyroMouseJoyFLP; + private System.Windows.Forms.ComboBox gyroOutputMode; + private System.Windows.Forms.Label label29; + private System.Windows.Forms.NumericUpDown gyroMouseStickDZ; + private System.Windows.Forms.Label label30; + private System.Windows.Forms.NumericUpDown gyroMouseStickMaxZ; + private System.Windows.Forms.Label label31; + private System.Windows.Forms.NumericUpDown gyroMouseStickAntiDeadX; + private System.Windows.Forms.Label label32; + private System.Windows.Forms.NumericUpDown gyroMouseStickAntiDeadY; + private System.Windows.Forms.Label label33; + private System.Windows.Forms.ComboBox gyroMousestickXAxisCom; + private System.Windows.Forms.CheckBox gyroMouseStickInvertXCk; + private System.Windows.Forms.CheckBox gyroMouseStickInvertYCk; + private System.Windows.Forms.Label label34; + private System.Windows.Forms.Label label36; + private System.Windows.Forms.Button btnGyroMStickTrig; + private System.Windows.Forms.CheckBox gyroMStickTrigBehaveCk; + private System.Windows.Forms.Label label35; + private System.Windows.Forms.ComboBox gyroMouseStickEvalCombo; } } \ No newline at end of file diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index e4b1fa1..ae2a757 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -56,10 +56,10 @@ namespace DS4Windows.Forms root = rt; btnRumbleHeavyTest.Text = Properties.Resources.TestHText; btnRumbleLightTest.Text = Properties.Resources.TestLText; - rBTPControls.Text = rBSAControls.Text; - rBTPMouse.Text = rBSAMouse.Text; - rBTPControls.Location = rBSAControls.Location; - rBTPMouse.Location = rBSAMouse.Location; + //rBTPControls.Text = rBSAControls.Text; + //rBTPMouse.Text = rBSAMouse.Text; + //rBTPControls.Location = rBSAControls.Location; + //rBTPMouse.Location = rBSAMouse.Location; Visible = false; colored = btnRainbow.Image; greyscale = GreyscaleImage((Bitmap)btnRainbow.Image); @@ -702,8 +702,29 @@ namespace DS4Windows.Forms cbStartTouchpadOff.Checked = StartTouchpadOff[device]; rBTPControls.Checked = UseTPforControls[device]; rBTPMouse.Checked = !UseTPforControls[device]; - rBSAMouse.Checked = UseSAforMouse[device]; - rBSAControls.Checked = !UseSAforMouse[device]; + GyroOutMode gyroOut = GyroOutputMode[device]; + if (gyroOut == GyroOutMode.Mouse) + { + pnlSAMouse.Visible = true; + fLPTiltControls.Visible = false; + gyroMouseJoyFLP.Visible = false; + gyroOutputMode.SelectedIndex = 1; + } + else if (gyroOut == GyroOutMode.Controls) + { + pnlSAMouse.Visible = false; + fLPTiltControls.Visible = true; + gyroMouseJoyFLP.Visible = false; + gyroOutputMode.SelectedIndex = 0; + } + else if (gyroOut == GyroOutMode.MouseJoystick) + { + pnlSAMouse.Visible = false; + fLPTiltControls.Visible = false; + gyroMouseJoyFLP.Visible = true; + gyroOutputMode.SelectedIndex = 2; + } + nUDLSCurve.Value = LSCurve[device]; nUDRSCurve.Value = RSCurve[device]; cBControllerInput.Checked = DS4Mapping; @@ -714,47 +735,23 @@ namespace DS4Windows.Forms Program.rootHub.touchPad[device]?.ResetTrackAccel(TrackballFriction[device]); } - for (int i = 0, arlen = cMGyroTriggers.Items.Count; i < arlen; i++) - { - ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; - } + ResetGyroTriggers(); for (int i = 0, arlen = cMTouchDisableInvert.Items.Count; i < arlen; i++) { ((ToolStripMenuItem)cMTouchDisableInvert.Items[i]).Checked = false; } - string[] satriggers = SATriggers[device].Split(','); + string[] satriggers; + satriggers = SATriggers[device].Split(','); + btnGyroTriggers.Text = GetGyroTriggerActionString(ref satriggers); + if (gyroOut == GyroOutMode.Mouse) MarkCurrentGyroTriggers(ref satriggers); + + satriggers = SAMousestickTriggers[device].Split(','); + btnGyroMStickTrig.Text = GetGyroTriggerActionString(ref satriggers); + if (gyroOut == GyroOutMode.MouseJoystick) MarkCurrentGyroTriggers(ref satriggers); + List s = new List(); - int gyroTriggerCount = cMGyroTriggers.Items.Count; - for (int i = 0, satrigLen = satriggers.Length; i < satrigLen; i++) - { - int tr = 0; - if (int.TryParse(satriggers[i], out tr)) - { - if (tr < gyroTriggerCount && tr > -1) - { - ((ToolStripMenuItem)cMGyroTriggers.Items[tr]).Checked = true; - s.Add(cMGyroTriggers.Items[tr].Text); - } - else - { - ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; - s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); - break; - } - } - else - { - ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; - s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); - break; - } - } - - btnGyroTriggers.Text = string.Join(", ", s); - s.Clear(); - int[] touchDisInvTriggers = TouchDisInvertTriggers[device]; int touchDisableInvCount = cMTouchDisableInvert.Items.Count; for (int i = 0, trigLen = touchDisInvTriggers.Length; i < trigLen; i++) @@ -806,6 +803,32 @@ namespace DS4Windows.Forms defaults = xboxDefaults; break; } + + switch (GyroOutputMode[device]) + { + case GyroOutMode.Controls: + gyroOutputMode.SelectedIndex = 0; + break; + case GyroOutMode.Mouse: + gyroOutputMode.SelectedIndex = 1; + break; + case GyroOutMode.MouseJoystick: + gyroOutputMode.SelectedIndex = 2; + break; + default: + break; + } + + gyroMStickTrigBehaveCk.Checked = GyroMouseStickTriggerTurns[device]; + gyroMouseStickEvalCombo.SelectedIndex = SAMouseStickTriggerCond[device] ? 0 : 1; + GyroMouseStickInfo gyroMouseStickInfo = GyroMouseStickInf[device]; + gyroMouseStickDZ.Value = gyroMouseStickInfo.deadZone; + gyroMouseStickMaxZ.Value = gyroMouseStickInfo.maxZone; + gyroMouseStickAntiDeadX.Value = (decimal)gyroMouseStickInfo.antiDeadX; + gyroMouseStickAntiDeadY.Value = (decimal)gyroMouseStickInfo.antiDeadY; + gyroMousestickXAxisCom.SelectedIndex = GyroMouseStickHorizontalAxis[device]; + gyroMouseStickInvertXCk.Checked = (gyroMouseStickInfo.inverted & 1) == 1; + gyroMouseStickInvertYCk.Checked = (gyroMouseStickInfo.inverted & 2) == 2; } else { @@ -824,11 +847,11 @@ namespace DS4Windows.Forms tBCustomOutputCurve.Enabled = lbCurveEditorURL.Enabled = false; rBTPMouse.Checked = true; - rBSAControls.Checked = true; + //rBSAControls.Checked = true; ToggleRainbow(false); cBDinput.Checked = false; cbStartTouchpadOff.Checked = false; - rBSAControls.Checked = true; + //rBSAControls.Checked = true; rBTPMouse.Checked = true; switch (device) @@ -912,10 +935,7 @@ namespace DS4Windows.Forms Program.rootHub.touchPad[device]?.ResetTrackAccel(10.0); } - for (int i = 0, arlen = cMGyroTriggers.Items.Count - 1; i < arlen; i++) - { - ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; - } + ResetGyroTriggers(); ((ToolStripMenuItem)cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1]).Checked = true; for (int i = 0, arlen = cMTouchDisableInvert.Items.Count; i < arlen; i++) @@ -937,6 +957,18 @@ namespace DS4Windows.Forms cBSteeringWheelEmulationAxis.SelectedIndex = 0; cBSteeringWheelEmulationRange.SelectedIndex = cBSteeringWheelEmulationRange.Items.IndexOf("360"); OutContTypeCb.SelectedIndex = 0; + + gyroOutputMode.SelectedIndex = 0; + gyroMStickTrigBehaveCk.Checked = false; + gyroMouseStickEvalCombo.SelectedIndex = 0; + gyroMouseStickDZ.Value = 50; + gyroMouseStickMaxZ.Value = 880; + gyroMouseStickAntiDeadX.Value = 0.35m; + gyroMouseStickAntiDeadY.Value = 0.35m; + gyroMousestickXAxisCom.SelectedIndex = 0; + gyroMouseStickInvertXCk.Checked = false; + gyroMouseStickInvertYCk.Checked = false; + Set(); } @@ -1017,6 +1049,80 @@ namespace DS4Windows.Forms btnSATrackS.Visible = on; } + private void ResetGyroTriggers() + { + loading = true; + for (int i = 0, arlen = cMGyroTriggers.Items.Count; i < arlen; i++) + { + ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; + } + + loading = false; + } + + private string GetGyroTriggerActionString(ref string[] satriggers) + { + List s = new List(); + int gyroTriggerCount = cMGyroTriggers.Items.Count; + for (int i = 0, satrigLen = satriggers.Length; i < satrigLen; i++) + { + int tr = 0; + if (int.TryParse(satriggers[i], out tr)) + { + if (tr < gyroTriggerCount && tr > -1) + { + ((ToolStripMenuItem)cMGyroTriggers.Items[tr]).Checked = true; + s.Add(cMGyroTriggers.Items[tr].Text); + } + else + { + ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; + s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); + break; + } + } + else + { + ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; + s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); + break; + } + } + + string result = string.Join(", ", s); + return result; + } + + private void MarkCurrentGyroTriggers(ref string[] satriggers) + { + loading = true; + int gyroTriggerCount = cMGyroTriggers.Items.Count; + ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = false; + for (int i = 0, satrigLen = satriggers.Length; i < satrigLen; i++) + { + int tr = 0; + if (int.TryParse(satriggers[i], out tr)) + { + if (tr < gyroTriggerCount && tr > -1) + { + ((ToolStripMenuItem)cMGyroTriggers.Items[tr]).Checked = true; + } + else + { + ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; + break; + } + } + else + { + ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; + break; + } + } + + loading = false; + } + private void ControllerReadout_Tick(object sender, EventArgs e) { // MEMS gyro data is all calibrated to roughly -1G..1G for values -0x2000..0x1fff @@ -1348,7 +1454,7 @@ namespace DS4Windows.Forms DinputOnly[device] = cBDinput.Checked; StartTouchpadOff[device] = cbStartTouchpadOff.Checked; UseTPforControls[device] = rBTPControls.Checked; - UseSAforMouse[device] = rBSAMouse.Checked; + //UseSAforMouse[device] = rBSAMouse.Checked; DS4Mapping = cBControllerInput.Checked; LSCurve[device] = (int)Math.Round(nUDLSCurve.Value, 0); RSCurve[device] = (int)Math.Round(nUDRSCurve.Value, 0); @@ -1364,8 +1470,9 @@ namespace DS4Windows.Forms calculateProfileActionDicts(device); cacheProfileCustomsFlags(device); pnlTPMouse.Visible = rBTPMouse.Checked; - pnlSAMouse.Visible = rBSAMouse.Checked; - fLPTiltControls.Visible = rBSAControls.Checked; + pnlSAMouse.Visible = false; + fLPTiltControls.Visible = false; + gyroMouseJoyFLP.Visible = false; fLPTouchSwipe.Visible = rBTPControls.Checked; TrackballMode[device] = trackballCk.Checked; TrackballFriction[device] = (double)trackFrictionNUD.Value; @@ -1393,7 +1500,7 @@ namespace DS4Windows.Forms GyroInvert[device] = invert; List ints = new List(); - for (int i = 0, trigLen = cMGyroTriggers.Items.Count - 1; i < trigLen; i++) + /*for (int i = 0, trigLen = cMGyroTriggers.Items.Count - 1; i < trigLen; i++) { if (((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked) ints.Add(i); @@ -1404,6 +1511,7 @@ namespace DS4Windows.Forms SATriggers[device] = string.Join(",", ints); SetSaTriggerCond(device, triggerCondAndCombo.SelectedItem.ToString().ToLower()); + */ ints.Clear(); for (int i = 0, trigLen = cMTouchDisableInvert.Items.Count; i < trigLen; i++) @@ -1433,6 +1541,43 @@ namespace DS4Windows.Forms { Global.OutContType[device] = tempType; } + + switch (gyroOutputMode.SelectedIndex) + { + case 0: + GyroOutputMode[device] = GyroOutMode.Controls; + break; + case 1: + GyroOutputMode[device] = GyroOutMode.Mouse; + break; + case 2: + GyroOutputMode[device] = GyroOutMode.MouseJoystick; + break; + default: + break; + } + + GyroMouseStickTriggerTurns[device] = gyroMStickTrigBehaveCk.Checked; + SetSaMouseStickTriggerCond(device, + gyroMouseStickEvalCombo.SelectedItem.ToString().ToLower()); + + if (GyroMouseStickDead()) + { + GyroMouseStickInf[device].deadZone = (int)gyroMouseStickDZ.Value; + GyroMouseStickInf[device].maxZone = (int)gyroMouseStickMaxZ.Value; + } + else + { + GyroMouseStickInf[device].deadZone = (int)gyroMouseStickMaxZ.Value; + GyroMouseStickInf[device].maxZone = (int)gyroMouseStickMaxZ.Value; + } + + GyroMouseStickInf[device].antiDeadX = (double)gyroMouseStickAntiDeadX.Value; + GyroMouseStickInf[device].antiDeadY = (double)gyroMouseStickAntiDeadY.Value; + GyroMouseStickHorizontalAxis[device] = gyroMousestickXAxisCom.SelectedIndex; + uint tempInvert = 0; + if (gyroMouseStickInvertXCk.Checked) tempInvert |= 1 << 0; + if (gyroMouseStickInvertYCk.Checked) tempInvert |= 1 << 1; } private void Show_ControlsBtn(object sender, EventArgs e) @@ -2678,12 +2823,13 @@ namespace DS4Windows.Forms DS4LightBar.forcelight[device] = false; } - private void useSAforMouse_CheckedChanged(object sender, EventArgs e) + /*private void useSAforMouse_CheckedChanged(object sender, EventArgs e) { UseSAforMouse[device] = rBSAMouse.Checked; pnlSAMouse.Visible = rBSAMouse.Checked; fLPTiltControls.Visible = rBSAControls.Checked; } + */ private void btnGyroTriggers_Click(object sender, EventArgs e) { @@ -2722,9 +2868,19 @@ namespace DS4Windows.Forms s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); } - SATriggers[device] = string.Join(",", ints); - if (s.Count > 0) - btnGyroTriggers.Text = string.Join(", ", s); + int gyroOutIdx = gyroOutputMode.SelectedIndex; + if (gyroOutIdx == 1) + { + SATriggers[device] = string.Join(",", ints); + if (s.Count > 0) + btnGyroTriggers.Text = string.Join(", ", s); + } + else if (gyroOutIdx == 2) + { + SAMousestickTriggers[device] = string.Join(",", ints); + if (s.Count > 0) + btnGyroMStickTrig.Text = string.Join(", ", s); + } } } @@ -3400,6 +3556,128 @@ namespace DS4Windows.Forms } } + private void GyroOutputMode_SelectedIndexChanged(object sender, EventArgs e) + { + if (loading == false) + { + int choice = gyroOutputMode.SelectedIndex; + if (choice == 0) + { + fLPTiltControls.Visible = true; + pnlSAMouse.Visible = false; + gyroMouseJoyFLP.Visible = false; + } + else if (choice == 1) + { + fLPTiltControls.Visible = false; + pnlSAMouse.Visible = true; + gyroMouseJoyFLP.Visible = false; + ResetGyroTriggers(); + string[] satriggers = SATriggers[device].Split(','); + MarkCurrentGyroTriggers(ref satriggers); + } + else if (choice == 2) + { + fLPTiltControls.Visible = false; + pnlSAMouse.Visible = false; + gyroMouseJoyFLP.Visible = true; + ResetGyroTriggers(); + string[] satriggers = SAMousestickTriggers[device].Split(','); + MarkCurrentGyroTriggers(ref satriggers); + } + + switch(choice) + { + case 0: + GyroOutputMode[device] = GyroOutMode.Controls; + break; + case 1: + GyroOutputMode[device] = GyroOutMode.Mouse; + break; + case 2: + GyroOutputMode[device] = GyroOutMode.MouseJoystick; + break; + default: + break; + } + + if (device < 4) + Program.rootHub.touchPad[device]?.ResetToggleGyroM(); + } + } + + private void BtnGyroMStickTrig_Click(object sender, EventArgs e) + { + Control button = (Control)sender; + cMGyroTriggers.Show(button, new Point(0, button.Height)); + } + + private void GyroMStickTrigBehaveCk_CheckedChanged(object sender, EventArgs e) + { + if (!loading) + { + GyroMouseStickTriggerTurns[device] = gyroMStickTrigBehaveCk.Checked; + if (device < 4) + Program.rootHub.touchPad[device]?.ResetToggleGyroM(); + } + } + + private void GyroMouseStickEvalCombo_SelectedIndexChanged(object sender, EventArgs e) + { + if (loading == false) + { + string temp = gyroMouseStickEvalCombo.SelectedItem.ToString(); + SetSaMouseStickTriggerCond(device, temp); + } + } + + private void GyroMouseStickDZ_ValueChanged(object sender, EventArgs e) + { + if (loading == false && GyroMouseStickDead()) + { + GyroMouseStickInf[device].deadZone = (int)gyroMouseStickDZ.Value; + } + } + + private void GyroMouseStickMaxZ_ValueChanged(object sender, EventArgs e) + { + if (loading == false && GyroMouseStickDead()) + { + GyroMouseStickInf[device].maxZone = (int)gyroMouseStickMaxZ.Value; + } + } + + private bool GyroMouseStickDead() + { + return gyroMouseStickDZ.Value <= gyroMouseStickMaxZ.Value; + } + + private void GyroMouseStickAntiDeadX_ValueChanged(object sender, EventArgs e) + { + if (loading == false) + { + GyroMouseStickInf[device].antiDeadX = (double)gyroMouseStickAntiDeadX.Value; + } + } + + private void GyroMouseSStickAntiDeadY_ValueChanged(object sender, EventArgs e) + { + if (loading == false) + { + GyroMouseStickInf[device].antiDeadY = (double)gyroMouseStickAntiDeadY.Value; + } + } + + private void GyroMouseStickInvert_CheckedChanged(object sender, EventArgs e) + { + if (loading == false) + { + uint value = 0; + if (gyroMouseStickInvertXCk.Checked) value |= 1 << 0; + if (gyroMouseStickInvertYCk.Checked) value |= 1 << 1; + } + } + private void trackFrictionNUD_ValueChanged(object sender, EventArgs e) { if (loading == false) diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index 777cacd..805e285 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -4327,10 +4327,10 @@ 12 - 4, 43 + 6, 47 - 271, 203 + 271, 195 254 @@ -4345,8 +4345,485 @@ gBGyro + 3 + + + True + + + NoControl + + + 3, 0 + + + 48, 13 + + + 275 + + + Triggers: + + + TopRight + + + label36 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 0 + + + NoControl + + + 56, 2 + + + 2, 2, 2, 2 + + + 160, 25 + + + 274 + + + None + + + btnGyroMStickTrig + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 1 + + + NoControl + + + 3, 32 + + + No + + + 188, 17 + + + 276 + + + Trigger Behavior - Turns Gyro + + + gyroMStickTrigBehaveCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + 2 + + True + + + 3, 52 + + + 64, 13 + + + 0 + + + Dead Zone: + + + label29 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 3 + + + 73, 55 + + + 41, 20 + + + 1 + + + gyroMouseStickDZ + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 4 + + + True + + + 120, 52 + + + 58, 13 + + + 2 + + + Max Zone: + + + label30 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 5 + + + 184, 55 + + + 48, 20 + + + 3 + + + gyroMouseStickMaxZ + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 6 + + + True + + + 3, 78 + + + 61, 13 + + + 4 + + + Minimum X: + + + label31 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 7 + + + 70, 81 + + + 50, 20 + + + 5 + + + gyroMouseStickAntiDeadX + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 8 + + + True + + + 126, 78 + + + 61, 13 + + + 6 + + + Minimum Y: + + + label32 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 9 + + + 193, 81 + + + 49, 20 + + + 7 + + + gyroMouseStickAntiDeadY + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 10 + + + True + + + NoControl + + + 3, 104 + + + 59, 13 + + + 278 + + + Eval Cond: + + + label35 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 11 + + + And + + + Or + + + 68, 107 + + + 72, 21 + + + 277 + + + gyroMouseStickEvalCombo + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 12 + + + True + + + 146, 104 + + + 39, 13 + + + 8 + + + X Axis: + + + label33 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 13 + + + Yaw + + + Roll + + + 191, 107 + + + 56, 21 + + + 9 + + + gyroMousestickXAxisCom + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 14 + + + True + + + 3, 134 + + + Yes + + + 63, 17 + + + 11 + + + Invert X + + + gyroMouseStickInvertXCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 15 + + + True + + + 72, 134 + + + Yes + + + 63, 17 + + + 12 + + + Invert Y + + + gyroMouseStickInvertYCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 16 + + + 8, 47 + + + 252, 181 + + + 260 + + + gyroMouseJoyFLP + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gBGyro + + + 0 + True @@ -8169,72 +8646,63 @@ True - + True - - NoControl + + 25, 17 - - 144, 20 + + 72, 13 - - 2, 2, 2, 2 + + 261 - - 100, 17 + + Output Mode: - - 258 + + label34 - - Use for Controls + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - rBSAControls - - - System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + gBGyro - - 0 - - - True - - - NoControl - - - 13, 20 - - - 2, 2, 2, 2 - - - 93, 17 - - - 257 - - - Use as Mouse - - - rBSAMouse - - - System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gBGyro - - + 1 + + Controls + + + Mouse + + + Mouse Joystick + + + 122, 15 + + + 121, 21 + + + 260 + + + gyroOutputMode + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gBGyro + + + 2 + True @@ -8872,13 +9340,13 @@ 21 - 6, 39 + 4, 47 2, 2, 2, 2 - 263, 207 + 263, 222 259 @@ -8893,13 +9361,13 @@ gBGyro - 3 + 4 3, 242 - 272, 257 + 272, 256 248 @@ -9556,7 +10024,7 @@ True - 47 + 114 96, 96 From a949f803a4971356af21417c41bb4f3a409de74c Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 23 Aug 2019 01:27:47 -0500 Subject: [PATCH 2/7] Lower default Mouse Joystick dead zone --- DS4Windows/DS4Control/ScpUtil.cs | 2 +- DS4Windows/DS4Forms/Options.Designer.cs | 2 +- DS4Windows/DS4Forms/Options.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 68e2ba3..6b613e9 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -4551,7 +4551,7 @@ namespace DS4Windows gyroOutMode[device] = GyroOutMode.Controls; sAMouseStickTriggers[device] = string.Empty; sAMouseStickTriggerCond[device] = false; - gyroMStickInfo[device].deadZone = 50; gyroMStickInfo[device].maxZone = 880; + gyroMStickInfo[device].deadZone = 40; gyroMStickInfo[device].maxZone = 880; gyroMStickInfo[device].antiDeadX = 0.35; gyroMStickInfo[device].antiDeadY = 0.35; gyroMStickInfo[device].inverted = 0; sASteeringWheelEmulationAxis[device] = SASteeringWheelEmulationAxisType.None; diff --git a/DS4Windows/DS4Forms/Options.Designer.cs b/DS4Windows/DS4Forms/Options.Designer.cs index 790209d..d0b5fb7 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -2089,7 +2089,7 @@ 0}); this.gyroMouseStickDZ.Name = "gyroMouseStickDZ"; this.gyroMouseStickDZ.Value = new decimal(new int[] { - 50, + 40, 0, 0, 0}); diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index ae2a757..84236f1 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -961,7 +961,7 @@ namespace DS4Windows.Forms gyroOutputMode.SelectedIndex = 0; gyroMStickTrigBehaveCk.Checked = false; gyroMouseStickEvalCombo.SelectedIndex = 0; - gyroMouseStickDZ.Value = 50; + gyroMouseStickDZ.Value = 40; gyroMouseStickMaxZ.Value = 880; gyroMouseStickAntiDeadX.Value = 0.35m; gyroMouseStickAntiDeadY.Value = 0.35m; From 5bc8346fe663de0d6d4c861d95847cd4744cb06f Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 23 Aug 2019 17:03:22 -0500 Subject: [PATCH 3/7] Fixed turn behavior setting for Mouse Joystick --- DS4Windows/DS4Control/ScpUtil.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 6b613e9..52aa0cf 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -2259,7 +2259,7 @@ namespace DS4Windows XmlNode xmlGyroOutMode = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroOutputMode", null); xmlGyroOutMode.InnerText = GetGyroOutModeString(gyroOutMode[device]); Node.AppendChild(xmlGyroOutMode); XmlNode xmlGyroMStickTriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickTriggers", null); xmlGyroMStickTriggers.InnerText = sAMouseStickTriggers[device].ToString(); Node.AppendChild(xmlGyroMStickTriggers); XmlNode xmlGyroMStickTriggerCond = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickTriggerCond", null); xmlGyroMStickTriggerCond.InnerText = SaTriggerCondString(sAMouseStickTriggerCond[device]); Node.AppendChild(xmlGyroMStickTriggerCond); - XmlNode xmlGyroMStickTriggerTurns = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMousestickTriggerTurns", null); xmlGyroMStickTriggerTurns.InnerText = gyroMouseStickTriggerTurns[device].ToString(); Node.AppendChild(xmlGyroMStickTriggerTurns); + XmlNode xmlGyroMStickTriggerTurns = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickTriggerTurns", null); xmlGyroMStickTriggerTurns.InnerText = gyroMouseStickTriggerTurns[device].ToString(); Node.AppendChild(xmlGyroMStickTriggerTurns); XmlNode xmlGyroMStickHAxis = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickHAxis", null); xmlGyroMStickHAxis.InnerText = gyroMouseStickHorizontalAxis[device].ToString(); Node.AppendChild(xmlGyroMStickHAxis); XmlNode xmlGyroMStickDZ = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickDeadZone", null); xmlGyroMStickDZ.InnerText = gyroMStickInfo[device].deadZone.ToString(); Node.AppendChild(xmlGyroMStickDZ); XmlNode xmlGyroMStickMaxZ = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickMaxZone", null); xmlGyroMStickMaxZ.InnerText = gyroMStickInfo[device].maxZone.ToString(); Node.AppendChild(xmlGyroMStickMaxZ); @@ -3137,7 +3137,7 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickTriggerCond"); sAMouseStickTriggerCond[device] = SaTriggerCondValue(Item.InnerText); } catch { sAMouseStickTriggerCond[device] = true; missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMousestickTriggerTurns"); bool.TryParse(Item.InnerText, out gyroTriggerTurns[device]); } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickTriggerTurns"); bool.TryParse(Item.InnerText, out gyroMouseStickTriggerTurns[device]); } catch { gyroMouseStickTriggerTurns[device] = true; missingSetting = true; } @@ -4550,7 +4550,7 @@ namespace DS4Windows sATriggerCond[device] = true; gyroOutMode[device] = GyroOutMode.Controls; sAMouseStickTriggers[device] = string.Empty; - sAMouseStickTriggerCond[device] = false; + sAMouseStickTriggerCond[device] = true; gyroMStickInfo[device].deadZone = 40; gyroMStickInfo[device].maxZone = 880; gyroMStickInfo[device].antiDeadX = 0.35; gyroMStickInfo[device].antiDeadY = 0.35; gyroMStickInfo[device].inverted = 0; From 78cf371dceeb22951a41e743d38109f862b221e6 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 23 Aug 2019 21:39:22 -0500 Subject: [PATCH 4/7] Fixed issue with gyro triggers getting reset --- DS4Windows/DS4Control/ScpUtil.cs | 3 ++- DS4Windows/DS4Forms/Options.cs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 52aa0cf..5f02f85 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -3552,7 +3552,8 @@ namespace DS4Windows containsCustomAction[device] = HasCustomActions(device); containsCustomExtras[device] = HasCustomExtras(device); - Program.rootHub.touchPad[device]?.ResetToggleGyroM(); + if (device < 4) + Program.rootHub.touchPad[device]?.ResetToggleGyroM(); // If a device exists, make sure to transfer relevant profile device // options to device instance diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 84236f1..41c50ff 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -735,7 +735,7 @@ namespace DS4Windows.Forms Program.rootHub.touchPad[device]?.ResetTrackAccel(TrackballFriction[device]); } - ResetGyroTriggers(); + ResetGyroTriggers(true); for (int i = 0, arlen = cMTouchDisableInvert.Items.Count; i < arlen; i++) { @@ -745,11 +745,11 @@ namespace DS4Windows.Forms string[] satriggers; satriggers = SATriggers[device].Split(','); btnGyroTriggers.Text = GetGyroTriggerActionString(ref satriggers); - if (gyroOut == GyroOutMode.Mouse) MarkCurrentGyroTriggers(ref satriggers); + if (gyroOut == GyroOutMode.Mouse) MarkCurrentGyroTriggers(ref satriggers, true); satriggers = SAMousestickTriggers[device].Split(','); btnGyroMStickTrig.Text = GetGyroTriggerActionString(ref satriggers); - if (gyroOut == GyroOutMode.MouseJoystick) MarkCurrentGyroTriggers(ref satriggers); + if (gyroOut == GyroOutMode.MouseJoystick) MarkCurrentGyroTriggers(ref satriggers, true); List s = new List(); int[] touchDisInvTriggers = TouchDisInvertTriggers[device]; @@ -935,7 +935,7 @@ namespace DS4Windows.Forms Program.rootHub.touchPad[device]?.ResetTrackAccel(10.0); } - ResetGyroTriggers(); + ResetGyroTriggers(true); ((ToolStripMenuItem)cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1]).Checked = true; for (int i = 0, arlen = cMTouchDisableInvert.Items.Count; i < arlen; i++) @@ -1049,7 +1049,7 @@ namespace DS4Windows.Forms btnSATrackS.Visible = on; } - private void ResetGyroTriggers() + private void ResetGyroTriggers(bool loadstate = false) { loading = true; for (int i = 0, arlen = cMGyroTriggers.Items.Count; i < arlen; i++) @@ -1057,7 +1057,7 @@ namespace DS4Windows.Forms ((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked = false; } - loading = false; + loading = loadstate; } private string GetGyroTriggerActionString(ref string[] satriggers) @@ -1093,7 +1093,7 @@ namespace DS4Windows.Forms return result; } - private void MarkCurrentGyroTriggers(ref string[] satriggers) + private void MarkCurrentGyroTriggers(ref string[] satriggers, bool loadstate = false) { loading = true; int gyroTriggerCount = cMGyroTriggers.Items.Count; @@ -1120,7 +1120,7 @@ namespace DS4Windows.Forms } } - loading = false; + loading = loadstate; } private void ControllerReadout_Tick(object sender, EventArgs e) From bc437a27696930b2f37530d512c0243df6dd7c86 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Fri, 23 Aug 2019 22:08:15 -0500 Subject: [PATCH 5/7] Adjusted defaulyts. Fixed trigger turn default --- DS4Windows/DS4Control/ScpUtil.cs | 12 ++++++------ DS4Windows/DS4Forms/Options.cs | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 5f02f85..406724a 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -3146,28 +3146,28 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickDeadZone"); int.TryParse(Item.InnerText, out int temp); gyroMStickInfo[device].deadZone = temp; } - catch { gyroMStickInfo[device].deadZone = 50; missingSetting = true; } + catch { gyroMStickInfo[device].deadZone = 30; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickMaxZone"); int.TryParse(Item.InnerText, out int temp); gyroMStickInfo[device].maxZone = temp; } - catch { gyroMStickInfo[device].maxZone = 880; missingSetting = true; } + catch { gyroMStickInfo[device].maxZone = 840; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickAntiDeadX"); double.TryParse(Item.InnerText, out double temp); gyroMStickInfo[device].antiDeadX = temp; } - catch { gyroMStickInfo[device].antiDeadX = 0.35; missingSetting = true; } + catch { gyroMStickInfo[device].antiDeadX = 0.4; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickAntiDeadY"); double.TryParse(Item.InnerText, out double temp); gyroMStickInfo[device].antiDeadY = temp; } - catch { gyroMStickInfo[device].antiDeadY = 0.35; missingSetting = true; } + catch { gyroMStickInfo[device].antiDeadY = 0.4; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickInvert"); uint.TryParse(Item.InnerText, out gyroMStickInfo[device].inverted); } catch { gyroMStickInfo[device].inverted = 0; missingSetting = true; } @@ -4552,8 +4552,8 @@ namespace DS4Windows gyroOutMode[device] = GyroOutMode.Controls; sAMouseStickTriggers[device] = string.Empty; sAMouseStickTriggerCond[device] = true; - gyroMStickInfo[device].deadZone = 40; gyroMStickInfo[device].maxZone = 880; - gyroMStickInfo[device].antiDeadX = 0.35; gyroMStickInfo[device].antiDeadY = 0.35; + gyroMStickInfo[device].deadZone = 30; gyroMStickInfo[device].maxZone = 840; + gyroMStickInfo[device].antiDeadX = 0.4; gyroMStickInfo[device].antiDeadY = 0.4; gyroMStickInfo[device].inverted = 0; sASteeringWheelEmulationAxis[device] = SASteeringWheelEmulationAxisType.None; sASteeringWheelEmulationRange[device] = 360; diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 41c50ff..43eea1a 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -959,12 +959,12 @@ namespace DS4Windows.Forms OutContTypeCb.SelectedIndex = 0; gyroOutputMode.SelectedIndex = 0; - gyroMStickTrigBehaveCk.Checked = false; + gyroMStickTrigBehaveCk.Checked = true; gyroMouseStickEvalCombo.SelectedIndex = 0; - gyroMouseStickDZ.Value = 40; - gyroMouseStickMaxZ.Value = 880; - gyroMouseStickAntiDeadX.Value = 0.35m; - gyroMouseStickAntiDeadY.Value = 0.35m; + gyroMouseStickDZ.Value = 30; + gyroMouseStickMaxZ.Value = 840; + gyroMouseStickAntiDeadX.Value = 0.4m; + gyroMouseStickAntiDeadY.Value = 0.4m; gyroMousestickXAxisCom.SelectedIndex = 0; gyroMouseStickInvertXCk.Checked = false; gyroMouseStickInvertYCk.Checked = false; From b99e866a96d9b95b58c740ee286a3a0c791c8cf3 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 24 Aug 2019 01:13:30 -0500 Subject: [PATCH 6/7] Fixed saving invert option for Mouse Joystick --- DS4Windows/DS4Forms/Options.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 43eea1a..85b7978 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -1578,6 +1578,7 @@ namespace DS4Windows.Forms uint tempInvert = 0; if (gyroMouseStickInvertXCk.Checked) tempInvert |= 1 << 0; if (gyroMouseStickInvertYCk.Checked) tempInvert |= 1 << 1; + GyroMouseStickInf[device].inverted = tempInvert; } private void Show_ControlsBtn(object sender, EventArgs e) @@ -3675,6 +3676,7 @@ namespace DS4Windows.Forms uint value = 0; if (gyroMouseStickInvertXCk.Checked) value |= 1 << 0; if (gyroMouseStickInvertYCk.Checked) value |= 1 << 1; + GyroMouseStickInf[device].inverted = value; } } From 709738aa599cca698d6226f98837455427f1f232 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Sat, 24 Aug 2019 01:52:46 -0500 Subject: [PATCH 7/7] Fixed gyro trigger item marking --- DS4Windows/DS4Forms/Options.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 85b7978..2c688b9 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -804,21 +804,6 @@ namespace DS4Windows.Forms break; } - switch (GyroOutputMode[device]) - { - case GyroOutMode.Controls: - gyroOutputMode.SelectedIndex = 0; - break; - case GyroOutMode.Mouse: - gyroOutputMode.SelectedIndex = 1; - break; - case GyroOutMode.MouseJoystick: - gyroOutputMode.SelectedIndex = 2; - break; - default: - break; - } - gyroMStickTrigBehaveCk.Checked = GyroMouseStickTriggerTurns[device]; gyroMouseStickEvalCombo.SelectedIndex = SAMouseStickTriggerCond[device] ? 0 : 1; GyroMouseStickInfo gyroMouseStickInfo = GyroMouseStickInf[device]; @@ -1071,19 +1056,16 @@ namespace DS4Windows.Forms { if (tr < gyroTriggerCount && tr > -1) { - ((ToolStripMenuItem)cMGyroTriggers.Items[tr]).Checked = true; s.Add(cMGyroTriggers.Items[tr].Text); } else { - ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); break; } } else { - ((ToolStripMenuItem)cMGyroTriggers.Items[gyroTriggerCount - 1]).Checked = true; s.Add(cMGyroTriggers.Items[gyroTriggerCount - 1].Text); break; }