Implemented user defined gyro mouse dead zone

Related to issue #338.
This commit is contained in:
Travis Nickles 2019-01-31 10:59:00 -06:00
parent 4a7e233bd1
commit ff870230a6
7 changed files with 3326 additions and 728 deletions

View File

@ -369,8 +369,9 @@ namespace DS4Windows
{ {
ProfilePath[i] = OlderProfilePath[i]; ProfilePath[i] = OlderProfilePath[i];
} }
LoadProfile(i, false, this, false, false);
touchPad[i] = new Mouse(i, device); touchPad[i] = new Mouse(i, device);
LoadProfile(i, false, this, false, false);
device.LightBarColor = getMainColor(i); device.LightBarColor = getMainColor(i);
if (!getDInputOnly(i) && device.isSynced()) if (!getDInputOnly(i) && device.isSynced())
@ -604,8 +605,8 @@ namespace DS4Windows
ProfilePath[Index] = OlderProfilePath[Index]; ProfilePath[Index] = OlderProfilePath[Index];
} }
LoadProfile(Index, false, this, false, false);
touchPad[Index] = new Mouse(Index, device); touchPad[Index] = new Mouse(Index, device);
LoadProfile(Index, false, this, false, false);
device.LightBarColor = getMainColor(Index); device.LightBarColor = getMainColor(Index);
int tempIdx = Index; int tempIdx = Index;

View File

