diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 730e43f..669be4a 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -617,9 +617,15 @@ namespace DS4Windows dState.RY = (byte)Math.Round(curvey, 0); } - int lsDeadzone = getLSDeadzone(device); + /*int lsDeadzone = getLSDeadzone(device); int lsAntiDead = getLSAntiDeadzone(device); int lsMaxZone = getLSMaxzone(device); + */ + StickDeadZoneInfo lsMod = GetLSDeadInfo(device); + int lsDeadzone = lsMod.deadZone; + int lsAntiDead = lsMod.antiDeadZone; + int lsMaxZone = lsMod.maxZone; + if (lsDeadzone > 0 || lsAntiDead > 0 || lsMaxZone != 100) { double lsSquared = Math.Pow(cState.LX - 128f, 2) + Math.Pow(cState.LY - 128f, 2); @@ -693,9 +699,14 @@ namespace DS4Windows } } - int rsDeadzone = getRSDeadzone(device); + /*int rsDeadzone = getRSDeadzone(device); int rsAntiDead = getRSAntiDeadzone(device); int rsMaxZone = getRSMaxzone(device); + */ + StickDeadZoneInfo rsMod = GetRSDeadInfo(device); + int rsDeadzone = rsMod.deadZone; + int rsAntiDead = rsMod.antiDeadZone; + int rsMaxZone = rsMod.maxZone; if (rsDeadzone > 0 || rsAntiDead > 0 || rsMaxZone != 100) { double rsSquared = Math.Pow(cState.RX - 128.0, 2) + Math.Pow(cState.RY - 128.0, 2); diff --git a/DS4Windows/DS4Control/ProfilePropGroups.cs b/DS4Windows/DS4Control/ProfilePropGroups.cs new file mode 100644 index 0000000..5e1ca88 --- /dev/null +++ b/DS4Windows/DS4Control/ProfilePropGroups.cs @@ -0,0 +1,18 @@ +using System; + +namespace DS4Windows +{ + public class SquareStickInfo + { + public bool lsMode; + public bool rsMode; + public double roundness = 5.0; + } + + public class StickDeadZoneInfo + { + public int deadZone; + public int antiDeadZone; + public int maxZone = 100; + } +} \ No newline at end of file diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 9cc1b96..cc24876 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -1016,28 +1016,44 @@ namespace DS4Windows return m_Config.SZDeadzone[index]; } - public static int[] LSDeadzone => m_Config.LSDeadzone; + //public static int[] LSDeadzone => m_Config.LSDeadzone; public static int getLSDeadzone(int index) { - return m_Config.LSDeadzone[index]; + return m_Config.lsModInfo[index].deadZone; + //return m_Config.LSDeadzone[index]; } - public static int[] RSDeadzone => m_Config.RSDeadzone; + //public static int[] RSDeadzone => m_Config.RSDeadzone; public static int getRSDeadzone(int index) { - return m_Config.RSDeadzone[index]; + return m_Config.rsModInfo[index].deadZone; + //return m_Config.RSDeadzone[index]; } - public static int[] LSAntiDeadzone => m_Config.LSAntiDeadzone; + //public static int[] LSAntiDeadzone => m_Config.LSAntiDeadzone; public static int getLSAntiDeadzone(int index) { - return m_Config.LSAntiDeadzone[index]; + return m_Config.lsModInfo[index].antiDeadZone; + //return m_Config.LSAntiDeadzone[index]; } - public static int[] RSAntiDeadzone => m_Config.RSAntiDeadzone; + //public static int[] RSAntiDeadzone => m_Config.RSAntiDeadzone; public static int getRSAntiDeadzone(int index) { - return m_Config.RSAntiDeadzone[index]; + return m_Config.rsModInfo[index].antiDeadZone; + //return m_Config.RSAntiDeadzone[index]; + } + + public static StickDeadZoneInfo[] LSModInfo => m_Config.lsModInfo; + public static StickDeadZoneInfo GetLSDeadInfo(int index) + { + return m_Config.lsModInfo[index]; + } + + public static StickDeadZoneInfo[] RSModInfo => m_Config.rsModInfo; + public static StickDeadZoneInfo GetRSDeadInfo(int index) + { + return m_Config.rsModInfo[index]; } public static double[] SXAntiDeadzone => m_Config.SXAntiDeadzone; @@ -1052,16 +1068,18 @@ namespace DS4Windows return m_Config.SZAntiDeadzone[index]; } - public static int[] LSMaxzone => m_Config.LSMaxzone; + //public static int[] LSMaxzone => m_Config.LSMaxzone; public static int getLSMaxzone(int index) { - return m_Config.LSMaxzone[index]; + return m_Config.lsModInfo[index].maxZone; + //return m_Config.LSMaxzone[index]; } - public static int[] RSMaxzone => m_Config.RSMaxzone; + //public static int[] RSMaxzone => m_Config.RSMaxzone; public static int getRSMaxzone(int index) { - return m_Config.RSMaxzone[index]; + return m_Config.rsModInfo[index].maxZone; + //return m_Config.RSMaxzone[index]; } public static double[] SXMaxzone => m_Config.SXMaxzone; @@ -1568,13 +1586,6 @@ namespace DS4Windows } } - public class SquareStickInfo - { - public bool lsMode; - public bool rsMode; - public double roundness = 5.0; - } - public class BackingStore { //public String m_Profile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool" + "\\Profiles.xml"; @@ -1602,9 +1613,18 @@ namespace DS4Windows public Byte[] rumble = new Byte[5] { 100, 100, 100, 100, 100 }; public Byte[] touchSensitivity = new Byte[5] { 100, 100, 100, 100, 100 }; public Byte[] l2Deadzone = new Byte[5] { 0, 0, 0, 0, 0 }, r2Deadzone = new Byte[5] { 0, 0, 0, 0, 0 }; - public int[] LSDeadzone = new int[5] { 0, 0, 0, 0, 0 }, RSDeadzone = new int[5] { 0, 0, 0, 0, 0 }; - public int[] LSAntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }, RSAntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }; - public int[] LSMaxzone = new int[5] { 100, 100, 100, 100, 100 }, RSMaxzone = new int[5] { 100, 100, 100, 100, 100 }; + public StickDeadZoneInfo[] lsModInfo = new StickDeadZoneInfo[5] + { + new StickDeadZoneInfo(), new StickDeadZoneInfo(), + new StickDeadZoneInfo(), new StickDeadZoneInfo(), + new StickDeadZoneInfo() + }; + public StickDeadZoneInfo[] rsModInfo = new StickDeadZoneInfo[5] + { + new StickDeadZoneInfo(), new StickDeadZoneInfo(), + new StickDeadZoneInfo(), new StickDeadZoneInfo(), + new StickDeadZoneInfo() + }; public int[] l2AntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }, r2AntiDeadzone = new int[5] { 0, 0, 0, 0, 0 }; public int[] l2Maxzone = new int[5] { 100, 100, 100, 100, 100 }, r2Maxzone = new int[5] { 100, 100, 100, 100, 100 }; public double[] LSRotation = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 }, RSRotation = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 }; @@ -1964,12 +1984,12 @@ namespace DS4Windows XmlNode xmlR2Maxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "R2MaxZone", null); xmlR2Maxzone.InnerText = r2Maxzone[device].ToString(); Node.AppendChild(xmlR2Maxzone); XmlNode xmlButtonMouseSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "ButtonMouseSensitivity", null); xmlButtonMouseSensitivity.InnerText = buttonMouseSensitivity[device].ToString(); Node.AppendChild(xmlButtonMouseSensitivity); XmlNode xmlRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "Rainbow", null); xmlRainbow.InnerText = rainbow[device].ToString(); Node.AppendChild(xmlRainbow); - XmlNode xmlLSD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSDeadZone", null); xmlLSD.InnerText = LSDeadzone[device].ToString(); Node.AppendChild(xmlLSD); - XmlNode xmlRSD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSDeadZone", null); xmlRSD.InnerText = RSDeadzone[device].ToString(); Node.AppendChild(xmlRSD); - XmlNode xmlLSAD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSAntiDeadZone", null); xmlLSAD.InnerText = LSAntiDeadzone[device].ToString(); Node.AppendChild(xmlLSAD); - XmlNode xmlRSAD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSAntiDeadZone", null); xmlRSAD.InnerText = RSAntiDeadzone[device].ToString(); Node.AppendChild(xmlRSAD); - XmlNode xmlLSMaxZone = m_Xdoc.CreateNode(XmlNodeType.Element, "LSMaxZone", null); xmlLSMaxZone.InnerText = LSMaxzone[device].ToString(); Node.AppendChild(xmlLSMaxZone); - XmlNode xmlRSMaxZone = m_Xdoc.CreateNode(XmlNodeType.Element, "RSMaxZone", null); xmlRSMaxZone.InnerText = RSMaxzone[device].ToString(); Node.AppendChild(xmlRSMaxZone); + XmlNode xmlLSD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSDeadZone", null); xmlLSD.InnerText = lsModInfo[device].deadZone.ToString(); Node.AppendChild(xmlLSD); + XmlNode xmlRSD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSDeadZone", null); xmlRSD.InnerText = rsModInfo[device].deadZone.ToString(); Node.AppendChild(xmlRSD); + XmlNode xmlLSAD = m_Xdoc.CreateNode(XmlNodeType.Element, "LSAntiDeadZone", null); xmlLSAD.InnerText = lsModInfo[device].antiDeadZone.ToString(); Node.AppendChild(xmlLSAD); + XmlNode xmlRSAD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSAntiDeadZone", null); xmlRSAD.InnerText = rsModInfo[device].antiDeadZone.ToString(); Node.AppendChild(xmlRSAD); + XmlNode xmlLSMaxZone = m_Xdoc.CreateNode(XmlNodeType.Element, "LSMaxZone", null); xmlLSMaxZone.InnerText = lsModInfo[device].maxZone.ToString(); Node.AppendChild(xmlLSMaxZone); + XmlNode xmlRSMaxZone = m_Xdoc.CreateNode(XmlNodeType.Element, "RSMaxZone", null); xmlRSMaxZone.InnerText = rsModInfo[device].maxZone.ToString(); Node.AppendChild(xmlRSMaxZone); XmlNode xmlLSRotation = m_Xdoc.CreateNode(XmlNodeType.Element, "LSRotation", null); xmlLSRotation.InnerText = Convert.ToInt32(LSRotation[device] * 180.0 / Math.PI).ToString(); Node.AppendChild(xmlLSRotation); XmlNode xmlRSRotation = m_Xdoc.CreateNode(XmlNodeType.Element, "RSRotation", null); xmlRSRotation.InnerText = Convert.ToInt32(RSRotation[device] * 180.0 / Math.PI).ToString(); Node.AppendChild(xmlRSRotation); @@ -2693,28 +2713,28 @@ namespace DS4Windows catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Rainbow"); double.TryParse(Item.InnerText, out rainbow[device]); } catch { rainbow[device] = 0; missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSDeadZone"); int.TryParse(Item.InnerText, out LSDeadzone[device]); } - catch { LSDeadzone[device] = 0; missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSDeadZone"); int.TryParse(Item.InnerText, out RSDeadzone[device]); } - catch { RSDeadzone[device] = 0; missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSAntiDeadZone"); int.TryParse(Item.InnerText, out LSAntiDeadzone[device]); } - catch { LSAntiDeadzone[device] = 0; missingSetting = true; } - try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSAntiDeadZone"); int.TryParse(Item.InnerText, out RSAntiDeadzone[device]); } - catch { RSAntiDeadzone[device] = 0; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSDeadZone"); int.TryParse(Item.InnerText, out lsModInfo[device].deadZone); } + catch { lsModInfo[device].deadZone = 0; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSDeadZone"); int.TryParse(Item.InnerText, out rsModInfo[device].deadZone); } + catch { rsModInfo[device].deadZone = 0; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSAntiDeadZone"); int.TryParse(Item.InnerText, out lsModInfo[device].antiDeadZone); } + catch { lsModInfo[device].antiDeadZone = 0; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSAntiDeadZone"); int.TryParse(Item.InnerText, out rsModInfo[device].antiDeadZone); } + catch { rsModInfo[device].antiDeadZone = 0; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSMaxZone"); int temp = 100; int.TryParse(Item.InnerText, out temp); - LSMaxzone[device] = Math.Min(Math.Max(temp, 0), 100); + lsModInfo[device].maxZone = Math.Min(Math.Max(temp, 0), 100); } - catch { LSMaxzone[device] = 100; missingSetting = true; } + catch { lsModInfo[device].maxZone = 100; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSMaxZone"); int temp = 100; int.TryParse(Item.InnerText, out temp); - RSMaxzone[device] = Math.Min(Math.Max(temp, 0), 100); + rsModInfo[device].maxZone = Math.Min(Math.Max(temp, 0), 100); } - catch { RSMaxzone[device] = 100; missingSetting = true; } + catch { rsModInfo[device].maxZone = 100; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SXDeadZone"); double.TryParse(Item.InnerText, out SXDeadzone[device]); } catch { SXDeadzone[device] = 0.02; missingSetting = true; } @@ -4169,9 +4189,9 @@ namespace DS4Windows rumble[device] = 100; touchSensitivity[device] = 100; l2Deadzone[device] = r2Deadzone[device] = 0; - LSDeadzone[device] = RSDeadzone[device] = 0; - LSAntiDeadzone[device] = RSAntiDeadzone[device] = 0; - LSMaxzone[device] = RSMaxzone[device] = 100; + lsModInfo[device].deadZone = rsModInfo[device].deadZone = 0; + lsModInfo[device].antiDeadZone = rsModInfo[device].antiDeadZone = 0; + lsModInfo[device].maxZone = rsModInfo[device].maxZone = 100; l2AntiDeadzone[device] = r2AntiDeadzone[device] = 0; l2Maxzone[device] = r2Maxzone[device] = 100; LSRotation[device] = 0.0; diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index a977684..bbf4fc8 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -509,7 +509,7 @@ namespace DS4Windows.Forms try { - nUDLS.Value = Math.Round((decimal)(LSDeadzone[device] / 127d), 3); + nUDLS.Value = Math.Round((decimal)(LSModInfo[device].deadZone / 127d), 3); } catch { @@ -517,7 +517,7 @@ namespace DS4Windows.Forms } try { - nUDRS.Value = Math.Round((decimal)(RSDeadzone[device] / 127d), 3); + nUDRS.Value = Math.Round((decimal)(RSModInfo[device].deadZone / 127d), 3); } catch { @@ -526,7 +526,7 @@ namespace DS4Windows.Forms try { - nUDLSAntiDead.Value = (decimal)(LSAntiDeadzone[device] / 100d); + nUDLSAntiDead.Value = (decimal)(LSModInfo[device].antiDeadZone / 100d); } catch { @@ -534,7 +534,7 @@ namespace DS4Windows.Forms } try { - nUDRSAntiDead.Value = (decimal)(RSAntiDeadzone[device] / 100d); + nUDRSAntiDead.Value = (decimal)(RSModInfo[device].antiDeadZone / 100d); } catch { @@ -543,7 +543,7 @@ namespace DS4Windows.Forms try { - nUDLSMaxZone.Value = (decimal)(LSMaxzone[device] / 100d); + nUDLSMaxZone.Value = (decimal)(LSModInfo[device].maxZone / 100d); } catch { @@ -551,7 +551,7 @@ namespace DS4Windows.Forms } try { - nUDRSMaxZone.Value = (decimal)(RSMaxzone[device] / 100d); + nUDRSMaxZone.Value = (decimal)(RSModInfo[device].maxZone / 100d); } catch { @@ -1313,12 +1313,12 @@ namespace DS4Windows.Forms IdleDisconnectTimeout[device] = (int)(nUDIdleDisconnect.Value * 60); Rainbow[device] = (int)nUDRainbow.Value; - RSDeadzone[device] = (int)Math.Round((nUDRS.Value * 127), 0); - LSDeadzone[device] = (int)Math.Round((nUDLS.Value * 127), 0); - LSAntiDeadzone[device] = (int)(nUDLSAntiDead.Value * 100); - RSAntiDeadzone[device] = (int)(nUDRSAntiDead.Value * 100); - LSMaxzone[device] = (int)(nUDLSMaxZone.Value * 100); - RSMaxzone[device] = (int)(nUDRSMaxZone.Value * 100); + RSModInfo[device].deadZone = (int)Math.Round((nUDRS.Value * 127), 0); + LSModInfo[device].deadZone = (int)Math.Round((nUDLS.Value * 127), 0); + LSModInfo[device].antiDeadZone = (int)(nUDLSAntiDead.Value * 100); + RSModInfo[device].antiDeadZone = (int)(nUDRSAntiDead.Value * 100); + LSModInfo[device].maxZone = (int)(nUDLSMaxZone.Value * 100); + RSModInfo[device].maxZone = (int)(nUDRSMaxZone.Value * 100); LSRotation[device] = (double)nUDLSRotation.Value * Math.PI / 180.0; RSRotation[device] = (double)nUDRSRotation.Value * Math.PI / 180.0; ButtonMouseSensitivity[device] = (int)numUDMouseSens.Value; @@ -2068,7 +2068,7 @@ namespace DS4Windows.Forms private void numUDRS_ValueChanged(object sender, EventArgs e) { nUDRS.Value = Math.Round(nUDRS.Value, 2); - RSDeadzone[device] = (int)Math.Round((nUDRS.Value * 127),0); + RSModInfo[device].deadZone = (int)Math.Round((nUDRS.Value * 127),0); pnlRSTrack.BackColor = nUDRS.Value >= 0 ? Color.White : Color.Red; pnlRSTrack.Refresh(); } @@ -2096,7 +2096,7 @@ namespace DS4Windows.Forms private void numUDLS_ValueChanged(object sender, EventArgs e) { nUDLS.Value = Math.Round(nUDLS.Value, 2); - LSDeadzone[device] = (int)Math.Round((nUDLS.Value * 127), 0); + LSModInfo[device].deadZone = (int)Math.Round((nUDLS.Value * 127), 0); pnlLSTrack.BackColor = nUDLS.Value >= 0 ? Color.White : Color.Red; pnlLSTrack.Refresh(); } @@ -2735,12 +2735,12 @@ namespace DS4Windows.Forms private void nUDLSAntiDead_ValueChanged(object sender, EventArgs e) { - LSAntiDeadzone[device] = (int)(nUDLSAntiDead.Value * 100); + LSModInfo[device].antiDeadZone = (int)(nUDLSAntiDead.Value * 100); } private void nUDRSAntiDead_ValueChanged(object sender, EventArgs e) { - RSAntiDeadzone[device] = (int)(nUDRSAntiDead.Value * 100); + RSModInfo[device].antiDeadZone = (int)(nUDRSAntiDead.Value * 100); } private void nUDL2AntiDead_ValueChanged(object sender, EventArgs e) @@ -2778,12 +2778,12 @@ namespace DS4Windows.Forms private void nUDRSMaxZone_ValueChanged(object sender, EventArgs e) { - RSMaxzone[device] = (int)(nUDRSMaxZone.Value * 100); + RSModInfo[device].maxZone = (int)(nUDRSMaxZone.Value * 100); } private void nUDLSMaxZone_ValueChanged(object sender, EventArgs e) { - LSMaxzone[device] = (int)(nUDLSMaxZone.Value * 100); + LSModInfo[device].maxZone = (int)(nUDLSMaxZone.Value * 100); } private void nUDL2Maxzone_ValueChanged(object sender, EventArgs e) diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index 472a3d9..24989c3 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -150,6 +150,7 @@ + @@ -1256,4 +1257,4 @@ echo @(VersionNumber)> $(ProjectDir)\newest.txt --> - + \ No newline at end of file