mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-25 10:46:51 +01:00
Make max output setting for LS and RS
Maybe implement for other axes later
This commit is contained in:
parent
660b865204
commit
fad0ddda26
@ -630,8 +630,9 @@ namespace DS4Windows
|
||||
int lsDeadzone = lsMod.deadZone;
|
||||
int lsAntiDead = lsMod.antiDeadZone;
|
||||
int lsMaxZone = lsMod.maxZone;
|
||||
double lsMaxOutput = lsMod.maxOutput;
|
||||
|
||||
if (lsDeadzone > 0 || lsAntiDead > 0 || lsMaxZone != 100)
|
||||
if (lsDeadzone > 0 || lsAntiDead > 0 || lsMaxZone != 100 || lsMaxOutput != 100.0)
|
||||
{
|
||||
double lsSquared = Math.Pow(cState.LX - 128f, 2) + Math.Pow(cState.LY - 128f, 2);
|
||||
double lsDeadzoneSquared = Math.Pow(lsDeadzone, 2);
|
||||
@ -640,12 +641,13 @@ namespace DS4Windows
|
||||
dState.LX = 128;
|
||||
dState.LY = 128;
|
||||
}
|
||||
else if ((lsDeadzone > 0 && lsSquared > lsDeadzoneSquared) || lsAntiDead > 0 || lsMaxZone != 100)
|
||||
else if ((lsDeadzone > 0 && lsSquared > lsDeadzoneSquared) || lsAntiDead > 0 || lsMaxZone != 100 || lsMaxOutput != 100.0)
|
||||
{
|
||||
double r = Math.Atan2(-(dState.LY - 128.0), (dState.LX - 128.0));
|
||||
double maxXValue = dState.LX >= 128.0 ? 127.0 : -128;
|
||||
double maxYValue = dState.LY >= 128.0 ? 127.0 : -128;
|
||||
double ratio = lsMaxZone / 100.0;
|
||||
double maxOutRatio = lsMaxOutput / 100.0;
|
||||
|
||||
double maxZoneXNegValue = (ratio * -128) + 128;
|
||||
double maxZoneXPosValue = (ratio * 127) + 128;
|
||||
@ -677,6 +679,14 @@ namespace DS4Windows
|
||||
tempOutputY = (currentY - 128.0) / maxZoneY;
|
||||
}
|
||||
|
||||
if (lsMaxOutput != 100.0)
|
||||
{
|
||||
double maxOutXRatio = Math.Abs(Math.Cos(r)) * maxOutRatio;
|
||||
double maxOutYRatio = Math.Abs(Math.Sin(r)) * maxOutRatio;
|
||||
tempOutputX = Math.Min(Math.Max(tempOutputX, 0.0), maxOutXRatio);
|
||||
tempOutputY = Math.Min(Math.Max(tempOutputY, 0.0), maxOutYRatio);
|
||||
}
|
||||
|
||||
double tempLsXAntiDeadPercent = 0.0, tempLsYAntiDeadPercent = 0.0;
|
||||
if (lsAntiDead > 0)
|
||||
{
|
||||
@ -712,7 +722,9 @@ namespace DS4Windows
|
||||
int rsDeadzone = rsMod.deadZone;
|
||||
int rsAntiDead = rsMod.antiDeadZone;
|
||||
int rsMaxZone = rsMod.maxZone;
|
||||
if (rsDeadzone > 0 || rsAntiDead > 0 || rsMaxZone != 100)
|
||||
double rsMaxOutput = rsMod.maxOutput;
|
||||
|
||||
if (rsDeadzone > 0 || rsAntiDead > 0 || rsMaxZone != 100 || rsMaxOutput != 100.0)
|
||||
{
|
||||
double rsSquared = Math.Pow(cState.RX - 128.0, 2) + Math.Pow(cState.RY - 128.0, 2);
|
||||
double rsDeadzoneSquared = Math.Pow(rsDeadzone, 2);
|
||||
@ -721,12 +733,13 @@ namespace DS4Windows
|
||||
dState.RX = 128;
|
||||
dState.RY = 128;
|
||||
}
|
||||
else if ((rsDeadzone > 0 && rsSquared > rsDeadzoneSquared) || rsAntiDead > 0 || rsMaxZone != 100)
|
||||
else if ((rsDeadzone > 0 && rsSquared > rsDeadzoneSquared) || rsAntiDead > 0 || rsMaxZone != 100 || rsMaxOutput != 100.0)
|
||||
{
|
||||
double r = Math.Atan2(-(dState.RY - 128.0), (dState.RX - 128.0));
|
||||
double maxXValue = dState.RX >= 128.0 ? 127 : -128;
|
||||
double maxYValue = dState.RY >= 128.0 ? 127 : -128;
|
||||
double ratio = rsMaxZone / 100.0;
|
||||
double maxOutRatio = rsMaxOutput / 100.0;
|
||||
|
||||
double maxZoneXNegValue = (ratio * -128.0) + 128.0;
|
||||
double maxZoneXPosValue = (ratio * 127.0) + 128.0;
|
||||
@ -760,6 +773,14 @@ namespace DS4Windows
|
||||
tempOutputY = (currentY - 128.0) / maxZoneY;
|
||||
}
|
||||
|
||||
if (rsMaxOutput != 100.0)
|
||||
{
|
||||
double maxOutXRatio = Math.Abs(Math.Cos(r)) * maxOutRatio;
|
||||
double maxOutYRatio = Math.Abs(Math.Sin(r)) * maxOutRatio;
|
||||
tempOutputX = Math.Min(Math.Max(tempOutputX, 0.0), maxOutXRatio);
|
||||
tempOutputY = Math.Min(Math.Max(tempOutputY, 0.0), maxOutYRatio);
|
||||
}
|
||||
|
||||
double tempRsXAntiDeadPercent = 0.0, tempRsYAntiDeadPercent = 0.0;
|
||||
if (rsAntiDead > 0)
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ namespace DS4Windows
|
||||
public int deadZone;
|
||||
public int antiDeadZone;
|
||||
public int maxZone = 100;
|
||||
public double maxOutput = 100.0;
|
||||
}
|
||||
|
||||
public class TriggerDeadZoneZInfo
|
||||
|
@ -2488,6 +2488,8 @@ namespace DS4Windows
|
||||
XmlNode xmlRSAD = m_Xdoc.CreateNode(XmlNodeType.Element, "RSAntiDeadZone", null); xmlRSAD.InnerText = rsModInfo[device].antiDeadZone.ToString(); Node.AppendChild(xmlRSAD);
|
||||
XmlNode xmlLSMaxZone = m_Xdoc.CreateNode(XmlNodeType.Element, "LSMaxZone", null); xmlLSMaxZone.InnerText = lsModInfo[device].maxZone.ToString(); Node.AppendChild(xmlLSMaxZone);
|
||||
XmlNode xmlRSMaxZone = m_Xdoc.CreateNode(XmlNodeType.Element, "RSMaxZone", null); xmlRSMaxZone.InnerText = rsModInfo[device].maxZone.ToString(); Node.AppendChild(xmlRSMaxZone);
|
||||
XmlNode xmlLSMaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "LSMaxOutput", null); xmlLSMaxOutput.InnerText = lsModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlLSMaxOutput);
|
||||
XmlNode xmlRSMaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "RSMaxOutput", null); xmlRSMaxOutput.InnerText = rsModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlRSMaxOutput);
|
||||
XmlNode xmlLSRotation = m_Xdoc.CreateNode(XmlNodeType.Element, "LSRotation", null); xmlLSRotation.InnerText = Convert.ToInt32(LSRotation[device] * 180.0 / Math.PI).ToString(); Node.AppendChild(xmlLSRotation);
|
||||
XmlNode xmlRSRotation = m_Xdoc.CreateNode(XmlNodeType.Element, "RSRotation", null); xmlRSRotation.InnerText = Convert.ToInt32(RSRotation[device] * 180.0 / Math.PI).ToString(); Node.AppendChild(xmlRSRotation);
|
||||
|
||||
@ -3271,6 +3273,22 @@ namespace DS4Windows
|
||||
}
|
||||
catch { rsModInfo[device].maxZone = 100; missingSetting = true; }
|
||||
|
||||
try
|
||||
{
|
||||
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSMaxOutput"); double temp = 100.0;
|
||||
temp = double.Parse(Item.InnerText);
|
||||
lsModInfo[device].maxOutput = Math.Min(Math.Max(temp, 0.0), 100.0);
|
||||
}
|
||||
catch { lsModInfo[device].maxOutput = 100.0; missingSetting = true; }
|
||||
|
||||
try
|
||||
{
|
||||
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/RSMaxOutput"); double temp = 100.0;
|
||||
temp = double.Parse(Item.InnerText);
|
||||
rsModInfo[device].maxOutput = Math.Min(Math.Max(temp, 0.0), 100.0);
|
||||
}
|
||||
catch { rsModInfo[device].maxOutput = 100; missingSetting = true; }
|
||||
|
||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SXDeadZone"); double.TryParse(Item.InnerText, out SXDeadzone[device]); }
|
||||
catch { SXDeadzone[device] = 0.02; missingSetting = true; }
|
||||
try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/SZDeadZone"); double.TryParse(Item.InnerText, out SZDeadzone[device]); }
|
||||
@ -4747,6 +4765,7 @@ namespace DS4Windows
|
||||
lsModInfo[device].deadZone = rsModInfo[device].deadZone = 10;
|
||||
lsModInfo[device].antiDeadZone = rsModInfo[device].antiDeadZone = 25;
|
||||
lsModInfo[device].maxZone = rsModInfo[device].maxZone = 100;
|
||||
lsModInfo[device].maxOutput = rsModInfo[device].maxOutput = 100.0;
|
||||
l2ModInfo[device].antiDeadZone = r2ModInfo[device].antiDeadZone = 0;
|
||||
l2ModInfo[device].maxZone = r2ModInfo[device].maxZone = 100;
|
||||
LSRotation[device] = 0.0;
|
||||
|
@ -309,6 +309,7 @@
|
||||
<RowDefinition Style="{StaticResource gridRowHeight}" />
|
||||
<RowDefinition Style="{StaticResource gridRowHeight}"/>
|
||||
<RowDefinition Style="{StaticResource gridRowHeight}" />
|
||||
<RowDefinition Style="{StaticResource gridRowHeight}" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="LS" Grid.Column="1" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,0,0,8"/>
|
||||
@ -332,14 +333,20 @@
|
||||
<xctk:DoubleUpDown d:IsHidden="True" Value="{Binding RSAntiDeadZone}" FormatString="F2" MinWidth="50" Grid.Row="3" Grid.Column="2" Maximum="1.0" Minimum="0.0" Increment="0.1"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
|
||||
<Label Content="Sensitivity:" Grid.Row="4" Grid.Column="0" />
|
||||
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding LSSens}" MinWidth="50" Grid.Row="4" Grid.Column="1" Maximum="5.0" Minimum="0.5" Increment="0.1"
|
||||
<Label Content="Max Output:" Grid.Row="4" Grid.Column="0" />
|
||||
<xctk:DoubleUpDown d:IsHidden="True" Value="{Binding LSMaxOutput}" FormatString="F2" MinWidth="50" Grid.Row="4" Grid.Column="1" Maximum="1.0" Minimum="0.0" Increment="0.1"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding RSSens}" MinWidth="50" Grid.Row="4" Grid.Column="2" Maximum="5.0" Minimum="0.5" Increment="0.1"
|
||||
<xctk:DoubleUpDown d:IsHidden="True" Value="{Binding RSMaxOutput}" FormatString="F2" MinWidth="50" Grid.Row="4" Grid.Column="2" Maximum="1.0" Minimum="0.0" Increment="0.1"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
|
||||
<Label Content="Output Curve:" Grid.Row="5" Grid.Column="0" />
|
||||
<ComboBox Grid.Row="5" Grid.Column="1" SelectedIndex="{Binding LSOutputCurveIndex}"
|
||||
<Label Content="Sensitivity:" Grid.Row="5" Grid.Column="0" />
|
||||
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding LSSens}" MinWidth="50" Grid.Row="5" Grid.Column="1" Maximum="5.0" Minimum="0.5" Increment="0.1"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding RSSens}" MinWidth="50" Grid.Row="5" Grid.Column="2" Maximum="5.0" Minimum="0.5" Increment="0.1"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
|
||||
<Label Content="Output Curve:" Grid.Row="6" Grid.Column="0" />
|
||||
<ComboBox Grid.Row="6" Grid.Column="1" SelectedIndex="{Binding LSOutputCurveIndex}"
|
||||
Margin="{StaticResource spaceMargin}">
|
||||
<ComboBoxItem Content="Linear" />
|
||||
<ComboBoxItem Content="Enhanced Precision" />
|
||||
@ -349,7 +356,7 @@
|
||||
<ComboBoxItem Content="Easeout Cubic" />
|
||||
<ComboBoxItem Content="Custom" />
|
||||
</ComboBox>
|
||||
<ComboBox Grid.Row="5" Grid.Column="2" SelectedIndex="{Binding RSOutputCurveIndex}"
|
||||
<ComboBox Grid.Row="6" Grid.Column="2" SelectedIndex="{Binding RSOutputCurveIndex}"
|
||||
Margin="{StaticResource spaceMargin}">
|
||||
<ComboBoxItem Content="Linear" />
|
||||
<ComboBoxItem Content="Enhanced Precision" />
|
||||
@ -360,50 +367,50 @@
|
||||
<ComboBoxItem Content="Custom" />
|
||||
</ComboBox>
|
||||
|
||||
<DockPanel Grid.Row="6" Grid.Column="1" IsEnabled="{Binding LSCustomCurveSelected}">
|
||||
<DockPanel Grid.Row="7" Grid.Column="1" IsEnabled="{Binding LSCustomCurveSelected}">
|
||||
<Button x:Name="lsCustomEditorBtn" Content="..." Tag="LS" Width="20" DockPanel.Dock="Right" Click="CustomEditorBtn_Click"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
<TextBox Text="{Binding LSCustomCurve,UpdateSourceTrigger=LostFocus,FallbackValue='0.00, 0.00, 1.00, 1.00'}" DockPanel.Dock="Left"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
</DockPanel>
|
||||
<DockPanel Grid.Row="6" Grid.Column="2" IsEnabled="{Binding RSCustomCurveSelected}">
|
||||
<DockPanel Grid.Row="7" Grid.Column="2" IsEnabled="{Binding RSCustomCurveSelected}">
|
||||
<Button x:Name="rsCustomEditorBtn" Content="..." Tag="RS" Width="20" DockPanel.Dock="Right" Click="CustomEditorBtn_Click"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
<TextBox Text="{Binding RSCustomCurve,UpdateSourceTrigger=LostFocus,FallbackValue='0.00, 0.00, 1.00, 1.00'}" DockPanel.Dock="Left"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
</DockPanel>
|
||||
|
||||
<Label Content="Square Stick:" Grid.Row="7" Grid.Column="0" />
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="1" HorizontalAlignment="Right">
|
||||
<Label Content="Square Stick:" Grid.Row="8" Grid.Column="0" />
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="1" HorizontalAlignment="Right">
|
||||
<CheckBox IsChecked="{Binding LSSquareStick}" Margin="{StaticResource spaceMargin}" />
|
||||
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F1" Value="{Binding LSSquareRoundness,FallbackValue=5}"
|
||||
MinWidth="100" Minimum="1.0" Maximum="5.0" Increment="1.0" IsEnabled="{Binding LSSquareStick}"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="2" HorizontalAlignment="Right">
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="2" HorizontalAlignment="Right">
|
||||
<CheckBox IsChecked="{Binding RSSquareStick}" Margin="{StaticResource spaceMargin}" />
|
||||
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F1" Value="{Binding RSSquareRoundness,FallbackValue=5}"
|
||||
MinWidth="100" Minimum="1.0" Maximum="5.0" Increment="1.0" IsEnabled="{Binding RSSquareStick}"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
</StackPanel>
|
||||
|
||||
<Label Content="Curve (Input):" Grid.Row="8" Grid.Column="0" />
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="1" HorizontalAlignment="Right">
|
||||
<Label Content="Curve (Input):" Grid.Row="9" Grid.Column="0" />
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="9" Grid.Column="1" HorizontalAlignment="Right">
|
||||
<xctk:DoubleUpDown d:IsHidden="True" MinWidth="100" Value="{Binding LSCurve}" Minimum="0" Maximum="100"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
<Label Content="%" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="2" HorizontalAlignment="Right">
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="9" Grid.Column="2" HorizontalAlignment="Right">
|
||||
<xctk:DoubleUpDown d:IsHidden="True" MinWidth="100" Value="{Binding RSCurve}" Minimum="0" Maximum="100" />
|
||||
<Label Content="%" />
|
||||
</StackPanel>
|
||||
|
||||
<Label Content="Rotation:" Grid.Row="9" Grid.Column="0" />
|
||||
<Label Content="Rotation:" Grid.Row="10" Grid.Column="0" />
|
||||
<xctk:IntegerUpDown d:IsHidden="True" Value="{Binding LSRotation}"
|
||||
Grid.Row="9" Grid.Column="1" Minimum="-180" Maximum="180"
|
||||
Grid.Row="10" Grid.Column="1" Minimum="-180" Maximum="180"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
<xctk:IntegerUpDown d:IsHidden="True" Value="{Binding RSRotation}"
|
||||
Grid.Row="9" Grid.Column="2" Minimum="-180" Maximum="180"
|
||||
Grid.Row="10" Grid.Column="2" Minimum="-180" Maximum="180"
|
||||
Margin="{StaticResource spaceMargin}" />
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
@ -683,6 +683,18 @@ namespace DS4WinWPF.DS4Forms.ViewModels
|
||||
set => Global.RSModInfo[device].antiDeadZone = (int)(value * 100.0);
|
||||
}
|
||||
|
||||
public double LSMaxOutput
|
||||
{
|
||||
get => Global.LSModInfo[device].maxOutput / 100.0;
|
||||
set => Global.LSModInfo[device].maxOutput = (int)(value * 100.0);
|
||||
}
|
||||
|
||||
public double RSMaxOutput
|
||||
{
|
||||
get => Global.RSModInfo[device].maxOutput / 100.0;
|
||||
set => Global.RSModInfo[device].maxOutput = (int)(value * 100.0);
|
||||
}
|
||||
|
||||
public double LSSens
|
||||
{
|
||||
get => Global.LSSens[device];
|
||||
|
Loading…
Reference in New Issue
Block a user