Add sixaxis anti-deadzone settings

This commit is contained in:
Travis Nickles 2017-07-18 19:44:55 -05:00
parent 7ddd2c1bf5
commit ec130f6156
5 changed files with 3410 additions and 834 deletions

View File

@ -876,51 +876,52 @@ namespace DS4Windows
int SZD = (int)(10d * getSZDeadzone(device));
double SXMax = getSXMaxzone(device);
double SZMax = getSZMaxzone(device);
double sxAntiDead = getSXAntiDeadzone(device);
double szAntiDead = getSZAntiDeadzone(device);
double sxsens = getSXSens(device);
double szsens = getSZSens(device);
int gyroX = cState.Motion.accelX;
int gyroZ = cState.Motion.accelZ;
int gyroX = cState.Motion.accelX, gyroZ = cState.Motion.accelZ;
int absx = Math.Abs(gyroX), absz = Math.Abs(gyroZ);
int absx = Math.Abs(gyroX);
int absz = Math.Abs(gyroZ);
if (SXD > 0 || SXMax < 1.0)
if (SXD > 0 || SXMax < 1.0 || sxAntiDead > 0)
{
int maxValue = (int)(SXMax * 128d);
if (absx > SXD)
{
cState.Motion.accelX = Math.Sign(gyroX) *
(int)Math.Min(128d, sxsens * 128d * ((absx - SXD) / (double)(maxValue - SXD)));
double ratioX = (absx - SXD) / (double)(maxValue - SXD);
dState.Motion.accelX = Math.Sign(gyroX) *
(int)Math.Min(128d, sxsens * 128d * ((1.0 - sxAntiDead) * ratioX + sxAntiDead));
}
else
{
cState.Motion.accelX = 0;
dState.Motion.accelX = 0;
}
}
else
{
cState.Motion.accelX = Math.Sign(gyroX) *
dState.Motion.accelX = Math.Sign(gyroX) *
(int)Math.Min(128d, sxsens * 128d * (absx / 128d));
}
if (SZD > 0 || SZMax < 1.0)
if (SZD > 0 || SZMax < 1.0 || szAntiDead > 0)
{
int maxValue = (int)(SZMax * 128d);
if (absz > SZD)
{
cState.Motion.accelZ = Math.Sign(gyroZ) *
(int)Math.Min(128d, szsens * 128d * ((absz - SZD) / (double)(maxValue - SZD)));
double ratioZ = (absz - SZD) / (double)(maxValue - SZD);
dState.Motion.accelZ = Math.Sign(gyroZ) *
(int)Math.Min(128d, szsens * 128d * ((1.0 - szAntiDead) * ratioZ + szAntiDead));
}
else
{
cState.Motion.accelZ = 0;
dState.Motion.accelZ = 0;
}
}
else
{
cState.Motion.accelZ = Math.Sign(gyroZ) *
(int)Math.Min(128d, szsens * 128d * ((absz) / 128d));
dState.Motion.accelZ = Math.Sign(gyroZ) *
(int)Math.Min(128d, szsens * 128d * (absz / 128d));
}
}

View File