@ -23,6 +23,7 @@ namespace DS4Windows
public bool priorLeftDown, priorRightDown, priorUpperDown, priorMultiDown; public bool priorLeftDown, priorRightDown, priorUpperDown, priorMultiDown;
protected DS4Controls pushed = DS4Controls.None; protected DS4Controls pushed = DS4Controls.None;
protected Mapping.Click clicked = Mapping.Click.None; protected Mapping.Click clicked = Mapping.Click.None;
public int CursorGyroDead { get => cursor.GyroCursorDeadZone; set => cursor.GyroCursorDeadZone = value; }
internal const int TRACKBALL_INIT_FICTION = 10; internal const int TRACKBALL_INIT_FICTION = 10;
internal const int TRACKBALL_MASS = 45; internal const int TRACKBALL_MASS = 45;
@ -419,6 +420,7 @@ namespace DS4Windows
} }
public bool dragging, dragging2; public bool dragging, dragging2;
private void synthesizeMouseButtons() private void synthesizeMouseButtons()
{ {
if (Global.GetDS4Action(deviceNum, DS4Controls.TouchLeft, false) == null && leftDown) if (Global.GetDS4Action(deviceNum, DS4Controls.TouchLeft, false) == null && leftDown)

View File

@ -21,7 +21,7 @@ namespace DS4Windows
private Direction hDirection = Direction.Neutral, vDirection = Direction.Neutral; private Direction hDirection = Direction.Neutral, vDirection = Direction.Neutral;
private const double GYRO_MOUSE_COEFFICIENT = 0.0095; private const double GYRO_MOUSE_COEFFICIENT = 0.0095;
private const int GYRO_MOUSE_DEADZONE = 10; public const int GYRO_MOUSE_DEADZONE = 10;
private const double GYRO_MOUSE_OFFSET = 0.1463; private const double GYRO_MOUSE_OFFSET = 0.1463;
private const double GYRO_SMOOTH_MOUSE_OFFSET = 0.14698; private const double GYRO_SMOOTH_MOUSE_OFFSET = 0.14698;
private const double TOUCHPAD_MOUSE_OFFSET = 0.015; private const double TOUCHPAD_MOUSE_OFFSET = 0.015;
@ -30,8 +30,9 @@ namespace DS4Windows
private double[] xSmoothBuffer = new double[SMOOTH_BUFFER_LEN]; private double[] xSmoothBuffer = new double[SMOOTH_BUFFER_LEN];
private double[] ySmoothBuffer = new double[SMOOTH_BUFFER_LEN]; private double[] ySmoothBuffer = new double[SMOOTH_BUFFER_LEN];
private int smoothBufferTail = 0; private int smoothBufferTail = 0;
private int gyroCursorDeadZone = GYRO_MOUSE_DEADZONE;
public int GyroCursorDeadZone { get => gyroCursorDeadZone; set => gyroCursorDeadZone = value; }
double coefficient = 0.0; double coefficient = 0.0;
double verticalScale = 0.0; double verticalScale = 0.0;
@ -80,8 +81,8 @@ namespace DS4Windows
vRemainder = 0.0; vRemainder = 0.0;
} }
int deadzoneX = (int)Math.Abs(normX * GYRO_MOUSE_DEADZONE); int deadzoneX = (int)Math.Abs(normX * gyroCursorDeadZone);
int deadzoneY = (int)Math.Abs(normY * GYRO_MOUSE_DEADZONE); int deadzoneY = (int)Math.Abs(normY * gyroCursorDeadZone);
if (Math.Abs(deltaX) > deadzoneX) if (Math.Abs(deltaX) > deadzoneX)
{ {

View File

@ -778,6 +778,17 @@ namespace DS4Windows
return m_Config.gyroMouseHorizontalAxis[index]; return m_Config.gyroMouseHorizontalAxis[index];
} }
public static int[] GyroMouseDeadZone => m_Config.gyroMouseDZ;
public static int GetGyroMouseDeadZone(int index)
{
return m_Config.gyroMouseDZ[index];
}
public static void SetGyroMouseDeadZone(int index, int value, ControlService control)
{
m_Config.SetGyroMouseDZ(index, value, control);
}
public static DS4Color[] MainColor => m_Config.m_Leds; public static DS4Color[] MainColor => m_Config.m_Leds;
public static DS4Color getMainColor(int index) public static DS4Color getMainColor(int index)
{ {
@ -1437,6 +1448,9 @@ namespace DS4Windows
public int[] flashAt = new int[5] { 0, 0, 0, 0, 0 }; public int[] flashAt = new int[5] { 0, 0, 0, 0, 0 };
public bool[] mouseAccel = new bool[5] { true, true, true, true, true }; public bool[] mouseAccel = new bool[5] { true, true, true, true, true };
public int[] btPollRate = new int[5] { 4, 4, 4, 4, 4 }; public int[] btPollRate = new int[5] { 4, 4, 4, 4, 4 };
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 int[] lsOutCurveMode = new int[5] { 0, 0, 0, 0, 0 }; public int[] lsOutCurveMode = new int[5] { 0, 0, 0, 0, 0 };
public int[] rsOutCurveMode = 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 }; public int[] l2OutCurveMode = new int[5] { 0, 0, 0, 0, 0 };
@ -1656,6 +1670,13 @@ namespace DS4Windows
sATriggerCond[index] = SaTriggerCondValue(text); sATriggerCond[index] = SaTriggerCondValue(text);
} }
public void SetGyroMouseDZ(int index, int value, ControlService control)
{
gyroMouseDZ[index] = value;
if (index < 4 && control.touchPad[index] != null)
control.touchPad[index].CursorGyroDead = value;
}
public bool SaveProfile(int device, string propath) public bool SaveProfile(int device, string propath)
{ {
bool Saved = true; bool Saved = true;
@ -1757,6 +1778,7 @@ namespace DS4Windows
XmlNode xmlGyroSmoothWeight = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSmoothingWeight", null); xmlGyroSmoothWeight.InnerText = Convert.ToInt32(gyroSmoothWeight[device] * 100).ToString(); Node.AppendChild(xmlGyroSmoothWeight); XmlNode xmlGyroSmoothWeight = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSmoothingWeight", null); xmlGyroSmoothWeight.InnerText = Convert.ToInt32(gyroSmoothWeight[device] * 100).ToString(); Node.AppendChild(xmlGyroSmoothWeight);
XmlNode xmlGyroSmoothing = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSmoothing", null); xmlGyroSmoothing.InnerText = gyroSmoothing[device].ToString(); Node.AppendChild(xmlGyroSmoothing); 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 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 xmlLSC = m_Xdoc.CreateNode(XmlNodeType.Element, "LSCurve", null); xmlLSC.InnerText = lsCurve[device].ToString(); Node.AppendChild(xmlLSC); 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 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); XmlNode xmlProfileActions = m_Xdoc.CreateNode(XmlNodeType.Element, "ProfileActions", null); xmlProfileActions.InnerText = string.Join("/", profileActions[device]); Node.AppendChild(xmlProfileActions);
@ -2656,6 +2678,10 @@ namespace DS4Windows
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseHAxis"); int temp = 0; int.TryParse(Item.InnerText, out temp); gyroMouseHorizontalAxis[device] = Math.Min(Math.Max(0, temp), 1); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseHAxis"); int temp = 0; int.TryParse(Item.InnerText, out temp); gyroMouseHorizontalAxis[device] = Math.Min(Math.Max(0, temp), 1); }
catch { gyroMouseHorizontalAxis[device] = 0; missingSetting = true; } catch { gyroMouseHorizontalAxis[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroMouseDeadZone"); int.TryParse(Item.InnerText, out int temp);
SetGyroMouseDZ(device, temp, control); }
catch { SetGyroMouseDZ(device, MouseCursor.GYRO_MOUSE_DEADZONE, control); missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSCurve"); int.TryParse(Item.InnerText, out lsCurve[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSCurve"); int.TryParse(Item.InnerText, out lsCurve[device]); }
catch { lsCurve[device] = 0; missingSetting = true; } catch { lsCurve[device] = 0; missingSetting = true; }

