Add touchpad mouse axis inverting. Related to issue #83.

This commit is contained in:
Travis Nickles 2017-07-12 22:39:46 -05:00
parent 6f069482a2
commit c0403fa7ab
5 changed files with 1028 additions and 3204 deletions

View File

@ -32,6 +32,7 @@ namespace DS4Windows
double verticalScale = 0.0;
bool gyroSmooth = false;
//double gyroSmoothWeight = 0.0;
int tempInt = 0;
public virtual void sixaxisMoved(SixAxisEventArgs arg)
{
@ -279,7 +280,7 @@ namespace DS4Windows
}
}
double coefficient = Global.TouchSensitivity[deviceNumber] / 100.0;
double coefficient = Global.TouchSensitivity[deviceNumber] * 0.01;
// Collect rounding errors instead of losing motion.
double xMotion = coefficient * deltaX;
if (xMotion > 0.0)
@ -309,6 +310,13 @@ namespace DS4Windows
int yAction = (int)yMotion;
verticalRemainder = yMotion - yAction;
int touchpadInvert = tempInt = Global.getTouchpadInvert(deviceNumber);
if ((touchpadInvert & 0x02) == 2)
xAction *= -1;
if ((touchpadInvert & 0x01) == 1)
yAction *= -1;
if (yAction != 0 || xAction != 0)
InputMethods.MoveCursorBy(xAction, yAction);

View File

