Make hotkey execution an optional profile setting.

Related to issue #21
This commit is contained in:
Travis Nickles 2017-04-26 12:43:01 -07:00
parent de0e9a88cb
commit 4a159d4216
5 changed files with 762 additions and 2728 deletions

View File

@ -576,10 +576,15 @@ namespace DS4Windows
DS4State pState = PreviousState[ind];
if (pState.Battery != cState.Battery)
{
OnBatteryStatusChange(this, ind, cState.Battery);
//ControllerStatusChanged(this);
}
CheckForHotkeys(ind, cState, pState);
if (getEnableHotkeys(ind))
{
CheckForHotkeys(ind, cState, pState);
}
// Temporarily disable easter time routine
//if (eastertime)
@ -1010,7 +1015,7 @@ namespace DS4Windows
}
}
else
touchreleased[deviceID] = true;
touchreleased[deviceID] = true;
}
public virtual void StartTPOff(int deviceID)

View File

@ -393,6 +393,11 @@ namespace DS4Windows
{
return m_Config.flushHIDQueue[index];
}
public static bool[] EnableHotkeys => m_Config.enableHotkeys;
public static bool getEnableHotkeys(int index)
{
return m_Config.enableHotkeys[index];
}
public static int[] IdleDisconnectTimeout => m_Config.idleDisconnectTimeout;
public static int getIdleDisconnectTimeout(int index)
{
@ -872,6 +877,7 @@ namespace DS4Windows
public int[] buttonMouseSensitivity = { 25, 25, 25, 25, 25 };
public bool[] flushHIDQueue = { false, false, false, false, false };
public bool[] enableHotkeys = { true, true, true, true, true };
public int[] idleDisconnectTimeout = { 0, 0, 0, 0, 0 };
public Boolean[] touchpadJitterCompensation = { true, true, true, true, true };
public Boolean[] lowerRCOn = { false, false, false, false, false };
@ -1107,6 +1113,7 @@ namespace DS4Windows
Node = m_Xdoc.CreateNode(XmlNodeType.Element, "DS4Windows", null);
XmlNode xmlFlushHIDQueue = m_Xdoc.CreateNode(XmlNodeType.Element, "flushHIDQueue", null); xmlFlushHIDQueue.InnerText = flushHIDQueue[device].ToString(); Node.AppendChild(xmlFlushHIDQueue);
XmlNode xmlEnableHotkeys = m_Xdoc.CreateNode(XmlNodeType.Element, "enableHotkeys", null); xmlEnableHotkeys.InnerText = enableHotkeys[device].ToString(); Node.AppendChild(xmlEnableHotkeys);
XmlNode xmlIdleDisconnectTimeout = m_Xdoc.CreateNode(XmlNodeType.Element, "idleDisconnectTimeout", null); xmlIdleDisconnectTimeout.InnerText = idleDisconnectTimeout[device].ToString(); Node.AppendChild(xmlIdleDisconnectTimeout);
XmlNode xmlColor = m_Xdoc.CreateNode(XmlNodeType.Element, "Color", null);
xmlColor.InnerText = m_Leds[device].red.ToString() + "," + m_Leds[device].green.ToString() + "," + m_Leds[device].blue.ToString();
@ -1705,6 +1712,9 @@ namespace DS4Windows
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/flushHIDQueue"); Boolean.TryParse(Item.InnerText, out flushHIDQueue[device]); }
catch { missingSetting = true; }//rootname = }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/enableHotkeys"); Boolean.TryParse(Item.InnerText, out enableHotkeys[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/idleDisconnectTimeout"); Int32.TryParse(Item.InnerText, out idleDisconnectTimeout[device]); }
catch { missingSetting = true; }
//New method for saving color

View File

@ -312,6 +312,7 @@
this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.advColorDialog = new DS4Windows.AdvancedColorDialog();
this.enableHotkeysCheckbox = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tBGreenBar)).BeginInit();
@ -1147,6 +1148,7 @@
// gBOther
//
this.gBOther.BackColor = System.Drawing.Color.WhiteSmoke;
this.gBOther.Controls.Add(this.enableHotkeysCheckbox);
this.gBOther.Controls.Add(this.cBDinput);
this.gBOther.Controls.Add(this.pBProgram);
this.gBOther.Controls.Add(this.cBLaunchProgram);
@ -3238,6 +3240,13 @@
resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem");
this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged);
//
// enableHotkeysCheckbox
//
resources.ApplyResources(this.enableHotkeysCheckbox, "enableHotkeysCheckbox");
this.enableHotkeysCheckbox.Name = "enableHotkeysCheckbox";
this.enableHotkeysCheckbox.UseVisualStyleBackColor = true;
this.enableHotkeysCheckbox.CheckedChanged += new System.EventHandler(this.enableHotkeysCheckbox_CheckedChanged);
//
// Options
//
resources.ApplyResources(this, "$this");
@ -3632,5 +3641,6 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown nUDL2AntiDead;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.CheckBox enableHotkeysCheckbox;
}
}

View File

@ -214,6 +214,7 @@ namespace DS4Windows
cBTouchpadJitterCompensation.Checked = TouchpadJitterCompensation[device];
cBlowerRCOn.Checked = LowerRCOn[device];
cBFlushHIDQueue.Checked = FlushHIDQueue[device];
enableHotkeysCheckbox.Checked = getEnableHotkeys(device);
nUDIdleDisconnect.Value = Math.Round((decimal)(IdleDisconnectTimeout[device] / 60d), 1);
cBIdleDisconnect.Checked = IdleDisconnectTimeout[device] > 0;
numUDMouseSens.Value = ButtonMouseSensitivity[device];
@ -448,6 +449,7 @@ namespace DS4Windows
cBTouchpadJitterCompensation.Checked = true;
cBlowerRCOn.Checked = false;
cBFlushHIDQueue.Checked = false;
enableHotkeysCheckbox.Checked = true;
nUDIdleDisconnect.Value = 5;
cBIdleDisconnect.Checked = true;
numUDMouseSens.Value = 25;
@ -2433,6 +2435,11 @@ namespace DS4Windows
}
}
private void enableHotkeysCheckbox_CheckedChanged(object sender, EventArgs e)
{
EnableHotkeys[device] = enableHotkeysCheckbox.Checked;
}
private void Options_Resize(object sender, EventArgs e)
{
fLPSettings.AutoScroll = false;

File diff suppressed because it is too large Load Diff