View File

@ -315,6 +315,8 @@
this.rBSAControls = new System.Windows.Forms.RadioButton(); this.rBSAControls = new System.Windows.Forms.RadioButton();
this.rBSAMouse = new System.Windows.Forms.RadioButton(); this.rBSAMouse = new System.Windows.Forms.RadioButton();
this.pnlSAMouse = new System.Windows.Forms.Panel(); this.pnlSAMouse = new System.Windows.Forms.Panel();
this.label27 = new System.Windows.Forms.Label();
this.gyroMouseDzNUD = new System.Windows.Forms.NumericUpDown();
this.label26 = new System.Windows.Forms.Label(); this.label26 = new System.Windows.Forms.Label();
this.triggerCondAndCombo = new System.Windows.Forms.ComboBox(); this.triggerCondAndCombo = new System.Windows.Forms.ComboBox();
this.cBGyroMouseXAxis = new System.Windows.Forms.ComboBox(); this.cBGyroMouseXAxis = new System.Windows.Forms.ComboBox();
@ -470,6 +472,7 @@
this.fLPSettings.SuspendLayout(); this.fLPSettings.SuspendLayout();
this.gBGyro.SuspendLayout(); this.gBGyro.SuspendLayout();
this.pnlSAMouse.SuspendLayout(); this.pnlSAMouse.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gyroMouseDzNUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDGyroSmoothWeight)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDGyroSmoothWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDGyroMouseVertScale)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDGyroMouseVertScale)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDGyroSensitivity)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDGyroSensitivity)).BeginInit();
@ -3392,6 +3395,8 @@
// //
// pnlSAMouse // pnlSAMouse
// //
this.pnlSAMouse.Controls.Add(this.label27);
this.pnlSAMouse.Controls.Add(this.gyroMouseDzNUD);
this.pnlSAMouse.Controls.Add(this.label26); this.pnlSAMouse.Controls.Add(this.label26);
this.pnlSAMouse.Controls.Add(this.triggerCondAndCombo); this.pnlSAMouse.Controls.Add(this.triggerCondAndCombo);
this.pnlSAMouse.Controls.Add(this.cBGyroMouseXAxis); this.pnlSAMouse.Controls.Add(this.cBGyroMouseXAxis);
@ -3414,6 +3419,22 @@
resources.ApplyResources(this.pnlSAMouse, "pnlSAMouse"); resources.ApplyResources(this.pnlSAMouse, "pnlSAMouse");
this.pnlSAMouse.Name = "pnlSAMouse"; this.pnlSAMouse.Name = "pnlSAMouse";
// //
// label27
//
resources.ApplyResources(this.label27, "label27");
this.label27.Name = "label27";
//
// gyroMouseDzNUD
//
resources.ApplyResources(this.gyroMouseDzNUD, "gyroMouseDzNUD");
this.gyroMouseDzNUD.Name = "gyroMouseDzNUD";
this.gyroMouseDzNUD.Value = new decimal(new int[] {
10,
0,
0,
0});
this.gyroMouseDzNUD.ValueChanged += new System.EventHandler(this.gyroMouseDzNUD_ValueChanged);
//
// label26 // label26
// //
resources.ApplyResources(this.label26, "label26"); resources.ApplyResources(this.label26, "label26");
@ -4240,6 +4261,7 @@
this.gBGyro.PerformLayout(); this.gBGyro.PerformLayout();
this.pnlSAMouse.ResumeLayout(false); this.pnlSAMouse.ResumeLayout(false);
this.pnlSAMouse.PerformLayout(); this.pnlSAMouse.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.gyroMouseDzNUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDGyroSmoothWeight)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDGyroSmoothWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDGyroMouseVertScale)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDGyroMouseVertScale)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDGyroSensitivity)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDGyroSensitivity)).EndInit();
@ -4620,5 +4642,7 @@
private System.Windows.Forms.CheckBox trackballCk; private System.Windows.Forms.CheckBox trackballCk;
private System.Windows.Forms.Label label26; private System.Windows.Forms.Label label26;
private System.Windows.Forms.ComboBox triggerCondAndCombo; private System.Windows.Forms.ComboBox triggerCondAndCombo;
private System.Windows.Forms.Label label27;
private System.Windows.Forms.NumericUpDown gyroMouseDzNUD;
} }
} }

