From 3f18aec71f3273bc476b46bf570eb62af5da0b11 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 26 Aug 2019 17:47:57 -0500 Subject: [PATCH 1/3] Change gyro toggle setting on mode change in form --- DS4Windows/DS4Forms/Options.cs | 4 + DS4Windows/DS4Forms/Options.resx | 258 ++++++++++++++++++++++++++++--- 2 files changed, 241 insertions(+), 21 deletions(-) diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 1992c20..61033bc 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -3586,9 +3586,13 @@ namespace DS4Windows.Forms break; case 1: GyroOutputMode[device] = GyroOutMode.Mouse; + SetGyroMouseToggle(device, toggleGyroMCb.Checked, + Program.rootHub); break; case 2: GyroOutputMode[device] = GyroOutMode.MouseJoystick; + SetGyroMouseStickToggle(device, + gyroMStickToggleCk.Checked, Program.rootHub); break; default: break; diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index 4fc0984..2a68938 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -5367,6 +5367,243 @@ 12 + + label36 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 0 + + + btnGyroMStickTrig + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 1 + + + gyroMStickTrigBehaveCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 2 + + + gyroMStickToggleCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 3 + + + label29 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 4 + + + gyroMouseStickDZ + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 5 + + + label30 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 6 + + + gyroMouseStickMaxZ + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 7 + + + label31 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 8 + + + gyroMouseStickAntiDeadX + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 9 + + + label32 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 10 + + + gyroMouseStickAntiDeadY + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 11 + + + label35 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 12 + + + gyroMouseStickEvalCombo + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 13 + + + label33 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 14 + + + gyroMousestickXAxisCom + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 15 + + + gyroMouseStickInvertXCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 16 + + + gyroMouseStickInvertYCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 17 + + + 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 @@ -5850,27 +6087,6 @@ 17 - - 8, 47 - - - 252, 181 - - - 260 - - - gyroMouseJoyFLP - - - System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gBGyro - - - 0 - tPControls From 111e44c2b87326c7266d6f1d3bb224852607a2c2 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 26 Aug 2019 18:53:28 -0500 Subject: [PATCH 2/3] Added vertical scale to Mouse Joystick --- DS4Windows/DS4Control/Mouse.cs | 6 + DS4Windows/DS4Control/ProfilePropGroups.cs | 1 + DS4Windows/DS4Control/ScpUtil.cs | 6 +- DS4Windows/DS4Forms/Options.Designer.cs | 37 +++ DS4Windows/DS4Forms/Options.cs | 11 + DS4Windows/DS4Forms/Options.resx | 357 +++++++-------------- 6 files changed, 168 insertions(+), 250 deletions(-) diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index 15f72a5..cd7ccd8 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -277,6 +277,12 @@ namespace DS4Windows maxDirY = deltaY >= 0 ? 127 : -128; */ + if (msinfo.vertScale != 100) + { + double verticalScale = msinfo.vertScale * 0.01; + deltaY = (int)(deltaY * verticalScale); + } + if (deltaX != 0) xratio = deltaX / (double)maxValX; if (deltaY != 0) yratio = deltaY / (double)maxValY; diff --git a/DS4Windows/DS4Control/ProfilePropGroups.cs b/DS4Windows/DS4Control/ProfilePropGroups.cs index eb3dad3..8a68417 100644 --- a/DS4Windows/DS4Control/ProfilePropGroups.cs +++ b/DS4Windows/DS4Control/ProfilePropGroups.cs @@ -34,6 +34,7 @@ namespace DS4Windows public int maxZone; public double antiDeadX; public double antiDeadY; + public int vertScale; // Flags representing invert axis choices public uint inverted; } diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 0f912db..4e3e50f 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -2280,6 +2280,7 @@ namespace DS4Windows 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 xmlGyroMStickToggle = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickToggle", null); xmlGyroMStickToggle.InnerText = gyroMouseStickToggle[device].ToString(); Node.AppendChild(xmlGyroMStickToggle); + XmlNode xmlGyroMStickVerticalScale = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickVerticalScale", null); xmlGyroMStickVerticalScale.InnerText = gyroMStickInfo[device].vertScale.ToString(); Node.AppendChild(xmlGyroMStickVerticalScale); 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); @@ -3192,6 +3193,9 @@ namespace DS4Windows } catch { gyroMouseStickToggle[device] = false; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickVerticalScale"); int.TryParse(Item.InnerText, out gyroMStickInfo[device].vertScale); } + catch { gyroMStickInfo[device].vertScale = 100; missingSetting = true; } + try { @@ -4587,7 +4591,7 @@ namespace DS4Windows sAMouseStickTriggerCond[device] = true; gyroMStickInfo[device].deadZone = 30; gyroMStickInfo[device].maxZone = 830; gyroMStickInfo[device].antiDeadX = 0.4; gyroMStickInfo[device].antiDeadY = 0.4; - gyroMStickInfo[device].inverted = 0; + gyroMStickInfo[device].inverted = 0; gyroMStickInfo[device].vertScale = 100; gyroMouseStickToggle[device] = false; sASteeringWheelEmulationAxis[device] = SASteeringWheelEmulationAxisType.None; sASteeringWheelEmulationRange[device] = 360; diff --git a/DS4Windows/DS4Forms/Options.Designer.cs b/DS4Windows/DS4Forms/Options.Designer.cs index 0466b6f..0b86524 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -424,6 +424,9 @@ this.optionsTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shareTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.psTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.label37 = new System.Windows.Forms.Label(); + this.gyroMStickVertScaleNUD = new System.Windows.Forms.NumericUpDown(); + this.label38 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBGreenBar)).BeginInit(); @@ -525,6 +528,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit(); this.cMGyroTriggers.SuspendLayout(); this.cMTouchDisableInvert.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMStickVertScaleNUD)).BeginInit(); this.SuspendLayout(); // // lowColorChooserButton @@ -2046,6 +2050,9 @@ this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickAntiDeadX); this.gyroMouseJoyFLP.Controls.Add(this.label32); this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickAntiDeadY); + this.gyroMouseJoyFLP.Controls.Add(this.label37); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMStickVertScaleNUD); + this.gyroMouseJoyFLP.Controls.Add(this.label38); this.gyroMouseJoyFLP.Controls.Add(this.label35); this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickEvalCombo); this.gyroMouseJoyFLP.Controls.Add(this.label33); @@ -4557,6 +4564,32 @@ resources.ApplyResources(this.psTouchInvStripMenuItem, "psTouchInvStripMenuItem"); this.psTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); // + // label37 + // + resources.ApplyResources(this.label37, "label37"); + this.label37.Name = "label37"; + // + // gyroMStickVertScaleNUD + // + resources.ApplyResources(this.gyroMStickVertScaleNUD, "gyroMStickVertScaleNUD"); + this.gyroMStickVertScaleNUD.Maximum = new decimal(new int[] { + 400, + 0, + 0, + 0}); + this.gyroMStickVertScaleNUD.Name = "gyroMStickVertScaleNUD"; + this.gyroMStickVertScaleNUD.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.gyroMStickVertScaleNUD.ValueChanged += new System.EventHandler(this.GyroMStickVertScaleNUD_ValueChanged); + // + // label38 + // + resources.ApplyResources(this.label38, "label38"); + this.label38.Name = "label38"; + // // Options // resources.ApplyResources(this, "$this"); @@ -4690,6 +4723,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit(); this.cMGyroTriggers.ResumeLayout(false); this.cMTouchDisableInvert.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.gyroMStickVertScaleNUD)).EndInit(); this.ResumeLayout(false); } @@ -5092,5 +5126,8 @@ private System.Windows.Forms.Label label35; private System.Windows.Forms.ComboBox gyroMouseStickEvalCombo; private System.Windows.Forms.CheckBox gyroMStickToggleCk; + private System.Windows.Forms.Label label37; + private System.Windows.Forms.NumericUpDown gyroMStickVertScaleNUD; + private System.Windows.Forms.Label label38; } } \ No newline at end of file diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 61033bc..53f0fc6 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -815,6 +815,7 @@ namespace DS4Windows.Forms gyroMouseStickInvertXCk.Checked = (gyroMouseStickInfo.inverted & 1) == 1; gyroMouseStickInvertYCk.Checked = (gyroMouseStickInfo.inverted & 2) == 2; gyroMStickToggleCk.Checked = GyroMouseStickToggle[device]; + gyroMStickVertScaleNUD.Value = gyroMouseStickInfo.vertScale; } else { @@ -960,6 +961,7 @@ namespace DS4Windows.Forms gyroMouseStickInvertYCk.Checked = false; gyroMStickTrigBehaveCk.Checked = false; gyroMStickToggleCk.Checked = false; + gyroMStickVertScaleNUD.Value = 100; Set(); } @@ -1571,6 +1573,7 @@ namespace DS4Windows.Forms if (gyroMouseStickInvertXCk.Checked) tempInvert |= 1 << 0; if (gyroMouseStickInvertYCk.Checked) tempInvert |= 1 << 1; GyroMouseStickInf[device].inverted = tempInvert; + GyroMouseStickInf[device].vertScale = (int)gyroMStickVertScaleNUD.Value; } private void Show_ControlsBtn(object sender, EventArgs e) @@ -3685,6 +3688,14 @@ namespace DS4Windows.Forms } } + private void GyroMStickVertScaleNUD_ValueChanged(object sender, EventArgs e) + { + if (loading == false) + { + GyroMouseStickInf[device].vertScale = (int)gyroMStickVertScaleNUD.Value; + } + } + private void trackFrictionNUD_ValueChanged(object sender, EventArgs e) { if (loading == false) diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index 2a68938..c61a9ee 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -5367,243 +5367,6 @@ 12 - - label36 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 0 - - - btnGyroMStickTrig - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 1 - - - gyroMStickTrigBehaveCk - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 2 - - - gyroMStickToggleCk - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 3 - - - label29 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 4 - - - gyroMouseStickDZ - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 5 - - - label30 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 6 - - - gyroMouseStickMaxZ - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 7 - - - label31 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 8 - - - gyroMouseStickAntiDeadX - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 9 - - - label32 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 10 - - - gyroMouseStickAntiDeadY - - - System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 11 - - - label35 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 12 - - - gyroMouseStickEvalCombo - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 13 - - - label33 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 14 - - - gyroMousestickXAxisCom - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 15 - - - gyroMouseStickInvertXCk - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 16 - - - gyroMouseStickInvertYCk - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - gyroMouseJoyFLP - - - 17 - - - 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 @@ -5916,6 +5679,81 @@ 11 + + True + + + 3, 104 + + + 75, 13 + + + 280 + + + Vertical Scale: + + + label37 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 12 + + + 84, 107 + + + 75, 20 + + + 281 + + + gyroMStickVertScaleNUD + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 13 + + + 165, 104 + + + 20, 23 + + + 282 + + + % + + + MiddleCenter + + + label38 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 14 + True @@ -5923,7 +5761,7 @@ NoControl - 3, 104 + 3, 130 59, 13 @@ -5944,7 +5782,7 @@ gyroMouseJoyFLP - 12 + 15 And @@ -5953,7 +5791,7 @@ Or - 68, 107 + 68, 133 72, 21 @@ -5971,13 +5809,13 @@ gyroMouseJoyFLP - 13 + 16 True - 146, 104 + 146, 130 39, 13 @@ -5998,7 +5836,7 @@ gyroMouseJoyFLP - 14 + 17 Yaw @@ -6007,7 +5845,7 @@ Roll - 191, 107 + 191, 133 56, 21 @@ -6025,13 +5863,13 @@ gyroMouseJoyFLP - 15 + 18 True - 3, 134 + 3, 160 Yes @@ -6055,13 +5893,13 @@ gyroMouseJoyFLP - 16 + 19 True - 72, 134 + 72, 160 Yes @@ -6085,7 +5923,28 @@ gyroMouseJoyFLP - 17 + 20 + + + 8, 47 + + + 252, 181 + + + 260 + + + gyroMouseJoyFLP + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gBGyro + + + 0 tPControls From 9bd51043b8698275c4057a94c3b92dca379ac596 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 26 Aug 2019 22:15:38 -0500 Subject: [PATCH 3/3] Added smoothing to Mouse Joystick --- DS4Windows/DS4Control/Mouse.cs | 62 +++++++------- DS4Windows/DS4Control/ProfilePropGroups.cs | 2 + DS4Windows/DS4Control/ScpUtil.cs | 12 +++ DS4Windows/DS4Forms/Options.Designer.cs | 80 +++++++++++++----- DS4Windows/DS4Forms/Options.cs | 48 +++++++++-- DS4Windows/DS4Forms/Options.resx | 98 +++++++++++++++++++--- 6 files changed, 228 insertions(+), 74 deletions(-) diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index cd7ccd8..d21c15d 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -174,14 +174,11 @@ namespace DS4Windows SixMouseStick(arg); else if (!useReverseRatchet && !triggeractivated) SixMouseStick(arg); - //else - // SixMouseReset(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]; @@ -194,7 +191,6 @@ namespace DS4Windows ySmoothBuffer[iIndex] = 0; smoothBufferTail = iIndex + 1; } - */ private void SixMouseStick(SixAxisEventArgs arg) { @@ -248,35 +244,37 @@ namespace DS4Windows 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++) + if (msinfo.useSmoothing) { - 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; + 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 *= msinfo.smoothWeight; + } + + 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; } - 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 (msinfo.vertScale != 100) { double verticalScale = msinfo.vertScale * 0.01; diff --git a/DS4Windows/DS4Control/ProfilePropGroups.cs b/DS4Windows/DS4Control/ProfilePropGroups.cs index 8a68417..ed53966 100644 --- a/DS4Windows/DS4Control/ProfilePropGroups.cs +++ b/DS4Windows/DS4Control/ProfilePropGroups.cs @@ -37,5 +37,7 @@ namespace DS4Windows public int vertScale; // Flags representing invert axis choices public uint inverted; + public bool useSmoothing; + public double smoothWeight; } } \ No newline at end of file diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 4e3e50f..d270594 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -2281,6 +2281,8 @@ namespace DS4Windows XmlNode xmlGyroMStickInvert = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickInvert", null); xmlGyroMStickInvert.InnerText = gyroMStickInfo[device].inverted.ToString(); Node.AppendChild(xmlGyroMStickInvert); XmlNode xmlGyroMStickToggle = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickToggle", null); xmlGyroMStickToggle.InnerText = gyroMouseStickToggle[device].ToString(); Node.AppendChild(xmlGyroMStickToggle); XmlNode xmlGyroMStickVerticalScale = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickVerticalScale", null); xmlGyroMStickVerticalScale.InnerText = gyroMStickInfo[device].vertScale.ToString(); Node.AppendChild(xmlGyroMStickVerticalScale); + XmlNode xmlGyroMStickSmoothing = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickSmoothing", null); xmlGyroMStickSmoothing.InnerText = gyroMStickInfo[device].useSmoothing.ToString(); Node.AppendChild(xmlGyroMStickSmoothing); + XmlNode xmlGyroMStickSmoothWeight = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseStickSmoothingWeight", null); xmlGyroMStickSmoothWeight.InnerText = Convert.ToInt32(gyroMStickInfo[device].smoothWeight * 100).ToString(); Node.AppendChild(xmlGyroMStickSmoothWeight); 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); @@ -3196,6 +3198,15 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickVerticalScale"); int.TryParse(Item.InnerText, out gyroMStickInfo[device].vertScale); } catch { gyroMStickInfo[device].vertScale = 100; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickSmoothing"); bool.TryParse(Item.InnerText, out gyroMStickInfo[device].useSmoothing); } + catch { gyroMStickInfo[device].useSmoothing = false; missingSetting = true; } + + try { + Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseStickSmoothingWeight"); + int temp = 0; int.TryParse(Item.InnerText, out temp); + gyroMStickInfo[device].smoothWeight = Math.Min(Math.Max(0.0, Convert.ToDouble(temp * 0.01)), 1.0); + } + catch { gyroMStickInfo[device].smoothWeight = 0.5; missingSetting = true; } try { @@ -4593,6 +4604,7 @@ namespace DS4Windows gyroMStickInfo[device].antiDeadX = 0.4; gyroMStickInfo[device].antiDeadY = 0.4; gyroMStickInfo[device].inverted = 0; gyroMStickInfo[device].vertScale = 100; gyroMouseStickToggle[device] = false; + gyroMStickInfo[device].useSmoothing = false; gyroMStickInfo[device].smoothWeight = 0.5; 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 0b86524..9dd8da6 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -208,6 +208,9 @@ this.gyroMouseStickAntiDeadX = new System.Windows.Forms.NumericUpDown(); this.label32 = new System.Windows.Forms.Label(); this.gyroMouseStickAntiDeadY = new System.Windows.Forms.NumericUpDown(); + this.label37 = new System.Windows.Forms.Label(); + this.gyroMStickVertScaleNUD = new System.Windows.Forms.NumericUpDown(); + this.label38 = new System.Windows.Forms.Label(); this.label35 = new System.Windows.Forms.Label(); this.gyroMouseStickEvalCombo = new System.Windows.Forms.ComboBox(); this.label33 = new System.Windows.Forms.Label(); @@ -424,9 +427,9 @@ this.optionsTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shareTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.psTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.label37 = new System.Windows.Forms.Label(); - this.gyroMStickVertScaleNUD = new System.Windows.Forms.NumericUpDown(); - this.label38 = new System.Windows.Forms.Label(); + this.gyroMStickUseSmoothCk = new System.Windows.Forms.CheckBox(); + this.gyroMStickSmoothWeightNUD = new System.Windows.Forms.NumericUpDown(); + this.label39 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBGreenBar)).BeginInit(); @@ -479,6 +482,7 @@ ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickMaxZ)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadX)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMStickVertScaleNUD)).BeginInit(); this.tCControls.SuspendLayout(); this.tPControls.SuspendLayout(); this.pnlController.SuspendLayout(); @@ -528,7 +532,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit(); this.cMGyroTriggers.SuspendLayout(); this.cMTouchDisableInvert.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.gyroMStickVertScaleNUD)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMStickSmoothWeightNUD)).BeginInit(); this.SuspendLayout(); // // lowColorChooserButton @@ -2059,6 +2063,9 @@ this.gyroMouseJoyFLP.Controls.Add(this.gyroMousestickXAxisCom); this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickInvertXCk); this.gyroMouseJoyFLP.Controls.Add(this.gyroMouseStickInvertYCk); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMStickUseSmoothCk); + this.gyroMouseJoyFLP.Controls.Add(this.label39); + this.gyroMouseJoyFLP.Controls.Add(this.gyroMStickSmoothWeightNUD); resources.ApplyResources(this.gyroMouseJoyFLP, "gyroMouseJoyFLP"); this.gyroMouseJoyFLP.Name = "gyroMouseJoyFLP"; // @@ -2176,6 +2183,32 @@ 131072}); this.gyroMouseStickAntiDeadY.ValueChanged += new System.EventHandler(this.GyroMouseSStickAntiDeadY_ValueChanged); // + // label37 + // + resources.ApplyResources(this.label37, "label37"); + this.label37.Name = "label37"; + // + // gyroMStickVertScaleNUD + // + resources.ApplyResources(this.gyroMStickVertScaleNUD, "gyroMStickVertScaleNUD"); + this.gyroMStickVertScaleNUD.Maximum = new decimal(new int[] { + 400, + 0, + 0, + 0}); + this.gyroMStickVertScaleNUD.Name = "gyroMStickVertScaleNUD"; + this.gyroMStickVertScaleNUD.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.gyroMStickVertScaleNUD.ValueChanged += new System.EventHandler(this.GyroMStickVertScaleNUD_ValueChanged); + // + // label38 + // + resources.ApplyResources(this.label38, "label38"); + this.label38.Name = "label38"; + // // label35 // resources.ApplyResources(this.label35, "label35"); @@ -4564,31 +4597,34 @@ resources.ApplyResources(this.psTouchInvStripMenuItem, "psTouchInvStripMenuItem"); this.psTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); // - // label37 + // gyroMStickUseSmoothCk // - resources.ApplyResources(this.label37, "label37"); - this.label37.Name = "label37"; + resources.ApplyResources(this.gyroMStickUseSmoothCk, "gyroMStickUseSmoothCk"); + this.gyroMStickUseSmoothCk.Name = "gyroMStickUseSmoothCk"; + this.gyroMStickUseSmoothCk.UseVisualStyleBackColor = true; + this.gyroMStickUseSmoothCk.CheckedChanged += new System.EventHandler(this.GyroMStickUseSmoothCk_CheckedChanged); // - // gyroMStickVertScaleNUD + // gyroMStickSmoothWeightNUD // - resources.ApplyResources(this.gyroMStickVertScaleNUD, "gyroMStickVertScaleNUD"); - this.gyroMStickVertScaleNUD.Maximum = new decimal(new int[] { - 400, + this.gyroMStickSmoothWeightNUD.DecimalPlaces = 3; + resources.ApplyResources(this.gyroMStickSmoothWeightNUD, "gyroMStickSmoothWeightNUD"); + this.gyroMStickSmoothWeightNUD.Maximum = new decimal(new int[] { + 1, 0, 0, 0}); - this.gyroMStickVertScaleNUD.Name = "gyroMStickVertScaleNUD"; - this.gyroMStickVertScaleNUD.Value = new decimal(new int[] { - 100, + this.gyroMStickSmoothWeightNUD.Name = "gyroMStickSmoothWeightNUD"; + this.gyroMStickSmoothWeightNUD.Value = new decimal(new int[] { + 5, 0, 0, - 0}); - this.gyroMStickVertScaleNUD.ValueChanged += new System.EventHandler(this.GyroMStickVertScaleNUD_ValueChanged); + 65536}); + this.gyroMStickSmoothWeightNUD.ValueChanged += new System.EventHandler(this.GyroMStickSmoothWeightNUD_ValueChanged); // - // label38 + // label39 // - resources.ApplyResources(this.label38, "label38"); - this.label38.Name = "label38"; + resources.ApplyResources(this.label39, "label39"); + this.label39.Name = "label39"; // // Options // @@ -4664,6 +4700,7 @@ ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickMaxZ)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadX)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gyroMouseStickAntiDeadY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMStickVertScaleNUD)).EndInit(); this.tCControls.ResumeLayout(false); this.tPControls.ResumeLayout(false); this.pnlController.ResumeLayout(false); @@ -4723,7 +4760,7 @@ ((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit(); this.cMGyroTriggers.ResumeLayout(false); this.cMTouchDisableInvert.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.gyroMStickVertScaleNUD)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.gyroMStickSmoothWeightNUD)).EndInit(); this.ResumeLayout(false); } @@ -5129,5 +5166,8 @@ private System.Windows.Forms.Label label37; private System.Windows.Forms.NumericUpDown gyroMStickVertScaleNUD; private System.Windows.Forms.Label label38; + private System.Windows.Forms.CheckBox gyroMStickUseSmoothCk; + private System.Windows.Forms.Label label39; + private System.Windows.Forms.NumericUpDown gyroMStickSmoothWeightNUD; } } \ No newline at end of file diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 53f0fc6..55a7579 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -816,6 +816,9 @@ namespace DS4Windows.Forms gyroMouseStickInvertYCk.Checked = (gyroMouseStickInfo.inverted & 2) == 2; gyroMStickToggleCk.Checked = GyroMouseStickToggle[device]; gyroMStickVertScaleNUD.Value = gyroMouseStickInfo.vertScale; + gyroMStickUseSmoothCk.Checked = gyroMouseStickInfo.useSmoothing; + gyroMStickSmoothWeightNUD.Enabled = gyroMouseStickInfo.useSmoothing; + gyroMStickSmoothWeightNUD.Value = (decimal)gyroMouseStickInfo.smoothWeight; } else { @@ -962,6 +965,9 @@ namespace DS4Windows.Forms gyroMStickTrigBehaveCk.Checked = false; gyroMStickToggleCk.Checked = false; gyroMStickVertScaleNUD.Value = 100; + gyroMStickUseSmoothCk.Checked = false; + gyroMStickSmoothWeightNUD.Enabled = false; + gyroMStickSmoothWeightNUD.Value = 0.5m; Set(); } @@ -1555,25 +1561,29 @@ namespace DS4Windows.Forms SetSaMouseStickTriggerCond(device, gyroMouseStickEvalCombo.SelectedItem.ToString().ToLower()); + + GyroMouseStickInfo gyroMouseStickInfo = GyroMouseStickInf[device]; if (GyroMouseStickDead()) { - GyroMouseStickInf[device].deadZone = (int)gyroMouseStickDZ.Value; - GyroMouseStickInf[device].maxZone = (int)gyroMouseStickMaxZ.Value; + gyroMouseStickInfo.deadZone = (int)gyroMouseStickDZ.Value; + gyroMouseStickInfo.maxZone = (int)gyroMouseStickMaxZ.Value; } else { - GyroMouseStickInf[device].deadZone = (int)gyroMouseStickMaxZ.Value; - GyroMouseStickInf[device].maxZone = (int)gyroMouseStickMaxZ.Value; + gyroMouseStickInfo.deadZone = (int)gyroMouseStickMaxZ.Value; + gyroMouseStickInfo.maxZone = (int)gyroMouseStickMaxZ.Value; } - - GyroMouseStickInf[device].antiDeadX = (double)gyroMouseStickAntiDeadX.Value; - GyroMouseStickInf[device].antiDeadY = (double)gyroMouseStickAntiDeadY.Value; + + gyroMouseStickInfo.antiDeadX = (double)gyroMouseStickAntiDeadX.Value; + gyroMouseStickInfo.antiDeadY = (double)gyroMouseStickAntiDeadY.Value; GyroMouseStickHorizontalAxis[device] = gyroMousestickXAxisCom.SelectedIndex; uint tempInvert = 0; if (gyroMouseStickInvertXCk.Checked) tempInvert |= 1 << 0; if (gyroMouseStickInvertYCk.Checked) tempInvert |= 1 << 1; - GyroMouseStickInf[device].inverted = tempInvert; - GyroMouseStickInf[device].vertScale = (int)gyroMStickVertScaleNUD.Value; + gyroMouseStickInfo.inverted = tempInvert; + gyroMouseStickInfo.vertScale = (int)gyroMStickVertScaleNUD.Value; + gyroMouseStickInfo.useSmoothing = gyroMStickUseSmoothCk.Checked; + gyroMouseStickInfo.smoothWeight = (double)gyroMStickSmoothWeightNUD.Value; } private void Show_ControlsBtn(object sender, EventArgs e) @@ -3696,6 +3706,26 @@ namespace DS4Windows.Forms } } + private void GyroMStickSmoothWeightNUD_ValueChanged(object sender, EventArgs e) + { + if (loading == false) + { + GyroMouseStickInf[device].smoothWeight = + (double)gyroMStickSmoothWeightNUD.Value; + } + } + + private void GyroMStickUseSmoothCk_CheckedChanged(object sender, EventArgs e) + { + if (loading == false) + { + GyroMouseStickInf[device].useSmoothing = + gyroMStickUseSmoothCk.Checked; + gyroMStickSmoothWeightNUD.Enabled = + GyroMouseStickInf[device].useSmoothing; + } + } + private void trackFrictionNUD_ValueChanged(object sender, EventArgs e) { if (loading == false) diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index c61a9ee..3cc9b88 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -4936,7 +4936,7 @@ 6, 47 - 271, 195 + 271, 199 254 @@ -5865,17 +5865,14 @@ 18 - - True - 3, 160 - Yes + No - 63, 17 + 96, 17 11 @@ -5895,17 +5892,14 @@ 19 - - True - - 72, 160 + 105, 160 - Yes + No - 63, 17 + 127, 17 12 @@ -5925,11 +5919,89 @@ 20 + + True + + + 3, 183 + + + Yes + + + 76, 17 + + + 283 + + + Smoothing + + + gyroMStickUseSmoothCk + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 21 + + + 85, 180 + + + 60, 23 + + + 285 + + + Weight: + + + MiddleCenter + + + label39 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 22 + + + 151, 183 + + + 72, 20 + + + 284 + + + gyroMStickSmoothWeightNUD + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gyroMouseJoyFLP + + + 23 + 8, 47 - 252, 181 + 252, 210 260