Implemented square stick roundness selectability

This commit is contained in:
Kamilczak020 2019-06-25 23:42:08 +02:00
parent 5d9546f5bd
commit 4b901b3489
6 changed files with 3900 additions and 3796 deletions

View File

@ -102,10 +102,9 @@ namespace DS4Windows
squared = new DS4Vector2(0.0, 0.0); squared = new DS4Vector2(0.0, 0.0);
} }
public void CircleToSquare() public void CircleToSquare(double roundness)
{ {
const double PiOverFour = Math.PI / 4.0; const double PiOverFour = Math.PI / 4.0;
const double roundness = 5.0;
// Determine the theta angle // Determine the theta angle
double angle = Math.Atan2(current.y, -current.x); double angle = Math.Atan2(current.y, -current.x);
@ -876,9 +875,10 @@ namespace DS4Windows
double capY = dState.LY >= 128 ? 127.0 : 128.0; double capY = dState.LY >= 128 ? 127.0 : 128.0;
double tempX = (dState.LX - 128.0) / capX; double tempX = (dState.LX - 128.0) / capX;
double tempY = (dState.LY - 128.0) / capY; double tempY = (dState.LY - 128.0) / capY;
double roundness = getSquareStickRoundness(device);
DS4SquareStick sqstick = outSqrStk[device]; DS4SquareStick sqstick = outSqrStk[device];
sqstick.current.x = tempX; sqstick.current.y = tempY; sqstick.current.x = tempX; sqstick.current.y = tempY;
sqstick.CircleToSquare(); sqstick.CircleToSquare(roundness);
//Console.WriteLine("Input ({0}) | Output ({1})", tempY, sqstick.current.y); //Console.WriteLine("Input ({0}) | Output ({1})", tempY, sqstick.current.y);
tempX = sqstick.current.x < -1.0 ? -1.0 : sqstick.current.x > 1.0 tempX = sqstick.current.x < -1.0 ? -1.0 : sqstick.current.x > 1.0
? 1.0 : sqstick.current.x; ? 1.0 : sqstick.current.x;
@ -974,9 +974,10 @@ namespace DS4Windows
double capY = dState.RY >= 128 ? 127.0 : 128.0; double capY = dState.RY >= 128 ? 127.0 : 128.0;
double tempX = (dState.RX - 128.0) / capX; double tempX = (dState.RX - 128.0) / capX;
double tempY = (dState.RY - 128.0) / capY; double tempY = (dState.RY - 128.0) / capY;
double roundness = getSquareStickRoundness(device);
DS4SquareStick sqstick = outSqrStk[device]; DS4SquareStick sqstick = outSqrStk[device];
sqstick.current.x = tempX; sqstick.current.y = tempY; sqstick.current.x = tempX; sqstick.current.y = tempY;
sqstick.CircleToSquare(); sqstick.CircleToSquare(roundness);
tempX = sqstick.current.x < -1.0 ? -1.0 : sqstick.current.x > 1.0 tempX = sqstick.current.x < -1.0 ? -1.0 : sqstick.current.x > 1.0
? 1.0 : sqstick.current.x; ? 1.0 : sqstick.current.x;
tempY = sqstick.current.y < -1.0 ? -1.0 : sqstick.current.y > 1.0 tempY = sqstick.current.y < -1.0 ? -1.0 : sqstick.current.y > 1.0

View File

@ -1184,6 +1184,12 @@ namespace DS4Windows
return m_Config.sqRSStickMode[device]; return m_Config.sqRSStickMode[device];
} }
public static double[] squareStickRoundness => m_Config.sqStickRoundness;
public static double getSquareStickRoundness(int device)
{
return m_Config.sqStickRoundness[device];
}
public static int[] lsOutCurveMode => m_Config.lsOutCurveMode; public static int[] lsOutCurveMode => m_Config.lsOutCurveMode;
public static int getLsOutCurveMode(int index) public static int getLsOutCurveMode(int index)
{ {
@ -1630,6 +1636,7 @@ namespace DS4Windows
false, false }; false, false };
public bool[] sqLSStickMode = new bool[5] { false, false, false, false, false }; public bool[] sqLSStickMode = new bool[5] { false, false, false, false, false };
public bool[] sqRSStickMode = new bool[5] { false, false, false, false, false }; public bool[] sqRSStickMode = new bool[5] { false, false, false, false, false };
public double[] sqStickRoundness = new double[5] { 5.0, 5.0, 5.0, 5.0, 5.0 };
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 };
@ -2017,6 +2024,8 @@ namespace DS4Windows
XmlNode xmlLsSquareStickMode = m_Xdoc.CreateNode(XmlNodeType.Element, "LSSquareStick", null); xmlLsSquareStickMode.InnerText = sqLSStickMode[device].ToString(); Node.AppendChild(xmlLsSquareStickMode); XmlNode xmlLsSquareStickMode = m_Xdoc.CreateNode(XmlNodeType.Element, "LSSquareStick", null); xmlLsSquareStickMode.InnerText = sqLSStickMode[device].ToString(); Node.AppendChild(xmlLsSquareStickMode);
XmlNode xmlRsSquareStickMode = m_Xdoc.CreateNode(XmlNodeType.Element, "RSSquareStick", null); xmlRsSquareStickMode.InnerText = sqRSStickMode[device].ToString(); Node.AppendChild(xmlRsSquareStickMode); XmlNode xmlRsSquareStickMode = m_Xdoc.CreateNode(XmlNodeType.Element, "RSSquareStick", null); xmlRsSquareStickMode.InnerText = sqRSStickMode[device].ToString(); Node.AppendChild(xmlRsSquareStickMode);
XmlNode xmlSquareStickRoundness = m_Xdoc.CreateNode(XmlNodeType.Element, "SquareStickRoundness", null); xmlSquareStickRoundness.InnerText = sqStickRoundness[device].ToString(); Node.AppendChild(xmlSquareStickRoundness);
XmlNode xmlL2OutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "L2OutputCurveMode", null); xmlL2OutputCurveMode.InnerText = axisOutputCurveString(l2OutCurveMode[device]); Node.AppendChild(xmlL2OutputCurveMode); XmlNode xmlL2OutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "L2OutputCurveMode", null); xmlL2OutputCurveMode.InnerText = axisOutputCurveString(l2OutCurveMode[device]); Node.AppendChild(xmlL2OutputCurveMode);
XmlNode xmlR2OutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "R2OutputCurveMode", null); xmlR2OutputCurveMode.InnerText = axisOutputCurveString(r2OutCurveMode[device]); Node.AppendChild(xmlR2OutputCurveMode); XmlNode xmlR2OutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "R2OutputCurveMode", null); xmlR2OutputCurveMode.InnerText = axisOutputCurveString(r2OutCurveMode[device]); Node.AppendChild(xmlR2OutputCurveMode);
@ -2921,6 +2930,9 @@ namespace DS4Windows
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSSquareStick"); bool.TryParse(Item.InnerText, out sqLSStickMode[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSSquareStick"); bool.TryParse(Item.InnerText, out sqLSStickMode[device]); }
catch { sqLSStickMode[device] = false; missingSetting = true; } catch { sqLSStickMode[device] = false; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SquareStickRoundness"); double.TryParse(Item.InnerText, out sqStickRoundness[device]); }
catch { sqStickRoundness[device] = 5.0; missingSetting = true; }
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSSquareStick"); bool.TryParse(Item.InnerText, out sqRSStickMode[device]); } try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSSquareStick"); bool.TryParse(Item.InnerText, out sqRSStickMode[device]); }
catch { sqRSStickMode[device] = false; missingSetting = true; } catch { sqRSStickMode[device] = false; missingSetting = true; }
@ -4220,6 +4232,7 @@ namespace DS4Windows
gyroMouseHorizontalAxis[device] = 0; gyroMouseHorizontalAxis[device] = 0;
sqLSStickMode[device] = false; sqLSStickMode[device] = false;
sqRSStickMode[device] = false; sqRSStickMode[device] = false;
sqStickRoundness[device] = 5;
lsOutCurveMode[device] = 0; lsOutCurveMode[device] = 0;
rsOutCurveMode[device] = 0; rsOutCurveMode[device] = 0;
l2OutCurveMode[device] = 0; l2OutCurveMode[device] = 0;