View File

@ -718,6 +718,7 @@ namespace DS4Windows
nUDGyroSmoothWeight.Value = (decimal)(GyroSmoothingWeight[device]); nUDGyroSmoothWeight.Value = (decimal)(GyroSmoothingWeight[device]);
cBGyroMouseXAxis.SelectedIndex = GyroMouseHorizontalAxis[device]; cBGyroMouseXAxis.SelectedIndex = GyroMouseHorizontalAxis[device];
triggerCondAndCombo.SelectedIndex = SATriggerCond[device] ? 0 : 1; triggerCondAndCombo.SelectedIndex = SATriggerCond[device] ? 0 : 1;
gyroMouseDzNUD.Value = GyroMouseDeadZone[device];
} }
else else
{ {
@ -834,6 +835,7 @@ namespace DS4Windows
cBGyroInvertY.Checked = false; cBGyroInvertY.Checked = false;
cBGyroSmooth.Checked = false; cBGyroSmooth.Checked = false;
nUDGyroSmoothWeight.Value = 0.5m; nUDGyroSmoothWeight.Value = 0.5m;
gyroMouseDzNUD.Value = MouseCursor.GYRO_MOUSE_DEADZONE;
cBGyroMouseXAxis.SelectedIndex = 0; cBGyroMouseXAxis.SelectedIndex = 0;
triggerCondAndCombo.SelectedIndex = 0; triggerCondAndCombo.SelectedIndex = 0;
Set(); Set();
@ -1334,6 +1336,7 @@ namespace DS4Windows
GyroSmoothing[device] = cBGyroSmooth.Checked; GyroSmoothing[device] = cBGyroSmooth.Checked;
GyroSmoothingWeight[device] = (double)nUDGyroSmoothWeight.Value; GyroSmoothingWeight[device] = (double)nUDGyroSmoothWeight.Value;
GyroMouseHorizontalAxis[device] = cBGyroMouseXAxis.SelectedIndex; GyroMouseHorizontalAxis[device] = cBGyroMouseXAxis.SelectedIndex;
SetGyroMouseDeadZone(device, (int)gyroMouseDzNUD.Value, Program.rootHub);
int invert = 0; int invert = 0;
if (cBGyroInvertX.Checked) if (cBGyroInvertX.Checked)
@ -2989,6 +2992,15 @@ namespace DS4Windows
} }
} }
private void gyroMouseDzNUD_ValueChanged(object sender, EventArgs e)
{
if (loading == false)
{
SetGyroMouseDeadZone(device, (int)gyroMouseDzNUD.Value,
Program.rootHub);
}
}
private void trackFrictionNUD_ValueChanged(object sender, EventArgs e) private void trackFrictionNUD_ValueChanged(object sender, EventArgs e)
{ {
if (loading == false) if (loading == false)

File diff suppressed because it is too large Load Diff