@ -696,18 +696,6 @@ namespace DS4Windows
return m_Config.SZDeadzone[index];
}
public static double[] SXMaxzone => m_Config.SXMaxzone;
public static double getSXMaxzone(int index)
{
return m_Config.SXMaxzone[index];
}
public static double[] SZMaxzone => m_Config.SZMaxzone;
public static double getSZMaxzone(int index)
{
return m_Config.SZMaxzone[index];
}
public static int[] LSDeadzone => m_Config.LSDeadzone;
public static int getLSDeadzone(int index)
{
@ -732,6 +720,18 @@ namespace DS4Windows
return m_Config.RSAntiDeadzone[index];
}
public static double[] SXAntiDeadzone => m_Config.SXAntiDeadzone;
public static double getSXAntiDeadzone(int index)
{
return m_Config.SXAntiDeadzone[index];
}
public static double[] SZAntiDeadzone => m_Config.SZAntiDeadzone;
public static double getSZAntiDeadzone(int index)
{
return m_Config.SZAntiDeadzone[index];
}
public static int[] LSMaxzone => m_Config.LSMaxzone;
public static int getLSMaxzone(int index)
{
@ -744,6 +744,18 @@ namespace DS4Windows
return m_Config.RSMaxzone[index];
}
public static double[] SXMaxzone => m_Config.SXMaxzone;
public static double getSXMaxzone(int index)
{
return m_Config.SXMaxzone[index];
}
public static double[] SZMaxzone => m_Config.SZMaxzone;
public static double getSZMaxzone(int index)
{
return m_Config.SZMaxzone[index];
}
public static int[] L2AntiDeadzone => m_Config.l2AntiDeadzone;
public static int getL2AntiDeadzone(int index)
{
@ -1184,6 +1196,8 @@ namespace DS4Windows
public double[] SXDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 }, SZDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 };
public double[] SXMaxzone = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 },
SZMaxzone = new double[5] { 1.0, 1.0, 1.0, 1.0, 1.0 };
public double[] SXAntiDeadzone = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 },
SZAntiDeadzone = new double[5] { 0.0, 0.0, 0.0, 0.0, 0.0 };
public double[] l2Sens = { 1, 1, 1, 1, 1 }, r2Sens = { 1, 1, 1, 1, 1 };
public double[] LSSens = { 1, 1, 1, 1, 1 }, RSSens = { 1, 1, 1, 1, 1 };
public double[] SXSens = { 1, 1, 1, 1, 1 }, SZSens = { 1, 1, 1, 1, 1 };
@ -1497,6 +1511,9 @@ namespace DS4Windows
XmlNode xmlSXMaxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "SXMaxZone", null); xmlSXMaxzone.InnerText = Convert.ToInt32(SXMaxzone[device] * 100.0).ToString(); Node.AppendChild(xmlSXMaxzone);
XmlNode xmlSZMaxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "SZMaxZone", null); xmlSZMaxzone.InnerText = Convert.ToInt32(SZMaxzone[device] * 100.0).ToString(); Node.AppendChild(xmlSZMaxzone);
XmlNode xmlSXAntiDeadzone = m_Xdoc.CreateNode(XmlNodeType.Element, "SXAntiDeadZone", null); xmlSXAntiDeadzone.InnerText = Convert.ToInt32(SXAntiDeadzone[device] * 100.0).ToString(); Node.AppendChild(xmlSXAntiDeadzone);
XmlNode xmlSZAntiDeadzone = m_Xdoc.CreateNode(XmlNodeType.Element, "SZAntiDeadZone", null); xmlSZAntiDeadzone.InnerText = Convert.ToInt32(SZAntiDeadzone[device] * 100.0).ToString(); Node.AppendChild(xmlSZAntiDeadzone);
XmlNode xmlSens = m_Xdoc.CreateNode(XmlNodeType.Element, "Sensitivity", null);
xmlSens.InnerText = $"{LSSens[device]}|{RSSens[device]}|{l2Sens[device]}|{r2Sens[device]}|{SXSens[device]}|{SZSens[device]}";
Node.AppendChild(xmlSens);
@ -2316,6 +2333,20 @@ namespace DS4Windows
}
catch { SZMaxzone[device] = 1.0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SXAntiDeadZone");
int temp = 0;
int.TryParse(Item.InnerText, out temp);
SXAntiDeadzone[device] = Math.Min(Math.Max(temp * 0.01, 0.0), 1.0);
}
catch { SXAntiDeadzone[device] = 0.0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SZAntiDeadZone");
int temp = 0;
int.TryParse(Item.InnerText, out temp);
SZAntiDeadzone[device] = Math.Min(Math.Max(temp * 0.01, 0.0), 1.0);
}
catch { SZAntiDeadzone[device] = 0.0; missingSetting = true; }
try
{
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/Sensitivity");
@ -3497,6 +3528,7 @@ namespace DS4Windows
RSRotation[device] = 0.0;
SXDeadzone[device] = SZDeadzone[device] = 0.25;
SXMaxzone[device] = SZMaxzone[device] = 1.0;
SXAntiDeadzone[device] = SZAntiDeadzone[device] = 0.0;
l2Sens[device] = r2Sens[device] = 1;
LSSens[device] = RSSens[device] = 1;
SXSens[device] = SZSens[device] = 1;

View File

@ -264,6 +264,10 @@
this.nUDLSAntiDead = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.maxZoneTabPage = new System.Windows.Forms.TabPage();
this.nUDSixAxisZMaxZone = new System.Windows.Forms.NumericUpDown();
this.nUDSixAxisXMaxZone = new System.Windows.Forms.NumericUpDown();
this.label18 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.nUDR2Maxzone = new System.Windows.Forms.NumericUpDown();
this.nUDL2Maxzone = new System.Windows.Forms.NumericUpDown();
this.label8 = new System.Windows.Forms.Label();
@ -345,11 +349,11 @@
this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label17 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.nUDSixAxisXMaxZone = new System.Windows.Forms.NumericUpDown();
this.nUDSixAxisZMaxZone = new System.Windows.Forms.NumericUpDown();
this.advColorDialog = new DS4Windows.AdvancedColorDialog();
this.label19 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.nUDSixaxisXAntiDead = new System.Windows.Forms.NumericUpDown();
this.nUDSixaxisZAntiDead = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tBGreenBar)).BeginInit();
@ -412,6 +416,8 @@
((System.ComponentModel.ISupportInitialize)(this.nUDRSAntiDead)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).BeginInit();
this.maxZoneTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisZMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisXMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDR2Maxzone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDL2Maxzone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).BeginInit();
@ -437,8 +443,8 @@
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit();
this.cMGyroTriggers.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisXMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisZMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixaxisXAntiDead)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixaxisZAntiDead)).BeginInit();
this.SuspendLayout();
//
// lowColorChooserButton
@ -2696,6 +2702,10 @@
//
// antiDeadzoneTabPage
//
this.antiDeadzoneTabPage.Controls.Add(this.nUDSixaxisZAntiDead);
this.antiDeadzoneTabPage.Controls.Add(this.nUDSixaxisXAntiDead);
this.antiDeadzoneTabPage.Controls.Add(this.label20);
this.antiDeadzoneTabPage.Controls.Add(this.label19);
this.antiDeadzoneTabPage.Controls.Add(this.nUDR2AntiDead);
this.antiDeadzoneTabPage.Controls.Add(this.label3);
this.antiDeadzoneTabPage.Controls.Add(this.nUDL2AntiDead);
@ -2814,6 +2824,60 @@
this.maxZoneTabPage.Name = "maxZoneTabPage";
this.maxZoneTabPage.UseVisualStyleBackColor = true;
//
// nUDSixAxisZMaxZone
//
this.nUDSixAxisZMaxZone.DecimalPlaces = 2;
this.nUDSixAxisZMaxZone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDSixAxisZMaxZone, "nUDSixAxisZMaxZone");
this.nUDSixAxisZMaxZone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisZMaxZone.Name = "nUDSixAxisZMaxZone";
this.nUDSixAxisZMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisZMaxZone.ValueChanged += new System.EventHandler(this.nUDSixAxisZMaxZone_ValueChanged);
//
// nUDSixAxisXMaxZone
//
this.nUDSixAxisXMaxZone.DecimalPlaces = 2;
this.nUDSixAxisXMaxZone.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDSixAxisXMaxZone, "nUDSixAxisXMaxZone");
this.nUDSixAxisXMaxZone.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisXMaxZone.Name = "nUDSixAxisXMaxZone";
this.nUDSixAxisXMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisXMaxZone.ValueChanged += new System.EventHandler(this.nUDSixAxisXMaxZone_ValueChanged);
//
// label18
//
resources.ApplyResources(this.label18, "label18");
this.label18.Name = "label18";
//
// label17
//
resources.ApplyResources(this.label17, "label17");
this.label17.Name = "label17";
//
// nUDR2Maxzone
//
this.nUDR2Maxzone.DecimalPlaces = 2;
@ -3679,59 +3743,49 @@
resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem");
this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged);
//
// label17
// label19
//
resources.ApplyResources(this.label17, "label17");
this.label17.Name = "label17";
resources.ApplyResources(this.label19, "label19");
this.label19.Name = "label19";
//
// label18
// label20
//
resources.ApplyResources(this.label18, "label18");
this.label18.Name = "label18";
resources.ApplyResources(this.label20, "label20");
this.label20.Name = "label20";
//
// nUDSixAxisXMaxZone
// nUDSixaxisXAntiDead
//
this.nUDSixAxisXMaxZone.DecimalPlaces = 2;
this.nUDSixAxisXMaxZone.Increment = new decimal(new int[] {
this.nUDSixaxisXAntiDead.DecimalPlaces = 2;
this.nUDSixaxisXAntiDead.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDSixAxisXMaxZone, "nUDSixAxisXMaxZone");
this.nUDSixAxisXMaxZone.Maximum = new decimal(new int[] {
resources.ApplyResources(this.nUDSixaxisXAntiDead, "nUDSixaxisXAntiDead");
this.nUDSixaxisXAntiDead.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisXMaxZone.Name = "nUDSixAxisXMaxZone";
this.nUDSixAxisXMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisXMaxZone.ValueChanged += new System.EventHandler(this.nUDSixAxisXMaxZone_ValueChanged);
this.nUDSixaxisXAntiDead.Name = "nUDSixaxisXAntiDead";
this.nUDSixaxisXAntiDead.ValueChanged += new System.EventHandler(this.nUDSixaxisXAntiDead_ValueChanged);
//
// nUDSixAxisZMaxZone
// nUDSixaxisZAntiDead
//
this.nUDSixAxisZMaxZone.DecimalPlaces = 2;
this.nUDSixAxisZMaxZone.Increment = new decimal(new int[] {
this.nUDSixaxisZAntiDead.DecimalPlaces = 2;
this.nUDSixaxisZAntiDead.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.nUDSixAxisZMaxZone, "nUDSixAxisZMaxZone");
this.nUDSixAxisZMaxZone.Maximum = new decimal(new int[] {
resources.ApplyResources(this.nUDSixaxisZAntiDead, "nUDSixaxisZAntiDead");
this.nUDSixaxisZAntiDead.Maximum = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisZMaxZone.Name = "nUDSixAxisZMaxZone";
this.nUDSixAxisZMaxZone.Value = new decimal(new int[] {
1,
0,
0,
0});
this.nUDSixAxisZMaxZone.ValueChanged += new System.EventHandler(this.nUDSixAxisZMaxZone_ValueChanged);
this.nUDSixaxisZAntiDead.Name = "nUDSixaxisZAntiDead";
this.nUDSixaxisZAntiDead.ValueChanged += new System.EventHandler(this.nUDSixaxisZAntiDead_ValueChanged);
//
// Options
//
@ -3819,6 +3873,8 @@
((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).EndInit();
this.maxZoneTabPage.ResumeLayout(false);
this.maxZoneTabPage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisZMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisXMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDR2Maxzone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDL2Maxzone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).EndInit();
@ -3850,8 +3906,8 @@
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit();
this.cMGyroTriggers.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisXMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixAxisZMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixaxisXAntiDead)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDSixaxisZAntiDead)).EndInit();
this.ResumeLayout(false);
}
@ -4180,5 +4236,9 @@
private System.Windows.Forms.NumericUpDown nUDSixAxisXMaxZone;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.NumericUpDown nUDSixaxisZAntiDead;
private System.Windows.Forms.NumericUpDown nUDSixaxisXAntiDead;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.Label label19;
}
}