View File

@ -293,6 +293,8 @@
this.nUDLSMaxZone = new System.Windows.Forms.NumericUpDown(); this.nUDLSMaxZone = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.squStickTabPage = new System.Windows.Forms.TabPage(); this.squStickTabPage = new System.Windows.Forms.TabPage();
this.RoundnessNUpDown = new System.Windows.Forms.NumericUpDown();
this.label28 = new System.Windows.Forms.Label();
this.rsSquStickCk = new System.Windows.Forms.CheckBox(); this.rsSquStickCk = new System.Windows.Forms.CheckBox();
this.lsSquStickCk = new System.Windows.Forms.CheckBox(); this.lsSquStickCk = new System.Windows.Forms.CheckBox();
this.tPOutCurve = new System.Windows.Forms.TabPage(); this.tPOutCurve = new System.Windows.Forms.TabPage();
@ -473,6 +475,7 @@
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).BeginInit();
this.squStickTabPage.SuspendLayout(); this.squStickTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.RoundnessNUpDown)).BeginInit();
this.tPOutCurve.SuspendLayout(); this.tPOutCurve.SuspendLayout();
this.tPCurve.SuspendLayout(); this.tPCurve.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nUDLSCurve)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDLSCurve)).BeginInit();
@ -3206,12 +3209,36 @@
// //
// squStickTabPage // squStickTabPage
// //
this.squStickTabPage.Controls.Add(this.RoundnessNUpDown);
this.squStickTabPage.Controls.Add(this.label28);
this.squStickTabPage.Controls.Add(this.rsSquStickCk); this.squStickTabPage.Controls.Add(this.rsSquStickCk);
this.squStickTabPage.Controls.Add(this.lsSquStickCk); this.squStickTabPage.Controls.Add(this.lsSquStickCk);
resources.ApplyResources(this.squStickTabPage, "squStickTabPage"); resources.ApplyResources(this.squStickTabPage, "squStickTabPage");
this.squStickTabPage.Name = "squStickTabPage"; this.squStickTabPage.Name = "squStickTabPage";
this.squStickTabPage.UseVisualStyleBackColor = true; this.squStickTabPage.UseVisualStyleBackColor = true;
// //
// RoundnessNUpDown
//
this.RoundnessNUpDown.DecimalPlaces = 1;
this.RoundnessNUpDown.Increment = new decimal(new int[] {
1,
0,
0,
65536});
resources.ApplyResources(this.RoundnessNUpDown, "RoundnessNUpDown");
this.RoundnessNUpDown.Maximum = new decimal(new int[] {
5,
0,
0,
0});
this.RoundnessNUpDown.Name = "RoundnessNUpDown";
this.RoundnessNUpDown.ValueChanged += new System.EventHandler(this.RoundnessNUpDown_ValueChanged);
//
// label28
//
resources.ApplyResources(this.label28, "label28");
this.label28.Name = "label28";
//
// rsSquStickCk // rsSquStickCk
// //
resources.ApplyResources(this.rsSquStickCk, "rsSquStickCk"); resources.ApplyResources(this.rsSquStickCk, "rsSquStickCk");
@ -4374,6 +4401,8 @@
((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDRSMaxZone)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nUDLSMaxZone)).EndInit();
this.squStickTabPage.ResumeLayout(false); this.squStickTabPage.ResumeLayout(false);
this.squStickTabPage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.RoundnessNUpDown)).EndInit();
this.tPOutCurve.ResumeLayout(false); this.tPOutCurve.ResumeLayout(false);
this.tPOutCurve.PerformLayout(); this.tPOutCurve.PerformLayout();
this.tPCurve.ResumeLayout(false); this.tPCurve.ResumeLayout(false);
@ -4782,5 +4811,7 @@
private System.Windows.Forms.CheckBox lsSquStickCk; private System.Windows.Forms.CheckBox lsSquStickCk;
private System.Windows.Forms.ComboBox OutContTypeCb; private System.Windows.Forms.ComboBox OutContTypeCb;
private System.Windows.Forms.Label outcontLb; private System.Windows.Forms.Label outcontLb;
private System.Windows.Forms.Label label28;
private System.Windows.Forms.NumericUpDown RoundnessNUpDown;
} }
} }

