From 11cc515127660c4e9d7d238cbbc4d93df749f34e Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 27 Mar 2017 02:50:32 -0700 Subject: [PATCH] Make anti-deadzone setting persistent --- DS4Windows/DS4Control/Mapping.cs | 12 ++++++------ DS4Windows/DS4Control/ScpUtil.cs | 6 ++++++ DS4Windows/DS4Forms/Options.cs | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 0dfbba5..5dde72b 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -457,15 +457,15 @@ namespace DS4Windows else if ((lsDeadzone > 0 && lsSquared > lsDeadzoneSquared) || lsAntiDead > 0) { double r = Math.Atan2(-(dState.LY - 127.5f), (dState.LX - 127.5f)); - double maxXValue = dState.LX > 127.5 ? 127.5 : -127.5; - double maxYValue = dState.LY > 127.5 ? 127.5 : -127.5; + double maxXValue = dState.LX >= 127.5 ? 127.5 : -127.5; + double maxYValue = dState.LY >= 127.5 ? 127.5 : -127.5; double tempLsXDead = 0.0, tempLsYDead = 0.0; double tempOutputX = 0.0, tempOutputY = 0.0; if (lsDeadzone > 0) { tempLsXDead = Math.Cos(r) * (lsDeadzone); - tempLsYDead = Math.Sin(r) * (lsDeadzone); + tempLsYDead = Math.Sin(r) * (-lsDeadzone); if (lsSquared > lsDeadzoneSquared) { @@ -515,15 +515,15 @@ namespace DS4Windows else if ((rsDeadzone > 0 && rsSquared > rsDeadzoneSquared) || rsAntiDead > 0) { double r = Math.Atan2(-(dState.RY - 127.5f), (dState.RX - 127.5f)); - double maxXValue = dState.RX > 127.5 ? 127.5 : -127.5; - double maxYValue = dState.RY > 127.5 ? 127.5 : -127.5; + double maxXValue = dState.RX >= 127.5 ? 127.5 : -127.5; + double maxYValue = dState.RY >= 127.5 ? 127.5 : -127.5; double tempRsXDead = 0.0, tempRsYDead = 0.0; double tempOutputX = 0.0, tempOutputY = 0.0; if (rsDeadzone > 0) { tempRsXDead = Math.Cos(r) * (rsDeadzone); - tempRsYDead = Math.Sin(r) * (rsDeadzone); + tempRsYDead = Math.Sin(r) * (-rsDeadzone); if (rsSquared > rsDeadzoneSquared) { diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index fa26c78..90da7d1 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -773,6 +773,8 @@ namespace DS4Windows 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 xmlSXD = m_Xdoc.CreateNode(XmlNodeType.Element, "SXDeadZone", null); xmlSXD.InnerText = SXDeadzone[device].ToString(); Node.AppendChild(xmlSXD); XmlNode xmlSZD = m_Xdoc.CreateNode(XmlNodeType.Element, "SZDeadZone", null); xmlSZD.InnerText = SZDeadzone[device].ToString(); Node.AppendChild(xmlSZD); @@ -1407,6 +1409,10 @@ namespace DS4Windows catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSDeadZone"); int.TryParse(Item.InnerText, out RSDeadzone[device]); } catch { missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSAntiDeadZone"); int.TryParse(Item.InnerText, out LSAntiDeadzone[device]); } + catch { missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSAntiDeadZone"); int.TryParse(Item.InnerText, out RSAntiDeadzone[device]); } + catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SXDeadZone"); double.TryParse(Item.InnerText, out SXDeadzone[device]); } catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SZDeadZone"); double.TryParse(Item.InnerText, out SZDeadzone[device]); } diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 362e851..01cf6ea 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -238,6 +238,22 @@ namespace DS4Windows nUDRS.Value = 0; } try + { + nUDLSAntiDead.Value = (decimal)(LSAntiDeadzone[device] / 100d); + } + catch + { + nUDLSAntiDead.Value = 0; + } + try + { + nUDRSAntiDead.Value = (decimal)(RSAntiDeadzone[device] / 100d); + } + catch + { + nUDRSAntiDead.Value = 0; + } + try { nUDSX.Value = (decimal)SXDeadzone[device]; } @@ -399,6 +415,8 @@ namespace DS4Windows nUDR2.Value = 0; nUDLS.Value = 0; nUDRS.Value = 0; + nUDLSAntiDead.Value = 0; + nUDRSAntiDead.Value = 0; nUDSX.Value = .25m; nUDSZ.Value = .25m; @@ -1021,6 +1039,8 @@ namespace DS4Windows 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); ButtonMouseSensitivity[device] = (int)numUDMouseSens.Value; FlashAt[device] = (int)nUDflashLED.Value; SXDeadzone[device] = (double)nUDSX.Value;