mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2025-02-21 10:02:02 +01:00
Initial anti-deadzone feature. Minor R2 deadzone fix.
This commit is contained in:
parent
fc58383a82
commit
fa8ba7a0ba
@ -447,43 +447,79 @@ namespace DS4Windows
|
|||||||
double lsSquared = Math.Pow(cState.LX - 127.5f, 2) + Math.Pow(cState.LY - 127.5f, 2);
|
double lsSquared = Math.Pow(cState.LX - 127.5f, 2) + Math.Pow(cState.LY - 127.5f, 2);
|
||||||
//deadzones
|
//deadzones
|
||||||
int lsDeadzone = LSDeadzone[device];
|
int lsDeadzone = LSDeadzone[device];
|
||||||
|
int lsAntiDead = LSAntiDeadzone[device];
|
||||||
double lsDeadzoneSquared = Math.Pow(lsDeadzone, 2);
|
double lsDeadzoneSquared = Math.Pow(lsDeadzone, 2);
|
||||||
if (lsDeadzone > 0 && lsSquared <= lsDeadzoneSquared)
|
if (lsDeadzone > 0 && lsSquared <= lsDeadzoneSquared)
|
||||||
{
|
{
|
||||||
dState.LX = 127;
|
dState.LX = 127;
|
||||||
dState.LY = 127;
|
dState.LY = 127;
|
||||||
}
|
}
|
||||||
else if (lsDeadzone > 0 && lsSquared > lsDeadzoneSquared)
|
else if ((lsDeadzone > 0 && lsSquared > lsDeadzoneSquared) || lsAntiDead > 0)
|
||||||
{
|
{
|
||||||
double r = Math.Atan2(-(dState.LY - 127.5f), (dState.LX - 127.5f));
|
double r = Math.Atan2(-(dState.LY - 127.5f), (dState.LX - 127.5f));
|
||||||
double tempLsXDead = Math.Cos(r) * (lsDeadzone);
|
|
||||||
double tempLsYDead = Math.Sin(r) * (lsDeadzone);
|
|
||||||
double maxXValue = dState.LX > 127.5 ? 127.5 : -127.5;
|
double maxXValue = dState.LX > 127.5 ? 127.5 : -127.5;
|
||||||
double maxYValue = dState.LY > 127.5 ? 127.5 : -127.5;
|
double maxYValue = dState.LY > 127.5 ? 127.5 : -127.5;
|
||||||
dState.LX = (byte)(((dState.LX - 127.5f - tempLsXDead) / (double)(maxXValue - tempLsXDead)) * maxXValue + 127.5f);
|
|
||||||
dState.LY = (byte)(((dState.LY - 127.5f - tempLsYDead) / (double)(maxYValue - tempLsYDead)) * maxYValue + 127.5f);
|
double tempLsXDead = 0.0, tempLsYDead = 0.0;
|
||||||
|
if (lsDeadzone > 0)
|
||||||
|
{
|
||||||
|
tempLsXDead = Math.Cos(r) * (lsDeadzone);
|
||||||
|
tempLsYDead = Math.Sin(r) * (lsDeadzone);
|
||||||
|
}
|
||||||
|
|
||||||
|
double tempLsXAntiDeadPercent = 0.0, tempLsYAntiDeadPercent = 0.0;
|
||||||
|
|
||||||
|
if (lsAntiDead > 0)
|
||||||
|
{
|
||||||
|
tempLsXAntiDeadPercent = (lsAntiDead / 100.0) * Math.Abs(Math.Cos(r));
|
||||||
|
tempLsYAntiDeadPercent = (lsAntiDead / 100.0) * Math.Abs(Math.Sin(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
double tempOutputX = ((dState.LX - 127.5f - tempLsXDead) / (double)(maxXValue - tempLsXDead));
|
||||||
|
double tempOutputY = ((dState.LY - 127.5f - tempLsYDead) / (double)(maxYValue - tempLsYDead));
|
||||||
|
|
||||||
|
dState.LX = (byte)((((1.0 - tempLsXAntiDeadPercent) * tempOutputX + tempLsXAntiDeadPercent)) * maxXValue + 127.5f);
|
||||||
|
dState.LY = (byte)((((1.0 - tempLsYAntiDeadPercent) * tempOutputY + tempLsYAntiDeadPercent)) * maxYValue + 127.5f);
|
||||||
//dState.LX = (byte)(Math.Cos(r) * (127.5f + LSDeadzone[device]) + 127.5f);
|
//dState.LX = (byte)(Math.Cos(r) * (127.5f + LSDeadzone[device]) + 127.5f);
|
||||||
//dState.LY = (byte)(Math.Sin(r) * (127.5f + LSDeadzone[device]) + 127.5f);
|
//dState.LY = (byte)(Math.Sin(r) * (127.5f + LSDeadzone[device]) + 127.5f);
|
||||||
}
|
}
|
||||||
//Console.WriteLine
|
//Console.WriteLine
|
||||||
double rsSquared = Math.Pow(cState.RX - 127.5f, 2) + Math.Pow(cState.RY - 127.5f, 2);
|
double rsSquared = Math.Pow(cState.RX - 127.5f, 2) + Math.Pow(cState.RY - 127.5f, 2);
|
||||||
int rsDeadzone = RSDeadzone[device];
|
int rsDeadzone = RSDeadzone[device];
|
||||||
|
int rsAntiDead = RSAntiDeadzone[device];
|
||||||
double rsDeadzoneSquared = Math.Pow(rsDeadzone, 2);
|
double rsDeadzoneSquared = Math.Pow(rsDeadzone, 2);
|
||||||
if (rsDeadzone > 0 && rsSquared <= rsDeadzoneSquared)
|
if (rsDeadzone > 0 && rsSquared <= rsDeadzoneSquared)
|
||||||
{
|
{
|
||||||
dState.RX = 127;
|
dState.RX = 127;
|
||||||
dState.RY = 127;
|
dState.RY = 127;
|
||||||
}
|
}
|
||||||
else if (rsDeadzone > 0 && rsSquared > rsDeadzoneSquared)
|
else if ((rsDeadzone > 0 && rsSquared > rsDeadzoneSquared) || rsAntiDead > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
double r = Math.Atan2(-(dState.RY - 127.5f), (dState.RX - 127.5f));
|
double r = Math.Atan2(-(dState.RY - 127.5f), (dState.RX - 127.5f));
|
||||||
double tempRsXDead = Math.Cos(r) * (lsDeadzone);
|
|
||||||
double tempRsYDead = Math.Sin(r) * (lsDeadzone);
|
|
||||||
double maxXValue = dState.RX > 127.5 ? 127.5 : -127.5;
|
double maxXValue = dState.RX > 127.5 ? 127.5 : -127.5;
|
||||||
double maxYValue = dState.RY > 127.5 ? 127.5 : -127.5;
|
double maxYValue = dState.RY > 127.5 ? 127.5 : -127.5;
|
||||||
dState.RX = (byte)(((dState.RX - 127.5f - tempRsXDead) / (double)(maxXValue - tempRsXDead)) * maxXValue + 127.5f);
|
|
||||||
dState.RY = (byte)(((dState.RY - 127.5f - tempRsYDead) / (double)(maxYValue - tempRsYDead)) * maxYValue + 127.5f);
|
double tempRsXDead = 0.0, tempRsYDead = 0.0;
|
||||||
|
if (rsDeadzone > 0)
|
||||||
|
{
|
||||||
|
tempRsXDead = Math.Cos(r) * (rsDeadzone);
|
||||||
|
tempRsYDead = Math.Sin(r) * (rsDeadzone);
|
||||||
|
}
|
||||||
|
|
||||||
|
double tempRsXAntiDeadPercent = 0.0, tempRsYAntiDeadPercent = 0.0;
|
||||||
|
if (rsAntiDead > 0)
|
||||||
|
{
|
||||||
|
tempRsXAntiDeadPercent = (rsAntiDead / 100.0) * Math.Abs(Math.Cos(r));
|
||||||
|
tempRsYAntiDeadPercent = (rsAntiDead / 100.0) * Math.Abs(Math.Sin(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
double tempOutputX = ((dState.RX - 127.5f - tempRsXDead) / (double)(maxXValue - tempRsXDead));
|
||||||
|
double tempOutputY = ((dState.RY - 127.5f - tempRsYDead) / (double)(maxYValue - tempRsYDead));
|
||||||
|
|
||||||
|
dState.RX = (byte)((((1.0 - tempRsXAntiDeadPercent) * tempOutputX + tempRsXAntiDeadPercent)) * maxXValue + 127.5f);
|
||||||
|
dState.RY = (byte)((((1.0 - tempRsYAntiDeadPercent) * tempOutputY + tempRsYAntiDeadPercent)) * maxYValue + 127.5f);
|
||||||
|
//dState.RX = (byte)(((dState.RX - 127.5f - tempRsXDead) / (double)(maxXValue - tempRsXDead)) * maxXValue + 127.5f);
|
||||||
|
//dState.RY = (byte)(((dState.RY - 127.5f - tempRsYDead) / (double)(maxYValue - tempRsYDead)) * maxYValue + 127.5f);
|
||||||
//dState.RX = (byte)(Math.Cos(r) * (127.5f + RSDeadzone[device]) + 127.5f);
|
//dState.RX = (byte)(Math.Cos(r) * (127.5f + RSDeadzone[device]) + 127.5f);
|
||||||
//dState.RY = (byte)(Math.Sin(r) * (127.5f + RSDeadzone[device]) + 127.5f);
|
//dState.RY = (byte)(Math.Sin(r) * (127.5f + RSDeadzone[device]) + 127.5f);
|
||||||
}
|
}
|
||||||
@ -506,7 +542,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
if (cState.R2 > r2Deadzone)
|
if (cState.R2 > r2Deadzone)
|
||||||
{
|
{
|
||||||
dState.R2 = (byte)(((dState.R2 - l2Deadzone) / (double)(255 - r2Deadzone)) * 255);
|
dState.R2 = (byte)(((dState.R2 - r2Deadzone) / (double)(255 - r2Deadzone)) * 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -319,6 +319,8 @@ namespace DS4Windows
|
|||||||
public static double[] SZDeadzone => m_Config.SZDeadzone;
|
public static double[] SZDeadzone => m_Config.SZDeadzone;
|
||||||
public static int[] LSDeadzone => m_Config.LSDeadzone;
|
public static int[] LSDeadzone => m_Config.LSDeadzone;
|
||||||
public static int[] RSDeadzone => m_Config.RSDeadzone;
|
public static int[] RSDeadzone => m_Config.RSDeadzone;
|
||||||
|
public static int[] LSAntiDeadzone => m_Config.LSAntiDeadzone;
|
||||||
|
public static int[] RSAntiDeadzone => m_Config.RSAntiDeadzone;
|
||||||
public static int[] LSCurve => m_Config.lsCurve;
|
public static int[] LSCurve => m_Config.lsCurve;
|
||||||
public static int[] RSCurve => m_Config.rsCurve;
|
public static int[] RSCurve => m_Config.rsCurve;
|
||||||
public static double[] L2Sens => m_Config.l2Sens;
|
public static double[] L2Sens => m_Config.l2Sens;
|
||||||
@ -532,6 +534,7 @@ namespace DS4Windows
|
|||||||
public Byte[] touchSensitivity = { 100, 100, 100, 100, 100 };
|
public Byte[] touchSensitivity = { 100, 100, 100, 100, 100 };
|
||||||
public Byte[] l2Deadzone = { 0, 0, 0, 0, 0 }, r2Deadzone = { 0, 0, 0, 0, 0 };
|
public Byte[] l2Deadzone = { 0, 0, 0, 0, 0 }, r2Deadzone = { 0, 0, 0, 0, 0 };
|
||||||
public int[] LSDeadzone = { 0, 0, 0, 0, 0 }, RSDeadzone = { 0, 0, 0, 0, 0 };
|
public int[] LSDeadzone = { 0, 0, 0, 0, 0 }, RSDeadzone = { 0, 0, 0, 0, 0 };
|
||||||
|
public int[] LSAntiDeadzone = { 0, 0, 0, 0, 0 }, RSAntiDeadzone = { 0, 0, 0, 0, 0 };
|
||||||
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[] SXDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 }, SZDeadzone = { 0.25, 0.25, 0.25, 0.25, 0.25 };
|
||||||
public double[] l2Sens = { 1, 1, 1, 1, 1 }, r2Sens = { 1, 1, 1, 1, 1 };
|
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[] LSSens = { 1, 1, 1, 1, 1 }, RSSens = { 1, 1, 1, 1, 1 };
|
||||||
|
72
DS4Windows/DS4Forms/Options.Designer.cs
generated
72
DS4Windows/DS4Forms/Options.Designer.cs
generated
@ -302,6 +302,11 @@
|
|||||||
this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.antiDeadzoneTabPage = new System.Windows.Forms.TabPage();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.nUDLSAntiDead = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.nUDRSAntiDead = new System.Windows.Forms.NumericUpDown();
|
||||||
this.advColorDialog = new DS4Windows.AdvancedColorDialog();
|
this.advColorDialog = new DS4Windows.AdvancedColorDialog();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit();
|
||||||
@ -374,6 +379,9 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).BeginInit();
|
||||||
this.cMGyroTriggers.SuspendLayout();
|
this.cMGyroTriggers.SuspendLayout();
|
||||||
|
this.antiDeadzoneTabPage.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nUDRSAntiDead)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// lowColorChooserButton
|
// lowColorChooserButton
|
||||||
@ -2552,6 +2560,7 @@
|
|||||||
//
|
//
|
||||||
this.tCSens.Controls.Add(this.tPDeadzone);
|
this.tCSens.Controls.Add(this.tPDeadzone);
|
||||||
this.tCSens.Controls.Add(this.tPCurve);
|
this.tCSens.Controls.Add(this.tPCurve);
|
||||||
|
this.tCSens.Controls.Add(this.antiDeadzoneTabPage);
|
||||||
resources.ApplyResources(this.tCSens, "tCSens");
|
resources.ApplyResources(this.tCSens, "tCSens");
|
||||||
this.tCSens.Name = "tCSens";
|
this.tCSens.Name = "tCSens";
|
||||||
this.tCSens.SelectedIndex = 0;
|
this.tCSens.SelectedIndex = 0;
|
||||||
@ -3131,6 +3140,60 @@
|
|||||||
resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem");
|
resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem");
|
||||||
this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged);
|
this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
// antiDeadzoneTabPage
|
||||||
|
//
|
||||||
|
this.antiDeadzoneTabPage.Controls.Add(this.nUDRSAntiDead);
|
||||||
|
this.antiDeadzoneTabPage.Controls.Add(this.label2);
|
||||||
|
this.antiDeadzoneTabPage.Controls.Add(this.nUDLSAntiDead);
|
||||||
|
this.antiDeadzoneTabPage.Controls.Add(this.label1);
|
||||||
|
resources.ApplyResources(this.antiDeadzoneTabPage, "antiDeadzoneTabPage");
|
||||||
|
this.antiDeadzoneTabPage.Name = "antiDeadzoneTabPage";
|
||||||
|
this.antiDeadzoneTabPage.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
resources.ApplyResources(this.label1, "label1");
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
//
|
||||||
|
// nUDLSAntiDead
|
||||||
|
//
|
||||||
|
this.nUDLSAntiDead.DecimalPlaces = 2;
|
||||||
|
this.nUDLSAntiDead.Increment = new decimal(new int[] {
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
65536});
|
||||||
|
resources.ApplyResources(this.nUDLSAntiDead, "nUDLSAntiDead");
|
||||||
|
this.nUDLSAntiDead.Maximum = new decimal(new int[] {
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.nUDLSAntiDead.Name = "nUDLSAntiDead";
|
||||||
|
this.nUDLSAntiDead.ValueChanged += new System.EventHandler(this.nUDLSAntiDead_ValueChanged);
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
resources.ApplyResources(this.label2, "label2");
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
//
|
||||||
|
// nUDRSAntiDead
|
||||||
|
//
|
||||||
|
this.nUDRSAntiDead.DecimalPlaces = 2;
|
||||||
|
this.nUDRSAntiDead.Increment = new decimal(new int[] {
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
65536});
|
||||||
|
resources.ApplyResources(this.nUDRSAntiDead, "nUDRSAntiDead");
|
||||||
|
this.nUDRSAntiDead.Maximum = new decimal(new int[] {
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.nUDRSAntiDead.Name = "nUDRSAntiDead";
|
||||||
|
this.nUDRSAntiDead.ValueChanged += new System.EventHandler(this.nUDRSAntiDead_ValueChanged);
|
||||||
|
//
|
||||||
// Options
|
// Options
|
||||||
//
|
//
|
||||||
resources.ApplyResources(this, "$this");
|
resources.ApplyResources(this, "$this");
|
||||||
@ -3229,6 +3292,10 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.nUDSXS)).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.nUDSZS)).EndInit();
|
||||||
this.cMGyroTriggers.ResumeLayout(false);
|
this.cMGyroTriggers.ResumeLayout(false);
|
||||||
|
this.antiDeadzoneTabPage.ResumeLayout(false);
|
||||||
|
this.antiDeadzoneTabPage.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nUDLSAntiDead)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nUDRSAntiDead)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3510,5 +3577,10 @@
|
|||||||
private System.Windows.Forms.Button btnRainbow;
|
private System.Windows.Forms.Button btnRainbow;
|
||||||
private System.Windows.Forms.ToolStripMenuItem alwaysOnToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem alwaysOnToolStripMenuItem;
|
||||||
public System.Windows.Forms.ToolStripMenuItem fingerOnTouchpadToolStripMenuItem;
|
public System.Windows.Forms.ToolStripMenuItem fingerOnTouchpadToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.TabPage antiDeadzoneTabPage;
|
||||||
|
private System.Windows.Forms.NumericUpDown nUDRSAntiDead;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
private System.Windows.Forms.NumericUpDown nUDLSAntiDead;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2335,6 +2335,16 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void nUDLSAntiDead_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LSAntiDeadzone[device] = (byte)(nUDLSAntiDead.Value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void nUDRSAntiDead_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
RSAntiDeadzone[device] = (byte)(nUDRSAntiDead.Value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
private void Options_Resize(object sender, EventArgs e)
|
private void Options_Resize(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
fLPSettings.AutoScroll = false;
|
fLPSettings.AutoScroll = false;
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user