View File

@ -688,6 +688,7 @@ namespace DS4Windows.Forms
lsSquStickCk.Checked = squareStickLS[device]; lsSquStickCk.Checked = squareStickLS[device];
rsSquStickCk.Checked = squareStickRS[device]; rsSquStickCk.Checked = squareStickRS[device];
RoundnessNUpDown.Value = (decimal)squareStickRoundness[device];
cBDinput.Checked = DinputOnly[device]; cBDinput.Checked = DinputOnly[device];
olddinputcheck = cBDinput.Checked; olddinputcheck = cBDinput.Checked;
@ -1330,6 +1331,7 @@ namespace DS4Windows.Forms
SZAntiDeadzone[device] = (double)nUDSixaxisZAntiDead.Value; SZAntiDeadzone[device] = (double)nUDSixaxisZAntiDead.Value;
squareStickLS[device] = lsSquStickCk.Checked; squareStickLS[device] = lsSquStickCk.Checked;
squareStickRS[device] = rsSquStickCk.Checked; squareStickRS[device] = rsSquStickCk.Checked;
squareStickRoundness[device] = (double)RoundnessNUpDown.Value;
MouseAccel[device] = cBMouseAccel.Checked; MouseAccel[device] = cBMouseAccel.Checked;
DinputOnly[device] = cBDinput.Checked; DinputOnly[device] = cBDinput.Checked;
StartTouchpadOff[device] = cbStartTouchpadOff.Checked; StartTouchpadOff[device] = cbStartTouchpadOff.Checked;
@ -3154,6 +3156,13 @@ namespace DS4Windows.Forms
} }
} }
private void RoundnessNUpDown_ValueChanged(object sender, EventArgs e)
{
if (loading == false) {
squareStickRoundness[device] = (int)RoundnessNUpDown.Value;
}
}
private void OutContTypeCb_SelectedIndexChanged(object sender, EventArgs e) private void OutContTypeCb_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (loading == false) if (loading == false)

