Version of different gyro trigger conditional

Related to issue #431
This commit is contained in:
Travis Nickles 2018-09-29 21:54:25 -05:00
parent 1019499612
commit 3aa558c85f
6 changed files with 170 additions and 29 deletions

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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()

View File

@ -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;
}
}

View File

@ -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++)

View File

@ -4058,7 +4058,7 @@ with profile</value>
<value>7</value>
</data>
<data name="fLPTiltControls.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 51</value>
<value>4, 43</value>
</data>
<data name="fLPTiltControls.Size" type="System.Drawing.Size, System.Drawing">
<value>271, 167</value>
@ -4076,7 +4076,7 @@ with profile</value>
<value>gBGyro</value>
</data>
<data name="&gt;&gt;fLPTiltControls.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="tPControls.AutoScroll" type="System.Boolean, mscorlib">
<value>True</value>
@ -7717,6 +7717,63 @@ with profile</value>
<data name="&gt;&gt;rBSAMouse.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="label26.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label26.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="label26.Location" type="System.Drawing.Point, System.Drawing">
<value>184, 43</value>
</data>
<data name="label26.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 13</value>
</data>
<data name="label26.TabIndex" type="System.Int32, mscorlib">
<value>273</value>
</data>
<data name="label26.Text" xml:space="preserve">
<value>Eval Cond:</value>
</data>
<data name="&gt;&gt;label26.Name" xml:space="preserve">
<value>label26</value>
</data>
<data name="&gt;&gt;label26.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label26.Parent" xml:space="preserve">
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;label26.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="triggerCondAndCombo.Items" xml:space="preserve">
<value>And</value>
</data>
<data name="triggerCondAndCombo.Items1" xml:space="preserve">
<value>Or</value>
</data>
<data name="triggerCondAndCombo.Location" type="System.Drawing.Point, System.Drawing">
<value>165, 67</value>
</data>
<data name="triggerCondAndCombo.Size" type="System.Drawing.Size, System.Drawing">
<value>73, 21</value>
</data>
<data name="triggerCondAndCombo.TabIndex" type="System.Int32, mscorlib">
<value>272</value>
</data>
<data name="&gt;&gt;triggerCondAndCombo.Name" xml:space="preserve">
<value>triggerCondAndCombo</value>
</data>
<data name="&gt;&gt;triggerCondAndCombo.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;triggerCondAndCombo.Parent" xml:space="preserve">
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;triggerCondAndCombo.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="cBGyroMouseXAxis.Items" xml:space="preserve">
<value>Yaw</value>
</data>
@ -7724,7 +7781,7 @@ with profile</value>
<value>Roll</value>
</data>
<data name="cBGyroMouseXAxis.Location" type="System.Drawing.Point, System.Drawing">
<value>170, 93</value>
<value>170, 114</value>
</data>
<data name="cBGyroMouseXAxis.Size" type="System.Drawing.Size, System.Drawing">
<value>74, 21</value>
@ -7742,7 +7799,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;cBGyroMouseXAxis.ZOrder" xml:space="preserve">
<value>0</value>
<value>2</value>
</data>
<data name="label16.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -7751,7 +7808,7 @@ with profile</value>
<value>NoControl</value>
</data>
<data name="label16.Location" type="System.Drawing.Point, System.Drawing">
<value>167, 74</value>
<value>167, 95</value>
</data>
<data name="label16.Size" type="System.Drawing.Size, System.Drawing">
<value>39, 13</value>
@ -7772,7 +7829,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;label16.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="lbGyroSmooth.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -7802,7 +7859,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;lbGyroSmooth.ZOrder" xml:space="preserve">
<value>2</value>
<value>4</value>
</data>
<data name="cBGyroSmooth.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -7832,7 +7889,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;cBGyroSmooth.ZOrder" xml:space="preserve">
<value>3</value>
<value>5</value>
</data>
<data name="lbSmoothWeight.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -7862,7 +7919,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;lbSmoothWeight.ZOrder" xml:space="preserve">
<value>4</value>
<value>6</value>
</data>
<data name="nUDGyroSmoothWeight.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
@ -7886,7 +7943,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;nUDGyroSmoothWeight.ZOrder" xml:space="preserve">
<value>5</value>
<value>7</value>
</data>
<data name="label12.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -7916,7 +7973,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;label12.ZOrder" xml:space="preserve">
<value>6</value>
<value>8</value>
</data>
<data name="nUDGyroMouseVertScale.Location" type="System.Drawing.Point, System.Drawing">
<value>96, 93</value>
@ -7937,7 +7994,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;nUDGyroMouseVertScale.ZOrder" xml:space="preserve">
<value>7</value>
<value>9</value>
</data>
<data name="label11.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -7967,7 +8024,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;label11.ZOrder" xml:space="preserve">
<value>8</value>
<value>10</value>
</data>
<data name="gyroTriggerBehavior.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -8000,7 +8057,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;gyroTriggerBehavior.ZOrder" xml:space="preserve">
<value>9</value>
<value>11</value>
</data>
<data name="cBGyroInvertY.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -8033,7 +8090,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;cBGyroInvertY.ZOrder" xml:space="preserve">
<value>10</value>
<value>12</value>
</data>
<data name="cBGyroInvertX.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -8066,7 +8123,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;cBGyroInvertX.ZOrder" xml:space="preserve">
<value>11</value>
<value>13</value>
</data>
<data name="lbGyroInvert.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -8099,7 +8156,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;lbGyroInvert.ZOrder" xml:space="preserve">
<value>12</value>
<value>14</value>
</data>
<data name="lbGyroTriggers.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -8132,7 +8189,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;lbGyroTriggers.ZOrder" xml:space="preserve">
<value>13</value>
<value>15</value>
</data>
<data name="btnGyroTriggers.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
@ -8162,7 +8219,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;btnGyroTriggers.ZOrder" xml:space="preserve">
<value>14</value>
<value>16</value>
</data>
<data name="nUDGyroSensitivity.Location" type="System.Drawing.Point, System.Drawing">
<value>96, 67</value>
@ -8183,7 +8240,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;nUDGyroSensitivity.ZOrder" xml:space="preserve">
<value>15</value>
<value>17</value>
</data>
<data name="lbGyroSens.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -8216,7 +8273,7 @@ with profile</value>
<value>pnlSAMouse</value>
</data>
<data name="&gt;&gt;lbGyroSens.ZOrder" xml:space="preserve">
<value>16</value>
<value>18</value>
</data>
<data name="pnlSAMouse.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 43</value>
@ -8240,7 +8297,7 @@ with profile</value>
<value>gBGyro</value>
</data>
<data name="&gt;&gt;pnlSAMouse.ZOrder" xml:space="preserve">
<value>3</value>
<value>2</value>
</data>
<data name="gBGyro.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 253</value>
@ -8914,6 +8971,9 @@ with profile</value>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>1011, 481</value>
</data>
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
@ -9332,7 +9392,7 @@ with profile</value>
<value>advColorDialog</value>
</data>
<data name="&gt;&gt;advColorDialog.Type" xml:space="preserve">
<value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>DS4Windows.AdvancedColorDialog, DS4Windows, Version=1.5.8.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>Options</value>