mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-26 16:41:50 +01:00
Group square stick profile properties into a class
This commit is contained in:
parent
4b901b3489
commit
157bb67951
@ -869,16 +869,16 @@ namespace DS4Windows
|
|||||||
if (r2Sens != 1.0)
|
if (r2Sens != 1.0)
|
||||||
dState.R2 = (byte)Global.Clamp(0, r2Sens * dState.R2, 255);
|
dState.R2 = (byte)Global.Clamp(0, r2Sens * dState.R2, 255);
|
||||||
|
|
||||||
if (getSquareStickLS(device) && (dState.LX != 128 || dState.LY != 128))
|
SquareStickInfo squStk = GetSquareStickInfo(device);
|
||||||
|
if (squStk.lsMode && (dState.LX != 128 || dState.LY != 128))
|
||||||
{
|
{
|
||||||
double capX = dState.LX >= 128 ? 127.0 : 128.0;
|
double capX = dState.LX >= 128 ? 127.0 : 128.0;
|
||||||
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(roundness);
|
sqstick.CircleToSquare(squStk.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;
|
||||||
@ -968,16 +968,15 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSquareStickRS(device) && (dState.RX != 128 || dState.RY != 128))
|
if (squStk.rsMode && (dState.RX != 128 || dState.RY != 128))
|
||||||
{
|
{
|
||||||
double capX = dState.RX >= 128 ? 127.0 : 128.0;
|
double capX = dState.RX >= 128 ? 127.0 : 128.0;
|
||||||
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(roundness);
|
sqstick.CircleToSquare(squStk.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
|
||||||
|
@ -1172,22 +1172,10 @@ namespace DS4Windows
|
|||||||
return m_Config.btPollRate[index];
|
return m_Config.btPollRate[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool[] squareStickLS => m_Config.sqLSStickMode;
|
public static SquareStickInfo[] SquStickInfo = m_Config.squStickInfo;
|
||||||
public static bool getSquareStickLS(int device)
|
public static SquareStickInfo GetSquareStickInfo(int device)
|
||||||
{
|
{
|
||||||
return m_Config.sqLSStickMode[device];
|
return m_Config.squStickInfo[device];
|
||||||
}
|
|
||||||
|
|
||||||
public static bool[] squareStickRS => m_Config.sqRSStickMode;
|
|
||||||
public static bool getSquareStickRS(int 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;
|
||||||
@ -1580,6 +1568,13 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SquareStickInfo
|
||||||
|
{
|
||||||
|
public bool lsMode;
|
||||||
|
public bool rsMode;
|
||||||
|
public double roundness = 5.0;
|
||||||
|
}
|
||||||
|
|
||||||
public class BackingStore
|
public class BackingStore
|
||||||
{
|
{
|
||||||
//public String m_Profile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool" + "\\Profiles.xml";
|
//public String m_Profile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool" + "\\Profiles.xml";
|
||||||
@ -1634,9 +1629,13 @@ namespace DS4Windows
|
|||||||
MouseCursor.GYRO_MOUSE_DEADZONE };
|
MouseCursor.GYRO_MOUSE_DEADZONE };
|
||||||
public bool[] gyroMouseToggle = new bool[5] { false, false, false,
|
public bool[] gyroMouseToggle = new bool[5] { false, false, 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 SquareStickInfo[] squStickInfo = new SquareStickInfo[5]
|
||||||
public double[] sqStickRoundness = new double[5] { 5.0, 5.0, 5.0, 5.0, 5.0 };
|
{
|
||||||
|
new SquareStickInfo(), new SquareStickInfo(),
|
||||||
|
new SquareStickInfo(), new SquareStickInfo(),
|
||||||
|
new SquareStickInfo(),
|
||||||
|
};
|
||||||
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 };
|
||||||
@ -2021,10 +2020,10 @@ namespace DS4Windows
|
|||||||
XmlNode xmlLsOutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "LSOutputCurveMode", null); xmlLsOutputCurveMode.InnerText = stickOutputCurveString(lsOutCurveMode[device]); Node.AppendChild(xmlLsOutputCurveMode);
|
XmlNode xmlLsOutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "LSOutputCurveMode", null); xmlLsOutputCurveMode.InnerText = stickOutputCurveString(lsOutCurveMode[device]); Node.AppendChild(xmlLsOutputCurveMode);
|
||||||
XmlNode xmlRsOutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "RSOutputCurveMode", null); xmlRsOutputCurveMode.InnerText = stickOutputCurveString(rsOutCurveMode[device]); Node.AppendChild(xmlRsOutputCurveMode);
|
XmlNode xmlRsOutputCurveMode = m_Xdoc.CreateNode(XmlNodeType.Element, "RSOutputCurveMode", null); xmlRsOutputCurveMode.InnerText = stickOutputCurveString(rsOutCurveMode[device]); Node.AppendChild(xmlRsOutputCurveMode);
|
||||||
|
|
||||||
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 = squStickInfo[device].lsMode.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 = squStickInfo[device].rsMode.ToString(); Node.AppendChild(xmlRsSquareStickMode);
|
||||||
|
|
||||||
XmlNode xmlSquareStickRoundness = m_Xdoc.CreateNode(XmlNodeType.Element, "SquareStickRoundness", null); xmlSquareStickRoundness.InnerText = sqStickRoundness[device].ToString(); Node.AppendChild(xmlSquareStickRoundness);
|
XmlNode xmlSquareStickRoundness = m_Xdoc.CreateNode(XmlNodeType.Element, "SquareStickRoundness", null); xmlSquareStickRoundness.InnerText = squStickInfo[device].roundness.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);
|
||||||
@ -2927,14 +2926,14 @@ namespace DS4Windows
|
|||||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSOutputCurveMode"); rsOutCurveMode[device] = stickOutputCurveId(Item.InnerText); }
|
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSOutputCurveMode"); rsOutCurveMode[device] = stickOutputCurveId(Item.InnerText); }
|
||||||
catch { rsOutCurveMode[device] = 0; missingSetting = true; }
|
catch { rsOutCurveMode[device] = 0; missingSetting = true; }
|
||||||
|
|
||||||
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 squStickInfo[device].lsMode); }
|
||||||
catch { sqLSStickMode[device] = false; missingSetting = true; }
|
catch { squStickInfo[device].lsMode = false; missingSetting = true; }
|
||||||
|
|
||||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SquareStickRoundness"); double.TryParse(Item.InnerText, out sqStickRoundness[device]); }
|
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SquareStickRoundness"); double.TryParse(Item.InnerText, out squStickInfo[device].roundness); }
|
||||||
catch { sqStickRoundness[device] = 5.0; missingSetting = true; }
|
catch { squStickInfo[device].roundness = 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 squStickInfo[device].rsMode); }
|
||||||
catch { sqRSStickMode[device] = false; missingSetting = true; }
|
catch { squStickInfo[device].rsMode = false; missingSetting = true; }
|
||||||
|
|
||||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/L2OutputCurveMode"); l2OutCurveMode[device] = axisOutputCurveId(Item.InnerText); }
|
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/L2OutputCurveMode"); l2OutCurveMode[device] = axisOutputCurveId(Item.InnerText); }
|
||||||
catch { l2OutCurveMode[device] = 0; missingSetting = true; }
|
catch { l2OutCurveMode[device] = 0; missingSetting = true; }
|
||||||
@ -4230,9 +4229,9 @@ namespace DS4Windows
|
|||||||
gyroSmoothing[device] = false;
|
gyroSmoothing[device] = false;
|
||||||
gyroSmoothWeight[device] = 0.5;
|
gyroSmoothWeight[device] = 0.5;
|
||||||
gyroMouseHorizontalAxis[device] = 0;
|
gyroMouseHorizontalAxis[device] = 0;
|
||||||
sqLSStickMode[device] = false;
|
squStickInfo[device].lsMode = false;
|
||||||
sqRSStickMode[device] = false;
|
squStickInfo[device].rsMode = false;
|
||||||
sqStickRoundness[device] = 5;
|
squStickInfo[device].roundness = 5;
|
||||||
lsOutCurveMode[device] = 0;
|
lsOutCurveMode[device] = 0;
|
||||||
rsOutCurveMode[device] = 0;
|
rsOutCurveMode[device] = 0;
|
||||||
l2OutCurveMode[device] = 0;
|
l2OutCurveMode[device] = 0;
|
||||||
|
@ -686,9 +686,9 @@ namespace DS4Windows.Forms
|
|||||||
btnBrowse.Text = Path.GetFileNameWithoutExtension(LaunchProgram[device]);
|
btnBrowse.Text = Path.GetFileNameWithoutExtension(LaunchProgram[device]);
|
||||||
}
|
}
|
||||||
|
|
||||||
lsSquStickCk.Checked = squareStickLS[device];
|
lsSquStickCk.Checked = SquStickInfo[device].lsMode;
|
||||||
rsSquStickCk.Checked = squareStickRS[device];
|
rsSquStickCk.Checked = SquStickInfo[device].rsMode;
|
||||||
RoundnessNUpDown.Value = (decimal)squareStickRoundness[device];
|
RoundnessNUpDown.Value = (decimal)SquStickInfo[device].roundness;
|
||||||
|
|
||||||
cBDinput.Checked = DinputOnly[device];
|
cBDinput.Checked = DinputOnly[device];
|
||||||
olddinputcheck = cBDinput.Checked;
|
olddinputcheck = cBDinput.Checked;
|
||||||
@ -1329,9 +1329,9 @@ namespace DS4Windows.Forms
|
|||||||
SZMaxzone[device] = (double)nUDSixAxisZMaxZone.Value;
|
SZMaxzone[device] = (double)nUDSixAxisZMaxZone.Value;
|
||||||
SXAntiDeadzone[device] = (double)nUDSixaxisXAntiDead.Value;
|
SXAntiDeadzone[device] = (double)nUDSixaxisXAntiDead.Value;
|
||||||
SZAntiDeadzone[device] = (double)nUDSixaxisZAntiDead.Value;
|
SZAntiDeadzone[device] = (double)nUDSixaxisZAntiDead.Value;
|
||||||
squareStickLS[device] = lsSquStickCk.Checked;
|
SquStickInfo[device].lsMode = lsSquStickCk.Checked;
|
||||||
squareStickRS[device] = rsSquStickCk.Checked;
|
SquStickInfo[device].rsMode = rsSquStickCk.Checked;
|
||||||
squareStickRoundness[device] = (double)RoundnessNUpDown.Value;
|
SquStickInfo[device].roundness = (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;
|
||||||
@ -3144,7 +3144,7 @@ namespace DS4Windows.Forms
|
|||||||
{
|
{
|
||||||
if (loading == false)
|
if (loading == false)
|
||||||
{
|
{
|
||||||
squareStickLS[device] = lsSquStickCk.Checked;
|
SquStickInfo[device].lsMode = lsSquStickCk.Checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3152,18 +3152,18 @@ namespace DS4Windows.Forms
|
|||||||
{
|
{
|
||||||
if (loading == false)
|
if (loading == false)
|
||||||
{
|
{
|
||||||
squareStickRS[device] = rsSquStickCk.Checked;
|
SquStickInfo[device].rsMode = rsSquStickCk.Checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RoundnessNUpDown_ValueChanged(object sender, EventArgs e)
|
private void RoundnessNUpDown_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (loading == false) {
|
if (loading == false) {
|
||||||
squareStickRoundness[device] = (int)RoundnessNUpDown.Value;
|
SquStickInfo[device].roundness = (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)
|
||||||
{
|
{
|
||||||
@ -3187,7 +3187,7 @@ namespace DS4Windows.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trackFrictionNUD_ValueChanged(object sender, EventArgs e)
|
private void trackFrictionNUD_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (loading == false)
|
if (loading == false)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user