View File

@ -525,6 +525,24 @@ namespace DS4Windows
nUDSixAxisZMaxZone.Value = 1.0m;
}
try
{
nUDSixaxisXAntiDead.Value = (decimal)SXAntiDeadzone[device];
}
catch
{
nUDSixaxisXAntiDead.Value = 0.0m;
}
try
{
nUDSixaxisZAntiDead.Value = (decimal)SZAntiDeadzone[device];
}
catch
{
nUDSixaxisZAntiDead.Value = 0.0m;
}
try
{
nUDL2S.Value = Math.Round((decimal)L2Sens[device], 2);
@ -699,6 +717,8 @@ namespace DS4Windows
nUDSZ.Value = .25m;
nUDSixAxisXMaxZone.Value = 1.0m;
nUDSixAxisZMaxZone.Value = 1.0m;
nUDSixaxisXAntiDead.Value = 0.0m;
nUDSixaxisZAntiDead.Value = 0.0m;
nUDL2S.Value = 1;
nUDR2S.Value = 1;
@ -1359,6 +1379,8 @@ namespace DS4Windows
SZDeadzone[device] = (double)nUDSZ.Value;
SXMaxzone[device] = (double)nUDSixAxisXMaxZone.Value;
SZMaxzone[device] = (double)nUDSixAxisZMaxZone.Value;
SXAntiDeadzone[device] = (double)nUDSixaxisXAntiDead.Value;
SZAntiDeadzone[device] = (double)nUDSixaxisZAntiDead.Value;
MouseAccel[device] = cBMouseAccel.Checked;
DinputOnly[device] = cBDinput.Checked;
StartTouchpadOff[device] = cbStartTouchpadOff.Checked;
@ -2960,6 +2982,22 @@ namespace DS4Windows
}
}
private void nUDSixaxisXAntiDead_ValueChanged(object sender, EventArgs e)
{
if (loading == false)
{
SXAntiDeadzone[device] = (double)nUDSixaxisXAntiDead.Value;
}
}
private void nUDSixaxisZAntiDead_ValueChanged(object sender, EventArgs e)
{
if (loading == false)
{
SZAntiDeadzone[device] = (double)nUDSixaxisZAntiDead.Value;
}
}
private void Options_Resize(object sender, EventArgs e)
{
fLPSettings.AutoScroll = false;

File diff suppressed because it is too large Load Diff