Added toggle option for Gyro Mouse activation

Not sure about this feature tbh. Related to issue #464.
This commit is contained in:
Travis Nickles 2019-02-06 21:42:34 -06:00
parent 09103dcea8
commit ce87d8c212
5 changed files with 801 additions and 3495 deletions

View File

@ -58,8 +58,18 @@ namespace DS4Windows
trackballAccel = TRACKBALL_RADIUS * friction / TRACKBALL_INERTIA;
}
public void ResetToggleGyroM()
{
currentToggleGyroM = false;
}
bool triggeractivated = false;
bool previousTriggerActivated = false;
bool useReverseRatchet = false;
bool toggleGyroMouse = true;
public bool ToggleGyroMouse { get => toggleGyroMouse;
set { toggleGyroMouse = value; ResetToggleGyroM(); } }
bool currentToggleGyroM = false;
public virtual void sixaxisMoved(object sender, SixAxisEventArgs arg)
{
@ -91,6 +101,21 @@ namespace DS4Windows
}
}
if (toggleGyroMouse)
{
if (triggeractivated && triggeractivated != previousTriggerActivated)
{
currentToggleGyroM = !currentToggleGyroM;
}
previousTriggerActivated = triggeractivated;
triggeractivated = currentToggleGyroM;
}
else
{
previousTriggerActivated = triggeractivated;
}
if (useReverseRatchet && triggeractivated)
cursor.sixaxisMoved(arg);
else if (!useReverseRatchet && !triggeractivated)

View File

@ -789,6 +789,10 @@ namespace DS4Windows
m_Config.SetGyroMouseDZ(index, value, control);
}
public static bool[] GyroMouseToggle => m_Config.gyroMouseToggle;
public static void SetGyroMouseToggle(int index, bool value, ControlService control)
=> m_Config.SetGyroMouseToggle(index, value, control);
public static DS4Color[] MainColor => m_Config.m_Leds;
public static DS4Color getMainColor(int index)
{
@ -1451,6 +1455,8 @@ namespace DS4Windows
public int[] gyroMouseDZ = new int[5] { MouseCursor.GYRO_MOUSE_DEADZONE, MouseCursor.GYRO_MOUSE_DEADZONE,
MouseCursor.GYRO_MOUSE_DEADZONE, MouseCursor.GYRO_MOUSE_DEADZONE,
MouseCursor.GYRO_MOUSE_DEADZONE };
public bool[] gyroMouseToggle = new bool[5] { false, false, false,
false, false };
public int[] lsOutCurveMode = new int[5] { 0, 0, 0, 0, 0 };
public int[] rsOutCurveMode = new int[5] { 0, 0, 0, 0, 0 };
public int[] l2OutCurveMode = new int[5] { 0, 0, 0, 0, 0 };
@ -1677,6 +1683,13 @@ namespace DS4Windows
control.touchPad[index].CursorGyroDead = value;
}
public void SetGyroMouseToggle(int index, bool value, ControlService control)
{
gyroMouseToggle[index] = value;
if (index < 4 && control.touchPad[index] != null)
control.touchPad[index].ToggleGyroMouse = value;
}
public bool SaveProfile(int device, string propath)
{
bool Saved = true;
@ -1779,6 +1792,7 @@ namespace DS4Windows
XmlNode xmlGyroSmoothing = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSmoothing", null); xmlGyroSmoothing.InnerText = gyroSmoothing[device].ToString(); Node.AppendChild(xmlGyroSmoothing);
XmlNode xmlGyroMouseHAxis = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseHAxis", null); xmlGyroMouseHAxis.InnerText = gyroMouseHorizontalAxis[device].ToString(); Node.AppendChild(xmlGyroMouseHAxis);
XmlNode xmlGyroMouseDZ = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseDeadZone", null); xmlGyroMouseDZ.InnerText = gyroMouseDZ[device].ToString(); Node.AppendChild(xmlGyroMouseDZ);
XmlNode xmlGyroMouseToggle = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroMouseToggle", null); xmlGyroMouseToggle.InnerText = gyroMouseToggle[device].ToString(); Node.AppendChild(xmlGyroMouseToggle);
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);
XmlNode xmlProfileActions = m_Xdoc.CreateNode(XmlNodeType.Element, "ProfileActions", null); xmlProfileActions.InnerText = string.Join("/", profileActions[device]); Node.AppendChild(xmlProfileActions);
@ -2682,6 +2696,13 @@ namespace DS4Windows
SetGyroMouseDZ(device, temp, control); }
catch { SetGyroMouseDZ(device, MouseCursor.GYRO_MOUSE_DEADZONE, control); missingSetting = true; }
try
{
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseToggle"); bool.TryParse(Item.InnerText, out bool temp);
SetGyroMouseToggle(device, temp, control);
}
catch { SetGyroMouseToggle(device, false, control); missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSCurve"); int.TryParse(Item.InnerText, out lsCurve[device]); }
catch { lsCurve[device] = 0; missingSetting = true; }

View File

@ -315,6 +315,7 @@
this.rBSAControls = new System.Windows.Forms.RadioButton();
this.rBSAMouse = new System.Windows.Forms.RadioButton();
this.pnlSAMouse = new System.Windows.Forms.Panel();
this.toggleGyroMCb = new System.Windows.Forms.CheckBox();
this.label27 = new System.Windows.Forms.Label();
this.gyroMouseDzNUD = new System.Windows.Forms.NumericUpDown();
this.label26 = new System.Windows.Forms.Label();
@ -3395,6 +3396,7 @@
//
// pnlSAMouse
//
this.pnlSAMouse.Controls.Add(this.toggleGyroMCb);
this.pnlSAMouse.Controls.Add(this.label27);
this.pnlSAMouse.Controls.Add(this.gyroMouseDzNUD);
this.pnlSAMouse.Controls.Add(this.label26);
@ -3419,6 +3421,13 @@
resources.ApplyResources(this.pnlSAMouse, "pnlSAMouse");
this.pnlSAMouse.Name = "pnlSAMouse";
//
// toggleGyroMCb
//
resources.ApplyResources(this.toggleGyroMCb, "toggleGyroMCb");
this.toggleGyroMCb.Name = "toggleGyroMCb";
this.toggleGyroMCb.UseVisualStyleBackColor = true;
this.toggleGyroMCb.Click += new System.EventHandler(this.toggleGyroMCb_Click);
//
// label27
//
resources.ApplyResources(this.label27, "label27");
@ -4644,5 +4653,6 @@
private System.Windows.Forms.ComboBox triggerCondAndCombo;
private System.Windows.Forms.Label label27;
private System.Windows.Forms.NumericUpDown gyroMouseDzNUD;
private System.Windows.Forms.CheckBox toggleGyroMCb;
}
}

