diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index 731ce3c..1805cec 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -872,21 +872,26 @@ namespace DS4Windows bool sOff = tempBool = isUsingSAforMouse(device); if (sOff == false) { - double SXD = 10 * getSXDeadzone(device); - double SZD = 10 * getSZDeadzone(device); + int SXD = (int)(10d * getSXDeadzone(device)); + int SZD = (int)(10d * getSZDeadzone(device)); + double SXMax = getSXMaxzone(device); + double SZMax = getSZMaxzone(device); double sxsens = getSXSens(device); double szsens = getSZSens(device); int gyroX = cState.Motion.accelX; int gyroZ = cState.Motion.accelZ; - if (SXD > 0.0) + int absx = Math.Abs(gyroX); + int absz = Math.Abs(gyroZ); + + if (SXD > 0 || SXMax < 1.0) { - int absx = Math.Abs(gyroX); + int maxValue = (int)(SXMax * 128d); if (absx > SXD) { cState.Motion.accelX = Math.Sign(gyroX) * - (int)Math.Min(128, sxsens * 128 * ((absx - SXD) / (128 - SXD))); + (int)Math.Min(128d, sxsens * 128d * ((absx - SXD) / (double)(maxValue - SXD))); } else { @@ -895,18 +900,17 @@ namespace DS4Windows } else { - int absx = Math.Abs(gyroX); cState.Motion.accelX = Math.Sign(gyroX) * - (int)Math.Min(128, sxsens * 128 * (absx / (double)(128))); + (int)Math.Min(128d, sxsens * 128d * (absx / 128d)); } - if (SZD > 0.0) + if (SZD > 0 || SZMax < 1.0) { - int absz = Math.Abs(gyroZ); + int maxValue = (int)(SZMax * 128d); if (absz > SZD) { cState.Motion.accelZ = Math.Sign(gyroZ) * - (int)Math.Min(128, szsens * 128 * ((absz - SZD) / (128 - SZD))); + (int)Math.Min(128d, szsens * 128d * ((absz - SZD) / (double)(maxValue - SZD))); } else { @@ -915,9 +919,8 @@ namespace DS4Windows } else { - int absz = Math.Abs(gyroZ); cState.Motion.accelZ = Math.Sign(gyroZ) * - (int)Math.Min(128, szsens * 128 * ((absz) / (double)(128))); + (int)Math.Min(128d, szsens * 128d * ((absz) / 128d)); } } diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 38cfaaa..8cc209e 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -696,6 +696,18 @@ namespace DS4Windows return m_Config.SZDeadzone[index]; } + public static double[] SXMaxzone => m_Config.SXMaxzone; + public static double getSXMaxzone(int index) + { + return m_Config.SXMaxzone[index]; + } + + public static double[] SZMaxzone => m_Config.SZMaxzone; + public static double getSZMaxzone(int index) + { + return m_Config.SZMaxzone[index]; + } + public static int[] LSDeadzone => m_Config.LSDeadzone; public static int getLSDeadzone(int index) { @@ -1170,6 +1182,8 @@ namespace DS4Windows public int[] l2Maxzone = { 100, 100, 100, 100, 100 }, r2Maxzone = { 100, 100, 100, 100, 100 }; public double[] LSRotation = { 0.0, 0.0, 0.0, 0.0, 0.0 }, RSRotation = { 0.0, 0.0, 0.0, 0.0, 0.0 }; public double[] SXDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 }, SZDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 }; + public double[] SXMaxzone = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }, + SZMaxzone = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 }; public double[] l2Sens = { 1, 1, 1, 1, 1 }, r2Sens = { 1, 1, 1, 1, 1 }; public double[] LSSens = { 1, 1, 1, 1, 1 }, RSSens = { 1, 1, 1, 1, 1 }; public double[] SXSens = { 1, 1, 1, 1, 1 }, SZSens = { 1, 1, 1, 1, 1 }; @@ -1480,6 +1494,9 @@ namespace DS4Windows 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); + XmlNode xmlSXMaxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "SXMaxZone", null); xmlSXMaxzone.InnerText = Convert.ToInt32(SXMaxzone[device] * 100.0).ToString(); Node.AppendChild(xmlSXMaxzone); + XmlNode xmlSZMaxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "SZMaxZone", null); xmlSZMaxzone.InnerText = Convert.ToInt32(SZMaxzone[device] * 100.0).ToString(); Node.AppendChild(xmlSZMaxzone); + XmlNode xmlSens = m_Xdoc.CreateNode(XmlNodeType.Element, "Sensitivity", null); xmlSens.InnerText = $"{LSSens[device]}|{RSSens[device]}|{l2Sens[device]}|{r2Sens[device]}|{SXSens[device]}|{SZSens[device]}"; Node.AppendChild(xmlSens); @@ -2281,9 +2298,23 @@ namespace DS4Windows catch { RSMaxzone[device] = 100; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SXDeadZone"); double.TryParse(Item.InnerText, out SXDeadzone[device]); } - catch { missingSetting = true; } + catch { SXDeadzone[device] = 0.25; missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SZDeadZone"); double.TryParse(Item.InnerText, out SZDeadzone[device]); } - catch { missingSetting = true; } + catch { SZDeadzone[device] = 0.25; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SXMaxZone"); + int temp = 0; + int.TryParse(Item.InnerText, out temp); + SXMaxzone[device] = Math.Min(Math.Max(temp * 0.01, 0.0), 1.0); + } + catch { SXMaxzone[device] = 1.0; missingSetting = true; } + + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SZMaxZone"); + int temp = 0; + int.TryParse(Item.InnerText, out temp); + SZMaxzone[device] = Math.Min(Math.Max(temp * 0.01, 0.0), 1.0); + } + catch { SZMaxzone[device] = 1.0; missingSetting = true; } try { @@ -3465,6 +3496,7 @@ namespace DS4Windows LSRotation[device] = 0.0; RSRotation[device] = 0.0; SXDeadzone[device] = SZDeadzone[device] = 0.25; + SXMaxzone[device] = SZMaxzone[device] = 1.0; l2Sens[device] = r2Sens[device] = 1; LSSens[device] = RSSens[device] = 1; SXSens[device] = SZSens[device] = 1; diff --git a/DS4Windows/DS4Forms/Options.Designer.cs b/DS4Windows/DS4Forms/Options.Designer.cs index 8ab5c04..7fde628 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -294,6 +294,8 @@ this.rBSAControls = new System.Windows.Forms.RadioButton(); this.rBSAMouse = new System.Windows.Forms.RadioButton(); this.pnlSAMouse = new System.Windows.Forms.Panel(); + this.cBGyroMouseXAxis = new System.Windows.Forms.ComboBox(); + this.label16 = new System.Windows.Forms.Label(); this.lbGyroSmooth = new System.Windows.Forms.Label(); this.cBGyroSmooth = new System.Windows.Forms.CheckBox(); this.lbSmoothWeight = new System.Windows.Forms.Label(); @@ -343,9 +345,11 @@ this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.label17 = new System.Windows.Forms.Label(); + this.label18 = new System.Windows.Forms.Label(); + this.nUDSixAxisXMaxZone = new System.Windows.Forms.NumericUpDown(); + this.nUDSixAxisZMaxZone = new System.Windows.Forms.NumericUpDown(); this.advColorDialog = new DS4Windows.AdvancedColorDialog(); - this.label16 = new System.Windows.Forms.Label(); - this.cBGyroMouseXAxis = new System.Windows.Forms.ComboBox(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBGreenBar)).BeginInit(); @@ -433,6 +437,8 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit(); this.cMGyroTriggers.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisXMaxZone)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisZMaxZone)).BeginInit(); this.SuspendLayout(); // // lowColorChooserButton @@ -2792,6 +2798,10 @@ // // maxZoneTabPage // + this.maxZoneTabPage.Controls.Add(this.nUDSixAxisZMaxZone); + this.maxZoneTabPage.Controls.Add(this.nUDSixAxisXMaxZone); + this.maxZoneTabPage.Controls.Add(this.label18); + this.maxZoneTabPage.Controls.Add(this.label17); this.maxZoneTabPage.Controls.Add(this.nUDR2Maxzone); this.maxZoneTabPage.Controls.Add(this.nUDL2Maxzone); this.maxZoneTabPage.Controls.Add(this.label8); @@ -3127,6 +3137,22 @@ resources.ApplyResources(this.pnlSAMouse, "pnlSAMouse"); this.pnlSAMouse.Name = "pnlSAMouse"; // + // cBGyroMouseXAxis + // + this.cBGyroMouseXAxis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cBGyroMouseXAxis.FormattingEnabled = true; + this.cBGyroMouseXAxis.Items.AddRange(new object[] { + resources.GetString("cBGyroMouseXAxis.Items"), + resources.GetString("cBGyroMouseXAxis.Items1")}); + resources.ApplyResources(this.cBGyroMouseXAxis, "cBGyroMouseXAxis"); + this.cBGyroMouseXAxis.Name = "cBGyroMouseXAxis"; + this.cBGyroMouseXAxis.SelectedIndexChanged += new System.EventHandler(this.cBGyroMouseXAxis_SelectedIndexChanged); + // + // label16 + // + resources.ApplyResources(this.label16, "label16"); + this.label16.Name = "label16"; + // // lbGyroSmooth // resources.ApplyResources(this.lbGyroSmooth, "lbGyroSmooth"); @@ -3653,21 +3679,59 @@ resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem"); this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged); // - // label16 + // label17 // - resources.ApplyResources(this.label16, "label16"); - this.label16.Name = "label16"; + resources.ApplyResources(this.label17, "label17"); + this.label17.Name = "label17"; // - // cBGyroMouseXAxis + // label18 // - this.cBGyroMouseXAxis.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cBGyroMouseXAxis.FormattingEnabled = true; - this.cBGyroMouseXAxis.Items.AddRange(new object[] { - resources.GetString("cBGyroMouseXAxis.Items"), - resources.GetString("cBGyroMouseXAxis.Items1")}); - resources.ApplyResources(this.cBGyroMouseXAxis, "cBGyroMouseXAxis"); - this.cBGyroMouseXAxis.Name = "cBGyroMouseXAxis"; - this.cBGyroMouseXAxis.SelectedIndexChanged += new System.EventHandler(this.cBGyroMouseXAxis_SelectedIndexChanged); + resources.ApplyResources(this.label18, "label18"); + this.label18.Name = "label18"; + // + // nUDSixAxisXMaxZone + // + this.nUDSixAxisXMaxZone.DecimalPlaces = 2; + this.nUDSixAxisXMaxZone.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + resources.ApplyResources(this.nUDSixAxisXMaxZone, "nUDSixAxisXMaxZone"); + this.nUDSixAxisXMaxZone.Maximum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nUDSixAxisXMaxZone.Name = "nUDSixAxisXMaxZone"; + this.nUDSixAxisXMaxZone.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nUDSixAxisXMaxZone.ValueChanged += new System.EventHandler(this.nUDSixAxisXMaxZone_ValueChanged); + // + // nUDSixAxisZMaxZone + // + this.nUDSixAxisZMaxZone.DecimalPlaces = 2; + this.nUDSixAxisZMaxZone.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + resources.ApplyResources(this.nUDSixAxisZMaxZone, "nUDSixAxisZMaxZone"); + this.nUDSixAxisZMaxZone.Maximum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nUDSixAxisZMaxZone.Name = "nUDSixAxisZMaxZone"; + this.nUDSixAxisZMaxZone.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.nUDSixAxisZMaxZone.ValueChanged += new System.EventHandler(this.nUDSixAxisZMaxZone_ValueChanged); // // Options // @@ -3786,6 +3850,8 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit(); this.cMGyroTriggers.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisXMaxZone)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisZMaxZone)).EndInit(); this.ResumeLayout(false); } @@ -4110,5 +4176,9 @@ private System.Windows.Forms.ComboBox touchpadInvertComboBox; private System.Windows.Forms.ComboBox cBGyroMouseXAxis; private System.Windows.Forms.Label label16; + private System.Windows.Forms.NumericUpDown nUDSixAxisZMaxZone; + private System.Windows.Forms.NumericUpDown nUDSixAxisXMaxZone; + private System.Windows.Forms.Label label18; + private System.Windows.Forms.Label label17; } } \ No newline at end of file diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 45c6678..512cd10 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -497,6 +497,7 @@ namespace DS4Windows { nUDSX.Value = 0.25m; } + try { nUDSZ.Value = (decimal)SZDeadzone[device]; @@ -505,6 +506,25 @@ namespace DS4Windows { nUDSZ.Value = 0.25m; } + + try + { + nUDSixAxisXMaxZone.Value = (decimal)SXMaxzone[device]; + } + catch + { + nUDSixAxisXMaxZone.Value = 1.0m; + } + + try + { + nUDSixAxisZMaxZone.Value = (decimal)SZMaxzone[device]; + } + catch + { + nUDSixAxisZMaxZone.Value = 1.0m; + } + try { nUDL2S.Value = Math.Round((decimal)L2Sens[device], 2); @@ -677,6 +697,8 @@ namespace DS4Windows nUDRSRotation.Value = 0; nUDSX.Value = .25m; nUDSZ.Value = .25m; + nUDSixAxisXMaxZone.Value = 1.0m; + nUDSixAxisZMaxZone.Value = 1.0m; nUDL2S.Value = 1; nUDR2S.Value = 1; @@ -1335,6 +1357,8 @@ namespace DS4Windows FlashAt[device] = (int)nUDflashLED.Value; SXDeadzone[device] = (double)nUDSX.Value; SZDeadzone[device] = (double)nUDSZ.Value; + SXMaxzone[device] = (double)nUDSixAxisXMaxZone.Value; + SZMaxzone[device] = (double)nUDSixAxisZMaxZone.Value; MouseAccel[device] = cBMouseAccel.Checked; DinputOnly[device] = cBDinput.Checked; StartTouchpadOff[device] = cbStartTouchpadOff.Checked; @@ -2920,6 +2944,22 @@ namespace DS4Windows } } + private void nUDSixAxisXMaxZone_ValueChanged(object sender, EventArgs e) + { + if (!loading) + { + SXMaxzone[device] = (double)nUDSixAxisXMaxZone.Value; + } + } + + private void nUDSixAxisZMaxZone_ValueChanged(object sender, EventArgs e) + { + if (!loading) + { + SZMaxzone[device] = (double)nUDSixAxisZMaxZone.Value; + } + } + private void Options_Resize(object sender, EventArgs e) { fLPSettings.AutoScroll = false; diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index acab86f..0a999dc 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -1338,6 +1338,9 @@ True + + NoControl + 141, 66 @@ -6337,11 +6340,113 @@ with profile 1 + + 220, 29 + + + 40, 20 + + + 11 + + + nUDSixAxisZMaxZone + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + maxZoneTabPage + + + 0 + + + 220, 3 + + + 41, 20 + + + 10 + + + nUDSixAxisXMaxZone + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + maxZoneTabPage + + + 1 + + + True + + + NoControl + + + 162, 31 + + + 52, 13 + + + 9 + + + Sixaxis Z: + + + label18 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + maxZoneTabPage + + + 2 + + + True + + + NoControl + + + 162, 6 + + + 52, 13 + + + 8 + + + Sixaxis X: + + + label17 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + maxZoneTabPage + + + 3 + - 161, 29 + 114, 29 - 50, 20 + 40, 20 7 @@ -6356,13 +6461,13 @@ with profile maxZoneTabPage - 0 + 4 - 42, 29 + 36, 29 - 51, 20 + 41, 20 6 @@ -6377,7 +6482,7 @@ with profile maxZoneTabPage - 1 + 5 True @@ -6386,7 +6491,7 @@ with profile NoControl - 129, 31 + 85, 31 24, 13 @@ -6407,7 +6512,7 @@ with profile maxZoneTabPage - 2 + 6 True @@ -6437,13 +6542,13 @@ with profile maxZoneTabPage - 3 + 7 - 160, 3 + 114, 4 - 51, 20 + 40, 20 3 @@ -6458,7 +6563,7 @@ with profile maxZoneTabPage - 4 + 8 True @@ -6467,7 +6572,7 @@ with profile NoControl - 129, 5 + 85, 5 25, 13 @@ -6488,13 +6593,13 @@ with profile maxZoneTabPage - 5 + 9 - 42, 3 + 37, 3 - 51, 20 + 40, 20 1 @@ -6509,7 +6614,7 @@ with profile maxZoneTabPage - 6 + 10 True @@ -6539,7 +6644,7 @@ with profile maxZoneTabPage - 7 + 11 4, 22 @@ -6937,6 +7042,9 @@ with profile True + + NoControl + 125, 23 @@ -6985,6 +7093,9 @@ with profile True + + NoControl + 4, 22 @@ -7156,6 +7267,9 @@ with profile True + + NoControl + 167, 74 @@ -7183,6 +7297,9 @@ with profile True + + NoControl + 8, 145 @@ -8188,6 +8305,9 @@ with profile 1011, 481 + + NoControl + 4, 4, 4, 4 @@ -8492,7 +8612,7 @@ with profile advColorDialog - DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.84.0, Culture=neutral, PublicKeyToken=null + DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.4.85.0, Culture=neutral, PublicKeyToken=null Options