mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-22 17:29:18 +01:00
Add vertical scale for gyro mouse mode
This commit is contained in:
parent
a4b540d62c
commit
588c2d4385
@ -18,6 +18,8 @@ namespace DS4Windows
|
||||
private Direction horizontalDirection = Direction.Neutral, verticalDirection = Direction.Neutral;
|
||||
private Direction hDirection = Direction.Neutral, vDirection = Direction.Neutral;
|
||||
|
||||
double verticalScale = 0.0;
|
||||
|
||||
public virtual void sixaxisMoved(SixAxisEventArgs arg)
|
||||
{
|
||||
int deltaX = 0, deltaY = 0;
|
||||
@ -25,8 +27,8 @@ namespace DS4Windows
|
||||
deltaY = -arg.sixAxis.gyroYFull;
|
||||
//Console.WriteLine(arg.sixAxis.deltaX);
|
||||
|
||||
double coefficient = Global.GyroSensitivity[deviceNumber] / 100f * 0.008;
|
||||
double offset = 0.1;
|
||||
double coefficient = (Global.getGyroSensitivity(deviceNumber) * 0.1) * 0.008;
|
||||
double offset = 0.12;
|
||||
double tempAngle = System.Math.Atan2(-deltaY, deltaX);
|
||||
double normX = System.Math.Abs(System.Math.Cos(tempAngle));
|
||||
double normY = System.Math.Abs(System.Math.Sin(tempAngle));
|
||||
@ -43,7 +45,7 @@ namespace DS4Windows
|
||||
vRemainder = 0.0;
|
||||
}
|
||||
|
||||
int deadzone = 14;
|
||||
int deadzone = 13;
|
||||
//int deadzone = 0;
|
||||
int deadzoneX = (int)System.Math.Abs(normX * deadzone);
|
||||
int deadzoneY = (int)System.Math.Abs(normY * deadzone);
|
||||
@ -80,7 +82,8 @@ namespace DS4Windows
|
||||
}
|
||||
|
||||
//hRemainder -= (int)hRemainder;
|
||||
double yMotion = deltaY != 0 ? coefficient * deltaY + (normY * (offset * signY)) : 0;
|
||||
verticalScale = Global.getGyroSensVerticalScale(deviceNumber) * 0.1;
|
||||
double yMotion = deltaY != 0 ? (coefficient * verticalScale) * deltaY + (normY * (offset * signY)) : 0;
|
||||
int yAction = 0;
|
||||
if (yMotion != 0.0)
|
||||
{
|
||||
@ -95,7 +98,7 @@ namespace DS4Windows
|
||||
|
||||
//vRemainder -= (int)vRemainder;
|
||||
|
||||
int gyroInvert = Global.GyroInvert[deviceNumber];
|
||||
int gyroInvert = Global.getGyroInvert(deviceNumber);
|
||||
if (gyroInvert == 2 || gyroInvert == 3)
|
||||
xAction *= -1;
|
||||
|
||||
|
@ -578,6 +578,12 @@ namespace DS4Windows
|
||||
return m_Config.gyroSensitivity[index];
|
||||
}
|
||||
|
||||
public static int[] GyroSensVerticalScale => m_Config.gyroSensVerticalScale;
|
||||
public static int getGyroSensVerticalScale(int index)
|
||||
{
|
||||
return m_Config.gyroSensVerticalScale[index];
|
||||
}
|
||||
|
||||
public static int[] GyroInvert => m_Config.gyroInvert;
|
||||
public static int getGyroInvert(int index)
|
||||
{
|
||||
@ -1231,6 +1237,7 @@ namespace DS4Windows
|
||||
public bool[] containsCustomExtras = { false, false, false, false, false };
|
||||
|
||||
public int[] gyroSensitivity = { 100, 100, 100, 100, 100 };
|
||||
public int[] gyroSensVerticalScale = { 100, 100, 100, 100, 100 };
|
||||
public int[] gyroInvert = { 0, 0, 0, 0, 0 };
|
||||
public bool[] gyroTriggerTurns = { true, true, true, true, true };
|
||||
|
||||
@ -1440,6 +1447,7 @@ namespace DS4Windows
|
||||
XmlNode xmlUseSAforMouse = m_Xdoc.CreateNode(XmlNodeType.Element, "UseSAforMouse", null); xmlUseSAforMouse.InnerText = useSAforMouse[device].ToString(); Node.AppendChild(xmlUseSAforMouse);
|
||||
XmlNode xmlSATriggers = m_Xdoc.CreateNode(XmlNodeType.Element, "SATriggers", null); xmlSATriggers.InnerText = sATriggers[device].ToString(); Node.AppendChild(xmlSATriggers);
|
||||
XmlNode xmlGyroSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSensitivity", null); xmlGyroSensitivity.InnerText = gyroSensitivity[device].ToString(); Node.AppendChild(xmlGyroSensitivity);
|
||||
XmlNode xmlGyroSensVerticalScale = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroSensVerticalScale", null); xmlGyroSensVerticalScale.InnerText = gyroSensVerticalScale[device].ToString(); Node.AppendChild(xmlGyroSensVerticalScale);
|
||||
XmlNode xmlGyroInvert = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroInvert", null); xmlGyroInvert.InnerText = gyroInvert[device].ToString(); Node.AppendChild(xmlGyroInvert);
|
||||
XmlNode xmlGyroTriggerTurns = m_Xdoc.CreateNode(XmlNodeType.Element, "GyroTriggerTurns", null); xmlGyroTriggerTurns.InnerText = gyroTriggerTurns[device].ToString(); Node.AppendChild(xmlGyroTriggerTurns);
|
||||
XmlNode xmlLSC = m_Xdoc.CreateNode(XmlNodeType.Element, "LSCurve", null); xmlLSC.InnerText = lsCurve[device].ToString(); Node.AppendChild(xmlLSC);
|
||||
@ -2351,6 +2359,9 @@ namespace DS4Windows
|
||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroSensitivity"); int.TryParse(Item.InnerText, out gyroSensitivity[device]); }
|
||||
catch { gyroSensitivity[device] = 100; missingSetting = true; }
|
||||
|
||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroSensVerticalScale"); int.TryParse(Item.InnerText, out gyroSensVerticalScale[device]); }
|
||||
catch { gyroSensVerticalScale[device] = 100; missingSetting = true; }
|
||||
|
||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/GyroInvert"); int.TryParse(Item.InnerText, out gyroInvert[device]); }
|
||||
catch { gyroInvert[device] = 0; missingSetting = true; }
|
||||
|
||||
@ -3406,6 +3417,7 @@ namespace DS4Windows
|
||||
sATriggers[device] = "";
|
||||
lsCurve[device] = rsCurve[device] = 0;
|
||||
gyroSensitivity[device] = 100;
|
||||
gyroSensVerticalScale[device] = 100;
|
||||
gyroInvert[device] = 0;
|
||||
lsOutCurveMode[device] = 0;
|
||||
rsOutCurveMode[device] = 0;
|
||||
|
58
DS4Windows/DS4Forms/Options.Designer.cs
generated
58
DS4Windows/DS4Forms/Options.Designer.cs
generated
@ -287,6 +287,9 @@
|
||||
this.rBSAControls = new System.Windows.Forms.RadioButton();
|
||||
this.rBSAMouse = new System.Windows.Forms.RadioButton();
|
||||
this.pnlSAMouse = new System.Windows.Forms.Panel();
|
||||
this.nUDGyroMouseVertScale = new System.Windows.Forms.NumericUpDown();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.gyroTriggerBehavior = new System.Windows.Forms.CheckBox();
|
||||
this.cBGyroInvertY = new System.Windows.Forms.CheckBox();
|
||||
this.cBGyroInvertX = new System.Windows.Forms.CheckBox();
|
||||
this.lbGyroInvert = new System.Windows.Forms.Label();
|
||||
@ -328,8 +331,8 @@
|
||||
this.shareToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.pSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.alwaysOnToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.gyroTriggerBehavior = new System.Windows.Forms.CheckBox();
|
||||
this.advColorDialog = new DS4Windows.AdvancedColorDialog();
|
||||
this.label12 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nUDRainbow)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tBBlueBar)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tBGreenBar)).BeginInit();
|
||||
@ -403,6 +406,7 @@
|
||||
this.fLPSettings.SuspendLayout();
|
||||
this.gBGyro.SuspendLayout();
|
||||
this.pnlSAMouse.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nUDGyroMouseVertScale)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nUDGyroSensitivity)).BeginInit();
|
||||
this.gBSensitivity.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nUDL2S)).BeginInit();
|
||||
@ -3013,6 +3017,9 @@
|
||||
//
|
||||
// pnlSAMouse
|
||||
//
|
||||
this.pnlSAMouse.Controls.Add(this.label12);
|
||||
this.pnlSAMouse.Controls.Add(this.nUDGyroMouseVertScale);
|
||||
this.pnlSAMouse.Controls.Add(this.label11);
|
||||
this.pnlSAMouse.Controls.Add(this.gyroTriggerBehavior);
|
||||
this.pnlSAMouse.Controls.Add(this.cBGyroInvertY);
|
||||
this.pnlSAMouse.Controls.Add(this.cBGyroInvertX);
|
||||
@ -3024,6 +3031,41 @@
|
||||
resources.ApplyResources(this.pnlSAMouse, "pnlSAMouse");
|
||||
this.pnlSAMouse.Name = "pnlSAMouse";
|
||||
//
|
||||
// nUDGyroMouseVertScale
|
||||
//
|
||||
this.nUDGyroMouseVertScale.Increment = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
65536});
|
||||
resources.ApplyResources(this.nUDGyroMouseVertScale, "nUDGyroMouseVertScale");
|
||||
this.nUDGyroMouseVertScale.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nUDGyroMouseVertScale.Name = "nUDGyroMouseVertScale";
|
||||
this.nUDGyroMouseVertScale.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.nUDGyroMouseVertScale.ValueChanged += new System.EventHandler(this.nUDGyroMouseVertScale_ValueChanged);
|
||||
//
|
||||
// label11
|
||||
//
|
||||
resources.ApplyResources(this.label11, "label11");
|
||||
this.label11.Name = "label11";
|
||||
//
|
||||
// gyroTriggerBehavior
|
||||
//
|
||||
resources.ApplyResources(this.gyroTriggerBehavior, "gyroTriggerBehavior");
|
||||
this.gyroTriggerBehavior.Checked = true;
|
||||
this.gyroTriggerBehavior.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.gyroTriggerBehavior.Name = "gyroTriggerBehavior";
|
||||
this.gyroTriggerBehavior.UseVisualStyleBackColor = true;
|
||||
this.gyroTriggerBehavior.CheckedChanged += new System.EventHandler(this.gyroTriggerBehavior_CheckedChanged);
|
||||
//
|
||||
// cBGyroInvertY
|
||||
//
|
||||
resources.ApplyResources(this.cBGyroInvertY, "cBGyroInvertY");
|
||||
@ -3476,14 +3518,10 @@
|
||||
resources.ApplyResources(this.alwaysOnToolStripMenuItem, "alwaysOnToolStripMenuItem");
|
||||
this.alwaysOnToolStripMenuItem.CheckedChanged += new System.EventHandler(this.SATrigger_CheckedChanged);
|
||||
//
|
||||
// gyroTriggerBehavior
|
||||
// label12
|
||||
//
|
||||
resources.ApplyResources(this.gyroTriggerBehavior, "gyroTriggerBehavior");
|
||||
this.gyroTriggerBehavior.Checked = true;
|
||||
this.gyroTriggerBehavior.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.gyroTriggerBehavior.Name = "gyroTriggerBehavior";
|
||||
this.gyroTriggerBehavior.UseVisualStyleBackColor = true;
|
||||
this.gyroTriggerBehavior.CheckedChanged += new System.EventHandler(this.gyroTriggerBehavior_CheckedChanged);
|
||||
resources.ApplyResources(this.label12, "label12");
|
||||
this.label12.Name = "label12";
|
||||
//
|
||||
// Options
|
||||
//
|
||||
@ -3586,6 +3624,7 @@
|
||||
this.gBGyro.PerformLayout();
|
||||
this.pnlSAMouse.ResumeLayout(false);
|
||||
this.pnlSAMouse.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nUDGyroMouseVertScale)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nUDGyroSensitivity)).EndInit();
|
||||
this.gBSensitivity.ResumeLayout(false);
|
||||
this.gBSensitivity.PerformLayout();
|
||||
@ -3904,5 +3943,8 @@
|
||||
private System.Windows.Forms.Label label10;
|
||||
private System.Windows.Forms.Label label9;
|
||||
private System.Windows.Forms.CheckBox gyroTriggerBehavior;
|
||||
private System.Windows.Forms.NumericUpDown nUDGyroMouseVertScale;
|
||||
private System.Windows.Forms.Label label11;
|
||||
private System.Windows.Forms.Label label12;
|
||||
}
|
||||
}
|
@ -361,7 +361,6 @@ namespace DS4Windows
|
||||
btPollRateComboBox.SelectedIndex = getBTPollRate(device);
|
||||
lsOutCurveComboBox.SelectedIndex = getLsOutCurveMode(device);
|
||||
rsOutCurveComboBox.SelectedIndex = getRsOutCurveMode(device);
|
||||
gyroTriggerBehavior.Checked = getGyroTriggerTurns(device);
|
||||
|
||||
try
|
||||
{
|
||||
@ -575,6 +574,8 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
nUDGyroSensitivity.Value = GyroSensitivity[device];
|
||||
gyroTriggerBehavior.Checked = GyroTriggerTurns[device];
|
||||
nUDGyroMouseVertScale.Value = GyroSensVerticalScale[device];
|
||||
int invert = GyroInvert[device];
|
||||
cBGyroInvertX.Checked = invert == 2 || invert == 3;
|
||||
cBGyroInvertY.Checked = invert == 1 || invert == 3;
|
||||
@ -595,7 +596,7 @@ namespace DS4Windows
|
||||
cbStartTouchpadOff.Checked = false;
|
||||
rBSAControls.Checked = true;
|
||||
rBTPMouse.Checked = true;
|
||||
gyroTriggerBehavior.Checked = true;
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case 0: tBRedBar.Value = 0; tBGreenBar.Value = 0; tBBlueBar.Value = 255; break;
|
||||
@ -662,6 +663,8 @@ namespace DS4Windows
|
||||
cBControllerInput.Checked = DS4Mapping;
|
||||
((ToolStripMenuItem)cMGyroTriggers.Items[cMGyroTriggers.Items.Count - 1]).Checked = true;
|
||||
nUDGyroSensitivity.Value = 100;
|
||||
nUDGyroMouseVertScale.Value = 100;
|
||||
gyroTriggerBehavior.Checked = true;
|
||||
cBGyroInvertX.Checked = false;
|
||||
cBGyroInvertY.Checked = false;
|
||||
Set();
|
||||
@ -1299,7 +1302,6 @@ namespace DS4Windows
|
||||
StartTouchpadOff[device] = cbStartTouchpadOff.Checked;
|
||||
UseTPforControls[device] = rBTPControls.Checked;
|
||||
UseSAforMouse[device] = rBSAMouse.Checked;
|
||||
GyroTriggerTurns[device] = gyroTriggerBehavior.Checked;
|
||||
DS4Mapping = cBControllerInput.Checked;
|
||||
LSCurve[device] = (int)Math.Round(nUDLSCurve.Value, 0);
|
||||
RSCurve[device] = (int)Math.Round(nUDRSCurve.Value, 0);
|
||||
@ -1320,6 +1322,9 @@ namespace DS4Windows
|
||||
fLPTouchSwipe.Visible = rBTPControls.Checked;
|
||||
|
||||
GyroSensitivity[device] = (int)Math.Round(nUDGyroSensitivity.Value, 0);
|
||||
GyroTriggerTurns[device] = gyroTriggerBehavior.Checked;
|
||||
GyroSensVerticalScale[device] = (int)nUDGyroMouseVertScale.Value;
|
||||
|
||||
int invert = 0;
|
||||
if (cBGyroInvertX.Checked)
|
||||
invert += 2;
|
||||
@ -1330,7 +1335,7 @@ namespace DS4Windows
|
||||
GyroInvert[device] = invert;
|
||||
|
||||
List<int> ints = new List<int>();
|
||||
for (int i = 0; i < cMGyroTriggers.Items.Count - 1; i++)
|
||||
for (int i = 0, trigLen = cMGyroTriggers.Items.Count - 1; i < trigLen; i++)
|
||||
{
|
||||
if (((ToolStripMenuItem)cMGyroTriggers.Items[i]).Checked)
|
||||
ints.Add(i);
|
||||
@ -2241,6 +2246,7 @@ namespace DS4Windows
|
||||
case "nUDSixaxis": root.lbLastMessage.Text = Properties.Resources.UseControllerForMapping; break;
|
||||
case "cBControllerInput": root.lbLastMessage.Text = Properties.Resources.UseControllerForMapping; break;
|
||||
case "lbUseController": root.lbLastMessage.Text = Properties.Resources.UseControllerForMapping; break;
|
||||
case "gyroTriggerBehavior": root.lbLastMessage.Text = Properties.Resources.GyroTriggerBehavior; break;
|
||||
default: root.lbLastMessage.Text = Properties.Resources.HoverOverItems; break;
|
||||
}
|
||||
|
||||
@ -2814,6 +2820,14 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
private void nUDGyroMouseVertScale_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!loading)
|
||||
{
|
||||
GyroSensVerticalScale[device] = (int)nUDGyroMouseVertScale.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Options_Resize(object sender, EventArgs e)
|
||||
{
|
||||
fLPSettings.AutoScroll = false;
|
||||
|
File diff suppressed because it is too large
Load Diff
9
DS4Windows/Properties/Resources.Designer.cs
generated
9
DS4Windows/Properties/Resources.Designer.cs
generated
@ -927,6 +927,15 @@ namespace DS4Windows.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Check to have gyro active while trigger is active. Uncheck to disable gyro while trigger is active..
|
||||
/// </summary>
|
||||
internal static string GyroTriggerBehavior {
|
||||
get {
|
||||
return ResourceManager.GetString("GyroTriggerBehavior", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to GyroX, Left and Right Tilt.
|
||||
/// </summary>
|
||||
|
@ -784,4 +784,7 @@
|
||||
<data name="BTPollRate" xml:space="preserve">
|
||||
<value>Determines the poll rate used for the DS4 hardware when connected via Bluetooth</value>
|
||||
</data>
|
||||
<data name="GyroTriggerBehavior" xml:space="preserve">
|
||||
<value>Check to have gyro active while trigger is active. Uncheck to disable gyro while trigger is active.</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user