@ -660,6 +660,12 @@ namespace DS4Windows
public static bool[] LowerRCOn => m_Config.lowerRCOn;
public static bool[] TouchpadJitterCompensation => m_Config.touchpadJitterCompensation;
public static int[] TouchpadInvert => m_Config.touchpadInvert;
public static int getTouchpadInvert(int index)
{
return m_Config.touchpadInvert[index];
}
public static byte[] L2Deadzone => m_Config.l2Deadzone;
public static byte getL2Deadzone(int index)
{
@ -1164,6 +1170,7 @@ namespace DS4Windows
public Byte[] tapSensitivity = { 0, 0, 0, 0, 0 };
public bool[] doubleTap = { false, false, false, false, false };
public int[] scrollSensitivity = { 0, 0, 0, 0, 0 };
public int[] touchpadInvert = { 0, 0, 0, 0, 0 };
public double[] rainbow = { 0, 0, 0, 0, 0 };
public int[] flashAt = { 0, 0, 0, 0, 0 };
public bool[] mouseAccel = { true, true, true, true, true };
@ -1447,6 +1454,7 @@ namespace DS4Windows
XmlNode xmlScrollSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "scrollSensitivity", null); xmlScrollSensitivity.InnerText = scrollSensitivity[device].ToString(); Node.AppendChild(xmlScrollSensitivity);
XmlNode xmlLeftTriggerMiddle = m_Xdoc.CreateNode(XmlNodeType.Element, "LeftTriggerMiddle", null); xmlLeftTriggerMiddle.InnerText = l2Deadzone[device].ToString(); Node.AppendChild(xmlLeftTriggerMiddle);
XmlNode xmlRightTriggerMiddle = m_Xdoc.CreateNode(XmlNodeType.Element, "RightTriggerMiddle", null); xmlRightTriggerMiddle.InnerText = r2Deadzone[device].ToString(); Node.AppendChild(xmlRightTriggerMiddle);
XmlNode xmlTouchpadInvert = m_Xdoc.CreateNode(XmlNodeType.Element, "TouchpadInvert", null); xmlTouchpadInvert.InnerText = touchpadInvert[device].ToString(); Node.AppendChild(xmlTouchpadInvert);
XmlNode xmlL2AD = m_Xdoc.CreateNode(XmlNodeType.Element, "L2AntiDeadZone", null); xmlL2AD.InnerText = l2AntiDeadzone[device].ToString(); Node.AppendChild(xmlL2AD);
XmlNode xmlR2AD = m_Xdoc.CreateNode(XmlNodeType.Element, "R2AntiDeadZone", null); xmlR2AD.InnerText = r2AntiDeadzone[device].ToString(); Node.AppendChild(xmlR2AD);
XmlNode xmlL2Maxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "L2MaxZone", null); xmlL2Maxzone.InnerText = l2Maxzone[device].ToString(); Node.AppendChild(xmlL2Maxzone);
@ -2190,12 +2198,18 @@ namespace DS4Windows
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/scrollSensitivity"); int.TryParse(Item.InnerText, out scrollSensitivity[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/TouchpadInvert"); int temp = 0; int.TryParse(Item.InnerText, out temp); touchpadInvert[device] = Math.Min(Math.Max(temp, 0), 3); }
catch { touchpadInvert[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LeftTriggerMiddle"); byte.TryParse(Item.InnerText, out l2Deadzone[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RightTriggerMiddle"); byte.TryParse(Item.InnerText, out r2Deadzone[device]); }
catch { missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/L2AntiDeadZone"); int.TryParse(Item.InnerText, out l2AntiDeadzone[device]); }
catch { l2AntiDeadzone[device] = 0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/R2AntiDeadZone"); int.TryParse(Item.InnerText, out r2AntiDeadzone[device]); }
catch { r2AntiDeadzone[device] = 0; missingSetting = true; }
@ -3446,6 +3460,7 @@ namespace DS4Windows
tapSensitivity[device] = 0;
doubleTap[device] = false;
scrollSensitivity[device] = 0;
touchpadInvert[device] = 0;
rainbow[device] = 0;
flashAt[device] = 0;
mouseAccel[device] = true;

View File

@ -282,6 +282,11 @@
this.lsOutCurveComboBox = new System.Windows.Forms.ComboBox();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.tpRotation = new System.Windows.Forms.TabPage();
this.nUDRSRotation = new System.Windows.Forms.NumericUpDown();
this.label14 = new System.Windows.Forms.Label();
this.nUDLSRotation = new System.Windows.Forms.NumericUpDown();
this.label13 = new System.Windows.Forms.Label();
this.fLPSettings = new System.Windows.Forms.FlowLayoutPanel();
this.gBGyro = new System.Windows.Forms.GroupBox();
this.rBSAControls = new System.Windows.Forms.RadioButton();
@ -337,11 +342,8 @@
this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.advColorDialog = new DS4Windows.AdvancedColorDialog();
this.tpRotation = new System.Windows.Forms.TabPage();
this.label13 = new System.Windows.Forms.Label();
this.nUDLSRotation = new System.Windows.Forms.NumericUpDown();
this.label14 = new System.Windows.Forms.Label();
this.nUDRSRotation = new System.Windows.Forms.NumericUpDown();
this.touchpadInvertComboBox = new System.Windows.Forms.ComboBox();
this.label15 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tBGreenBar)).BeginInit();
@ -412,6 +414,9 @@
((System.ComponentModel.ISupportInitialize)(this.nUDLSCurve)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSCurve)).BeginInit();
this.tPOutCurve.SuspendLayout();
this.tpRotation.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDRSRotation)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSRotation)).BeginInit();
this.fLPSettings.SuspendLayout();
this.gBGyro.SuspendLayout();
this.pnlSAMouse.SuspendLayout();
@ -426,9 +431,6 @@
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit();
this.cMGyroTriggers.SuspendLayout();
this.tpRotation.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDLSRotation)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSRotation)).BeginInit();
this.SuspendLayout();
//
// lowColorChooserButton
@ -887,6 +889,8 @@
//
// pnlTPMouse
//
this.pnlTPMouse.Controls.Add(this.label15);
this.pnlTPMouse.Controls.Add(this.touchpadInvertComboBox);
this.pnlTPMouse.Controls.Add(this.nUDScroll);
this.pnlTPMouse.Controls.Add(this.cBDoubleTap);
this.pnlTPMouse.Controls.Add(this.cBScroll);
@ -2990,6 +2994,58 @@
resources.ApplyResources(this.label9, "label9");
this.label9.Name = "label9";
//
// tpRotation
//
this.tpRotation.Controls.Add(this.nUDRSRotation);
this.tpRotation.Controls.Add(this.label14);
this.tpRotation.Controls.Add(this.nUDLSRotation);
this.tpRotation.Controls.Add(this.label13);
resources.ApplyResources(this.tpRotation, "tpRotation");
this.tpRotation.Name = "tpRotation";
this.tpRotation.UseVisualStyleBackColor = true;
//
// nUDRSRotation
//
resources.ApplyResources(this.nUDRSRotation, "nUDRSRotation");
this.nUDRSRotation.Maximum = new decimal(new int[] {
180,
0,
0,
0});
this.nUDRSRotation.Minimum = new decimal(new int[] {
180,
0,
0,
-2147483648});
this.nUDRSRotation.Name = "nUDRSRotation";
this.nUDRSRotation.ValueChanged += new System.EventHandler(this.nUDRSRotation_ValueChanged);
//
// label14
//
resources.ApplyResources(this.label14, "label14");
this.label14.Name = "label14";
//
// nUDLSRotation
//
resources.ApplyResources(this.nUDLSRotation, "nUDLSRotation");
this.nUDLSRotation.Maximum = new decimal(new int[] {
180,
0,
0,
0});
this.nUDLSRotation.Minimum = new decimal(new int[] {
180,
0,
0,
-2147483648});
this.nUDLSRotation.Name = "nUDLSRotation";
this.nUDLSRotation.ValueChanged += new System.EventHandler(this.nUDLSRotation_ValueChanged);
//
// label13
//
resources.ApplyResources(this.label13, "label13");
this.label13.Name = "label13";
//
// fLPSettings
//
resources.ApplyResources(this.fLPSettings, "fLPSettings");
@ -3575,57 +3631,23 @@
resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem");
this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged);
//
// tpRotation
// touchpadInvertComboBox
//
this.tpRotation.Controls.Add(this.nUDRSRotation);
this.tpRotation.Controls.Add(this.label14);
this.tpRotation.Controls.Add(this.nUDLSRotation);
this.tpRotation.Controls.Add(this.label13);
resources.ApplyResources(this.tpRotation, "tpRotation");
this.tpRotation.Name = "tpRotation";
this.tpRotation.UseVisualStyleBackColor = true;
this.touchpadInvertComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.touchpadInvertComboBox.FormattingEnabled = true;
this.touchpadInvertComboBox.Items.AddRange(new object[] {
resources.GetString("touchpadInvertComboBox.Items"),
resources.GetString("touchpadInvertComboBox.Items1"),
resources.GetString("touchpadInvertComboBox.Items2"),
resources.GetString("touchpadInvertComboBox.Items3")});
resources.ApplyResources(this.touchpadInvertComboBox, "touchpadInvertComboBox");
this.touchpadInvertComboBox.Name = "touchpadInvertComboBox";
this.touchpadInvertComboBox.SelectedIndexChanged += new System.EventHandler(this.touchpadInvertComboBox_SelectedIndexChanged);
//
// label13
// label15
//
resources.ApplyResources(this.label13, "label13");
this.label13.Name = "label13";
//
// nUDLSRotation
//
resources.ApplyResources(this.nUDLSRotation, "nUDLSRotation");
this.nUDLSRotation.Maximum = new decimal(new int[] {
180,
0,
0,
0});
this.nUDLSRotation.Minimum = new decimal(new int[] {
180,
0,
0,
-2147483648});
this.nUDLSRotation.Name = "nUDLSRotation";
this.nUDLSRotation.ValueChanged += new System.EventHandler(this.nUDLSRotation_ValueChanged);
//
// label14
//
resources.ApplyResources(this.label14, "label14");
this.label14.Name = "label14";
//
// nUDRSRotation
//
resources.ApplyResources(this.nUDRSRotation, "nUDRSRotation");
this.nUDRSRotation.Maximum = new decimal(new int[] {
180,
0,
0,
0});
this.nUDRSRotation.Minimum = new decimal(new int[] {
180,
0,
0,
-2147483648});
this.nUDRSRotation.Name = "nUDRSRotation";
this.nUDRSRotation.ValueChanged += new System.EventHandler(this.nUDRSRotation_ValueChanged);
resources.ApplyResources(this.label15, "label15");
this.label15.Name = "label15";
//
// Options
//
@ -3723,6 +3745,10 @@
((System.ComponentModel.ISupportInitialize)(this.nUDRSCurve)).EndInit();
this.tPOutCurve.ResumeLayout(false);
this.tPOutCurve.PerformLayout();
this.tpRotation.ResumeLayout(false);
this.tpRotation.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDRSRotation)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSRotation)).EndInit();
this.fLPSettings.ResumeLayout(false);
this.gBGyro.ResumeLayout(false);
this.gBGyro.PerformLayout();
@ -3740,10 +3766,6 @@
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit();
this.cMGyroTriggers.ResumeLayout(false);
this.tpRotation.ResumeLayout(false);
this.tpRotation.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDLSRotation)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSRotation)).EndInit();
this.ResumeLayout(false);
}
@ -4064,5 +4086,7 @@
private System.Windows.Forms.Label label14;
private System.Windows.Forms.NumericUpDown nUDLSRotation;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.ComboBox touchpadInvertComboBox;
}
}