View File

@ -7165,14 +7165,62 @@ with profile</value>
<data name="&gt;&gt;maxZoneTabPage.ZOrder" xml:space="preserve"> <data name="&gt;&gt;maxZoneTabPage.ZOrder" xml:space="preserve">
<value>2</value> <value>2</value>
</data> </data>
<data name="RoundnessNUpDown.Location" type="System.Drawing.Point, System.Drawing">
<value>216, 17</value>
</data>
<data name="RoundnessNUpDown.Size" type="System.Drawing.Size, System.Drawing">
<value>36, 20</value>
</data>
<data name="RoundnessNUpDown.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="&gt;&gt;RoundnessNUpDown.Name" xml:space="preserve">
<value>RoundnessNUpDown</value>
</data>
<data name="&gt;&gt;RoundnessNUpDown.Type" xml:space="preserve">
<value>System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;RoundnessNUpDown.Parent" xml:space="preserve">
<value>squStickTabPage</value>
</data>
<data name="&gt;&gt;RoundnessNUpDown.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="label28.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label28.Location" type="System.Drawing.Point, System.Drawing">
<value>141, 19</value>
</data>
<data name="label28.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 13</value>
</data>
<data name="label28.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="label28.Text" xml:space="preserve">
<value>Roundness</value>
</data>
<data name="&gt;&gt;label28.Name" xml:space="preserve">
<value>label28</value>
</data>
<data name="&gt;&gt;label28.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label28.Parent" xml:space="preserve">
<value>squStickTabPage</value>
</data>
<data name="&gt;&gt;label28.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="rsSquStickCk.Location" type="System.Drawing.Point, System.Drawing"> <data name="rsSquStickCk.Location" type="System.Drawing.Point, System.Drawing">
<value>130, 13</value> <value>70, 14</value>
</data> </data>
<data name="rsSquStickCk.RightToLeft" type="System.Windows.Forms.RightToLeft, System.Windows.Forms"> <data name="rsSquStickCk.RightToLeft" type="System.Windows.Forms.RightToLeft, System.Windows.Forms">
<value>No</value> <value>No</value>
</data> </data>
<data name="rsSquStickCk.Size" type="System.Drawing.Size, System.Drawing"> <data name="rsSquStickCk.Size" type="System.Drawing.Size, System.Drawing">
<value>104, 24</value> <value>43, 24</value>
</data> </data>
<data name="rsSquStickCk.TabIndex" type="System.Int32, mscorlib"> <data name="rsSquStickCk.TabIndex" type="System.Int32, mscorlib">
<value>1</value> <value>1</value>
@ -7190,16 +7238,16 @@ with profile</value>
<value>squStickTabPage</value> <value>squStickTabPage</value>
</data> </data>
<data name="&gt;&gt;rsSquStickCk.ZOrder" xml:space="preserve"> <data name="&gt;&gt;rsSquStickCk.ZOrder" xml:space="preserve">
<value>0</value> <value>2</value>
</data> </data>
<data name="lsSquStickCk.Location" type="System.Drawing.Point, System.Drawing"> <data name="lsSquStickCk.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 13</value> <value>10, 14</value>
</data> </data>
<data name="lsSquStickCk.RightToLeft" type="System.Windows.Forms.RightToLeft, System.Windows.Forms"> <data name="lsSquStickCk.RightToLeft" type="System.Windows.Forms.RightToLeft, System.Windows.Forms">
<value>No</value> <value>No</value>
</data> </data>
<data name="lsSquStickCk.Size" type="System.Drawing.Size, System.Drawing"> <data name="lsSquStickCk.Size" type="System.Drawing.Size, System.Drawing">
<value>91, 24</value> <value>48, 24</value>
</data> </data>
<data name="lsSquStickCk.TabIndex" type="System.Int32, mscorlib"> <data name="lsSquStickCk.TabIndex" type="System.Int32, mscorlib">
<value>0</value> <value>0</value>
@ -7217,7 +7265,7 @@ with profile</value>
<value>squStickTabPage</value> <value>squStickTabPage</value>
</data> </data>
<data name="&gt;&gt;lsSquStickCk.ZOrder" xml:space="preserve"> <data name="&gt;&gt;lsSquStickCk.ZOrder" xml:space="preserve">
<value>1</value> <value>3</value>
</data> </data>
<data name="squStickTabPage.Location" type="System.Drawing.Point, System.Drawing"> <data name="squStickTabPage.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 22</value> <value>4, 22</value>

View File

@ -28,6 +28,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>