diff --git a/DS4Windows/DS4Control/Mouse.cs b/DS4Windows/DS4Control/Mouse.cs index 126eeb5..23d2057 100644 --- a/DS4Windows/DS4Control/Mouse.cs +++ b/DS4Windows/DS4Control/Mouse.cs @@ -66,20 +66,26 @@ namespace DS4Windows { s = dev.getCurrentStateRef(); - triggeractivated = true; useReverseRatchet = Global.getGyroTriggerTurns(deviceNum); int i = 0; string[] ss = Global.getSATriggers(deviceNum).Split(','); + bool andCond = Global.getSATriggerCond(deviceNum); + triggeractivated = andCond ? true : false; if (!string.IsNullOrEmpty(ss[0])) { string s = string.Empty; - for (int index = 0, arlen = ss.Length; - triggeractivated && index < arlen; index++) + for (int index = 0, arlen = ss.Length; index < arlen; index++) { s = ss[index]; - if (!(int.TryParse(s, out i) && getDS4ControlsByName(i))) + 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; } } } diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index b968a33..380a2ed 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -707,6 +707,16 @@ namespace DS4Windows return m_Config.sATriggers[index]; } + public static bool[] SATriggerCond => m_Config.sATriggerCond; + public static bool getSATriggerCond(int index) + { + return m_Config.sATriggerCond[index]; + } + public static void SetSaTriggerCond(int index, string text) + { + m_Config.SetSaTriggerCond(index, text); + } + public static int[][] TouchDisInvertTriggers => m_Config.touchDisInvertTriggers; public static int[] getTouchDisInvertTriggers(int index) { @@ -1470,6 +1480,7 @@ namespace DS4Windows public bool[] useTPforControls = new bool[5] { false, false, false, false, false }; public bool[] useSAforMouse = new bool[5] { false, false, false, false, false }; public string[] sATriggers = 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 int[][] touchDisInvertTriggers = new int[5][] { new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 }, new int[1] { -1 } }; public int[] lsCurve = new int[5] { 0, 0, 0, 0, 0 }; @@ -1604,6 +1615,30 @@ namespace DS4Windows return id; } + private bool SaTriggerCondValue(string text) + { + bool result = true; + switch (text) + { + case "and": result = true; break; + case "or": result = false; break; + default: result = true; break; + } + + return result; + } + + private string SaTriggerCondString(bool value) + { + string result = value ? "and" : "or"; + return result; + } + + public void SetSaTriggerCond(int index, string text) + { + sATriggerCond[index] = SaTriggerCondValue(text); + } + public bool SaveProfile(int device, string propath) { bool Saved = true; @@ -1691,6 +1726,7 @@ namespace DS4Windows XmlNode xmlUseTPforControls = m_Xdoc.CreateNode(XmlNodeType.Element, "UseTPforControls", null); xmlUseTPforControls.InnerText = useTPforControls[device].ToString(); Node.AppendChild(xmlUseTPforControls); XmlNode xmlUseSAforMouse = m_Xdoc.CreateNode(XmlNodeType.Element, "UseSAforMouse", null); xmlUseSAforMouse.InnerText = useSAforMouse[device].ToString(); Node.AppendChild(xmlUseSAforMouse); XmlNode xmlSATriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "SATriggers", null); xmlSATriggers.InnerText = sATriggers[device].ToString(); Node.AppendChild(xmlSATriggers); + XmlNode xmlSATriggerCond = m_Xdoc.CreateNode(XmlNodeType.Element, "SATriggerCond", null); xmlSATriggerCond.InnerText = SaTriggerCondString(sATriggerCond[device]); Node.AppendChild(xmlSATriggerCond); XmlNode xmlTouchDisInvTriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "TouchDisInvTriggers", null); string tempTouchDisInv = string.Join(",", touchDisInvertTriggers[device]); @@ -2571,6 +2607,9 @@ namespace DS4Windows try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SATriggers"); sATriggers[device] = Item.InnerText; } catch { sATriggers[device] = ""; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SATriggerCond"); sATriggerCond[device] = SaTriggerCondValue(Item.InnerText); } + catch { sATriggerCond[device] = true; missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/TouchDisInvTriggers"); string[] triggers = Item.InnerText.Split(','); @@ -3747,6 +3786,7 @@ namespace DS4Windows useTPforControls[device] = false; useSAforMouse[device] = false; sATriggers[device] = string.Empty; + sATriggerCond[device] = true; touchDisInvertTriggers[device] = new int[1] { -1 }; lsCurve[device] = rsCurve[device] = 0; gyroSensitivity[device] = 100; diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 68e5189..e9c6dbe 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -398,7 +398,7 @@ namespace DS4Windows } if (btnStartStop.Enabled && start) - TaskRunner.Delay(10).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); + TaskRunner.Delay(50).ContinueWith((t) => this.BeginInvoke((System.Action)(() => BtnStartStop_Clicked()))); } private void populateHoverTextDict() diff --git a/DS4Windows/DS4Forms/Options.Designer.cs b/DS4Windows/DS4Forms/Options.Designer.cs index 6c5bedb..cd9742a 100644 --- a/DS4Windows/DS4Forms/Options.Designer.cs +++ b/DS4Windows/DS4Forms/Options.Designer.cs @@ -386,6 +386,8 @@ this.optionsTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shareTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.psTouchInvStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.triggerCondAndCombo = new System.Windows.Forms.ComboBox(); + this.label26 = new System.Windows.Forms.Label(); this.advColorDialog = new DS4Windows.AdvancedColorDialog(); ((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit(); @@ -3360,8 +3362,8 @@ this.gBGyro.BackColor = System.Drawing.SystemColors.Control; this.gBGyro.Controls.Add(this.rBSAControls); this.gBGyro.Controls.Add(this.rBSAMouse); - this.gBGyro.Controls.Add(this.fLPTiltControls); this.gBGyro.Controls.Add(this.pnlSAMouse); + this.gBGyro.Controls.Add(this.fLPTiltControls); resources.ApplyResources(this.gBGyro, "gBGyro"); this.gBGyro.Name = "gBGyro"; this.gBGyro.TabStop = false; @@ -3384,6 +3386,8 @@ // // pnlSAMouse // + this.pnlSAMouse.Controls.Add(this.label26); + this.pnlSAMouse.Controls.Add(this.triggerCondAndCombo); this.pnlSAMouse.Controls.Add(this.cBGyroMouseXAxis); this.pnlSAMouse.Controls.Add(this.label16); this.pnlSAMouse.Controls.Add(this.lbGyroSmooth); @@ -4106,6 +4110,21 @@ resources.ApplyResources(this.psTouchInvStripMenuItem, "psTouchInvStripMenuItem"); this.psTouchInvStripMenuItem.CheckedChanged += new System.EventHandler(this.TouchDisableInvert_CheckedChanged); // + // triggerCondAndCombo + // + this.triggerCondAndCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.triggerCondAndCombo.FormattingEnabled = true; + this.triggerCondAndCombo.Items.AddRange(new object[] { + resources.GetString("triggerCondAndCombo.Items"), + resources.GetString("triggerCondAndCombo.Items1")}); + resources.ApplyResources(this.triggerCondAndCombo, "triggerCondAndCombo"); + this.triggerCondAndCombo.Name = "triggerCondAndCombo"; + // + // label26 + // + resources.ApplyResources(this.label26, "label26"); + this.label26.Name = "label26"; + // // Options // resources.ApplyResources(this, "$this"); @@ -4593,5 +4612,7 @@ private System.Windows.Forms.Label trackFrictionLb; private System.Windows.Forms.NumericUpDown trackFrictionNUD; private System.Windows.Forms.CheckBox trackballCk; + private System.Windows.Forms.Label label26; + private System.Windows.Forms.ComboBox triggerCondAndCombo; } } \ No newline at end of file diff --git a/DS4Windows/DS4Forms/Options.cs b/DS4Windows/DS4Forms/Options.cs index 6fe5f3d..7c9aa91 100644 --- a/DS4Windows/DS4Forms/Options.cs +++ b/DS4Windows/DS4Forms/Options.cs @@ -126,6 +126,8 @@ namespace DS4Windows sixaxisTimer.Tick += ControllerReadout_Tick; sixaxisTimer.Interval = 1000 / 60; + triggerCondAndCombo.SelectedIndexChanged += TriggerCondAndCombo_SelectedIndexChanged; + bnGyroZN.Text = Properties.Resources.TiltUp; bnGyroZP.Text = Properties.Resources.TiltDown; bnGyroXP.Text = Properties.Resources.TiltLeft; @@ -142,6 +144,15 @@ namespace DS4Windows populateHoverLabelDict(); } + private void TriggerCondAndCombo_SelectedIndexChanged(object sender, EventArgs e) + { + if (!loading) + { + string temp = triggerCondAndCombo.SelectedItem.ToString().ToLower(); + SetSaTriggerCond(device, triggerCondAndCombo.SelectedItem.ToString().ToLower()); + } + } + public void SetFlowAutoScroll() { fLPSettings.AutoScroll = false; @@ -706,6 +717,7 @@ namespace DS4Windows cBGyroSmooth.Checked = nUDGyroSmoothWeight.Enabled = GyroSmoothing[device]; nUDGyroSmoothWeight.Value = (decimal)(GyroSmoothingWeight[device]); cBGyroMouseXAxis.SelectedIndex = GyroMouseHorizontalAxis[device]; + triggerCondAndCombo.SelectedIndex = SATriggerCond[device] ? 0 : 1; } else { @@ -823,6 +835,7 @@ namespace DS4Windows cBGyroSmooth.Checked = false; nUDGyroSmoothWeight.Value = 0.5m; cBGyroMouseXAxis.SelectedIndex = 0; + triggerCondAndCombo.SelectedIndex = 0; Set(); } @@ -1342,6 +1355,7 @@ namespace DS4Windows ints.Add(-1); SATriggers[device] = string.Join(",", ints); + SetSaTriggerCond(device, triggerCondAndCombo.SelectedItem.ToString().ToLower()); ints.Clear(); for (int i = 0, trigLen = cMTouchDisableInvert.Items.Count; i < trigLen; i++) diff --git a/DS4Windows/DS4Forms/Options.resx b/DS4Windows/DS4Forms/Options.resx index 5ab8b82..dc50f18 100644 --- a/DS4Windows/DS4Forms/Options.resx +++ b/DS4Windows/DS4Forms/Options.resx @@ -4058,7 +4058,7 @@ with profile 7 - 6, 51 + 4, 43 271, 167 @@ -4076,7 +4076,7 @@ with profile gBGyro - 2 + 3 True @@ -7717,6 +7717,63 @@ with profile 1 + + True + + + NoControl + + + 184, 43 + + + 59, 13 + + + 273 + + + Eval Cond: + + + label26 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pnlSAMouse + + + 0 + + + And + + + Or + + + 165, 67 + + + 73, 21 + + + 272 + + + triggerCondAndCombo + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pnlSAMouse + + + 1 + Yaw @@ -7724,7 +7781,7 @@ with profile Roll - 170, 93 + 170, 114 74, 21 @@ -7742,7 +7799,7 @@ with profile pnlSAMouse - 0 + 2 True @@ -7751,7 +7808,7 @@ with profile NoControl - 167, 74 + 167, 95 39, 13 @@ -7772,7 +7829,7 @@ with profile pnlSAMouse - 1 + 3 True @@ -7802,7 +7859,7 @@ with profile pnlSAMouse - 2 + 4 True @@ -7832,7 +7889,7 @@ with profile pnlSAMouse - 3 + 5 True @@ -7862,7 +7919,7 @@ with profile pnlSAMouse - 4 + 6 False @@ -7886,7 +7943,7 @@ with profile pnlSAMouse - 5 + 7 True @@ -7916,7 +7973,7 @@ with profile pnlSAMouse - 6 + 8 96, 93 @@ -7937,7 +7994,7 @@ with profile pnlSAMouse - 7 + 9 True @@ -7967,7 +8024,7 @@ with profile pnlSAMouse - 8 + 10 True @@ -8000,7 +8057,7 @@ with profile pnlSAMouse - 9 + 11 True @@ -8033,7 +8090,7 @@ with profile pnlSAMouse - 10 + 12 True @@ -8066,7 +8123,7 @@ with profile pnlSAMouse - 11 + 13 True @@ -8099,7 +8156,7 @@ with profile pnlSAMouse - 12 + 14 True @@ -8132,7 +8189,7 @@ with profile pnlSAMouse - 13 + 15 NoControl @@ -8162,7 +8219,7 @@ with profile pnlSAMouse - 14 + 16 96, 67 @@ -8183,7 +8240,7 @@ with profile pnlSAMouse - 15 + 17 True @@ -8216,7 +8273,7 @@ with profile pnlSAMouse - 16 + 18 6, 43 @@ -8240,7 +8297,7 @@ with profile gBGyro - 3 + 2 3, 253 @@ -8914,6 +8971,9 @@ with profile 1011, 481 + + NoControl + 4, 4, 4, 4 @@ -9332,7 +9392,7 @@ with profile advColorDialog - DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null + DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.8.0, Culture=neutral, PublicKeyToken=null Options