View File

@ -30,6 +30,9 @@ namespace DS4Windows
private Dictionary<Control, int> hoverIndexDict = new Dictionary<Control, int>();
private Dictionary<Control, Bitmap> hoverImageDict = new Dictionary<Control, Bitmap>();
private Dictionary<Control, Label> hoverLabelDict = new Dictionary<Control, Label>();
private int[] touchpadInvertToValue = new int[4] { 0, 2, 1, 3 };
int tempInt = 0;
public Options(DS4Form rt)
{
@ -338,6 +341,10 @@ namespace DS4Windows
cBTap.Checked = TapSensitivity[device] > 0;
cBDoubleTap.Checked = DoubleTap[device];
cBTouchpadJitterCompensation.Checked = TouchpadJitterCompensation[device];
tempInt = TouchpadInvert[device];
touchpadInvertComboBox.SelectedIndex = touchpadInvertToValue[tempInt];
cBlowerRCOn.Checked = LowerRCOn[device];
cBFlushHIDQueue.Checked = FlushHIDQueue[device];
enableTouchToggleCheckbox.Checked = getEnableTouchToggle(device);
@ -643,6 +650,7 @@ namespace DS4Windows
cBTap.Checked = false;
cBDoubleTap.Checked = false;
cBTouchpadJitterCompensation.Checked = true;
touchpadInvertComboBox.SelectedIndex = 0;
cBlowerRCOn.Checked = false;
cBFlushHIDQueue.Checked = false;
enableTouchToggleCheckbox.Checked = true;
@ -1312,6 +1320,10 @@ namespace DS4Windows
ScrollSensitivity[device] = (int)nUDScroll.Value;
DoubleTap[device] = cBDoubleTap.Checked;
TapSensitivity[device] = (byte)nUDTap.Value;
tempInt = touchpadInvertComboBox.SelectedIndex;
TouchpadInvert[device] = touchpadInvertToValue[tempInt];
IdleDisconnectTimeout[device] = (int)(nUDIdleDisconnect.Value * 60);
Rainbow[device] = (int)nUDRainbow.Value;
RSDeadzone[device] = (int)Math.Round((nUDRS.Value * 127), 0);
@ -2893,6 +2905,15 @@ namespace DS4Windows
}
}
private void touchpadInvertComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (!loading)
{
tempInt = touchpadInvertToValue[touchpadInvertComboBox.SelectedIndex];
TouchpadInvert[device] = tempInt;
}
}
private void Options_Resize(object sender, EventArgs e)
{
fLPSettings.AutoScroll = false;

File diff suppressed because it is too large Load Diff