View File

@ -719,6 +719,7 @@ namespace DS4Windows
cBGyroMouseXAxis.SelectedIndex = GyroMouseHorizontalAxis[device];
triggerCondAndCombo.SelectedIndex = SATriggerCond[device] ? 0 : 1;
gyroMouseDzNUD.Value = GyroMouseDeadZone[device];
toggleGyroMCb.Checked = GyroMouseToggle[device];
}
else
{
@ -836,6 +837,7 @@ namespace DS4Windows
cBGyroSmooth.Checked = false;
nUDGyroSmoothWeight.Value = 0.5m;
gyroMouseDzNUD.Value = MouseCursor.GYRO_MOUSE_DEADZONE;
toggleGyroMCb.Checked = false;
cBGyroMouseXAxis.SelectedIndex = 0;
triggerCondAndCombo.SelectedIndex = 0;
Set();
@ -1337,6 +1339,7 @@ namespace DS4Windows
GyroSmoothingWeight[device] = (double)nUDGyroSmoothWeight.Value;
GyroMouseHorizontalAxis[device] = cBGyroMouseXAxis.SelectedIndex;
SetGyroMouseDeadZone(device, (int)gyroMouseDzNUD.Value, Program.rootHub);
SetGyroMouseToggle(device, toggleGyroMCb.Checked, Program.rootHub);
int invert = 0;
if (cBGyroInvertX.Checked)
@ -2817,6 +2820,8 @@ namespace DS4Windows
if (!loading)
{
GyroTriggerTurns[device] = gyroTriggerBehavior.Checked;
if (device < 4)
Program.rootHub.touchPad[device]?.ResetToggleGyroM();
}
}
@ -3001,6 +3006,17 @@ namespace DS4Windows
}
}
private void toggleGyroMCb_Click(object sender, EventArgs e)
{
if (loading == false)
{
if (device < 4)
{
SetGyroMouseToggle(device, toggleGyroMCb.Checked, Program.rootHub);
}
}
}
private void trackFrictionNUD_ValueChanged(object sender, EventArgs e)
{
if (loading == false)

File diff suppressed because it is too large Load Diff