Added max output setting for L2 and R2

This commit is contained in:
Travis Nickles 2020-01-21 03:46:24 -06:00
parent fad0ddda26
commit 3353b4afcd
5 changed files with 63 additions and 10 deletions

View File

@ -817,7 +817,8 @@ namespace DS4Windows
byte l2Deadzone = l2ModInfo.deadZone; byte l2Deadzone = l2ModInfo.deadZone;
int l2AntiDeadzone = l2ModInfo.antiDeadZone; int l2AntiDeadzone = l2ModInfo.antiDeadZone;
int l2Maxzone = l2ModInfo.maxZone; int l2Maxzone = l2ModInfo.maxZone;
if (l2Deadzone > 0 || l2AntiDeadzone > 0 || l2Maxzone != 100) double l2MaxOutput = l2ModInfo.maxOutput;
if (l2Deadzone > 0 || l2AntiDeadzone > 0 || l2Maxzone != 100 || l2MaxOutput != 100.0)
{ {
double tempL2Output = cState.L2 / 255.0; double tempL2Output = cState.L2 / 255.0;
double tempL2AntiDead = 0.0; double tempL2AntiDead = 0.0;
@ -837,6 +838,12 @@ namespace DS4Windows
} }
} }
if (l2MaxOutput != 100.0)
{
double maxOutRatio = l2MaxOutput / 100.0;
tempL2Output = Math.Min(Math.Max(tempL2Output, 0.0), maxOutRatio);
}
if (l2AntiDeadzone > 0) if (l2AntiDeadzone > 0)
{ {
tempL2AntiDead = l2AntiDeadzone * 0.01; tempL2AntiDead = l2AntiDeadzone * 0.01;
@ -860,7 +867,8 @@ namespace DS4Windows
byte r2Deadzone = r2ModInfo.deadZone; byte r2Deadzone = r2ModInfo.deadZone;
int r2AntiDeadzone = r2ModInfo.antiDeadZone; int r2AntiDeadzone = r2ModInfo.antiDeadZone;
int r2Maxzone = r2ModInfo.maxZone; int r2Maxzone = r2ModInfo.maxZone;
if (r2Deadzone > 0 || r2AntiDeadzone > 0 || r2Maxzone != 100) double r2MaxOutput = r2ModInfo.maxOutput;
if (r2Deadzone > 0 || r2AntiDeadzone > 0 || r2Maxzone != 100 || r2MaxOutput != 100.0)
{ {
double tempR2Output = cState.R2 / 255.0; double tempR2Output = cState.R2 / 255.0;
double tempR2AntiDead = 0.0; double tempR2AntiDead = 0.0;
@ -880,6 +888,12 @@ namespace DS4Windows
} }
} }
if (r2MaxOutput != 100.0)
{
double maxOutRatio = r2MaxOutput / 100.0;
tempR2Output = Math.Min(Math.Max(tempR2Output, 0.0), maxOutRatio);
}
if (r2AntiDeadzone > 0) if (r2AntiDeadzone > 0)
{ {
tempR2AntiDead = r2AntiDeadzone * 0.01; tempR2AntiDead = r2AntiDeadzone * 0.01;

View File

@ -23,6 +23,7 @@ namespace DS4Windows
public byte deadZone; // Trigger deadzone is expressed in axis units public byte deadZone; // Trigger deadzone is expressed in axis units
public int antiDeadZone; public int antiDeadZone;
public int maxZone = 100; public int maxZone = 100;
public double maxOutput = 100.0;
} }
public class GyroMouseInfo public class GyroMouseInfo

View File

@ -2479,6 +2479,8 @@ namespace DS4Windows
XmlNode xmlR2AD = m_Xdoc.CreateNode(XmlNodeType.Element, "R2AntiDeadZone", null); xmlR2AD.InnerText = r2ModInfo[device].antiDeadZone.ToString(); Node.AppendChild(xmlR2AD); XmlNode xmlR2AD = m_Xdoc.CreateNode(XmlNodeType.Element, "R2AntiDeadZone", null); xmlR2AD.InnerText = r2ModInfo[device].antiDeadZone.ToString(); Node.AppendChild(xmlR2AD);
XmlNode xmlL2Maxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "L2MaxZone", null); xmlL2Maxzone.InnerText = l2ModInfo[device].maxZone.ToString(); Node.AppendChild(xmlL2Maxzone); XmlNode xmlL2Maxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "L2MaxZone", null); xmlL2Maxzone.InnerText = l2ModInfo[device].maxZone.ToString(); Node.AppendChild(xmlL2Maxzone);
XmlNode xmlR2Maxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "R2MaxZone", null); xmlR2Maxzone.InnerText = r2ModInfo[device].maxZone.ToString(); Node.AppendChild(xmlR2Maxzone); XmlNode xmlR2Maxzone = m_Xdoc.CreateNode(XmlNodeType.Element, "R2MaxZone", null); xmlR2Maxzone.InnerText = r2ModInfo[device].maxZone.ToString(); Node.AppendChild(xmlR2Maxzone);
XmlNode xmlL2MaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "L2MaxOutput", null); xmlL2MaxOutput.InnerText = l2ModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlL2MaxOutput);
XmlNode xmlR2MaxOutput = m_Xdoc.CreateNode(XmlNodeType.Element, "R2MaxOutput", null); xmlR2MaxOutput.InnerText = r2ModInfo[device].maxOutput.ToString(); Node.AppendChild(xmlR2MaxOutput);
XmlNode xmlButtonMouseSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "ButtonMouseSensitivity", null); xmlButtonMouseSensitivity.InnerText = buttonMouseSensitivity[device].ToString(); Node.AppendChild(xmlButtonMouseSensitivity); XmlNode xmlButtonMouseSensitivity = m_Xdoc.CreateNode(XmlNodeType.Element, "ButtonMouseSensitivity", null); xmlButtonMouseSensitivity.InnerText = buttonMouseSensitivity[device].ToString(); Node.AppendChild(xmlButtonMouseSensitivity);
XmlNode xmlRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "Rainbow", null); xmlRainbow.InnerText = rainbow[device].ToString(); Node.AppendChild(xmlRainbow); XmlNode xmlRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "Rainbow", null); xmlRainbow.InnerText = rainbow[device].ToString(); Node.AppendChild(xmlRainbow);
XmlNode xmlMaxSatRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "MaxSatRainbow", null); xmlMaxSatRainbow.InnerText = Convert.ToInt32(maxRainbowSat[device] * 100.0).ToString(); Node.AppendChild(xmlMaxSatRainbow); XmlNode xmlMaxSatRainbow = m_Xdoc.CreateNode(XmlNodeType.Element, "MaxSatRainbow", null); xmlMaxSatRainbow.InnerText = Convert.ToInt32(maxRainbowSat[device] * 100.0).ToString(); Node.AppendChild(xmlMaxSatRainbow);
@ -3223,6 +3225,22 @@ namespace DS4Windows
} }
catch { r2ModInfo[device].maxZone = 100; missingSetting = true; } catch { r2ModInfo[device].maxZone = 100; missingSetting = true; }
try
{
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/L2MaxOutput"); double temp = 100.0;
temp = double.Parse(Item.InnerText);
l2ModInfo[device].maxOutput = Math.Min(Math.Max(temp, 0.0), 100.0);
}
catch { l2ModInfo[device].maxOutput = 100.0; missingSetting = true; }
try
{
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/R2MaxOutput"); double temp = 100.0;
temp = double.Parse(Item.InnerText);
r2ModInfo[device].maxOutput = Math.Min(Math.Max(temp, 0.0), 100.0);
}
catch { r2ModInfo[device].maxOutput = 100.0; missingSetting = true; }
try try
{ {
Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSRotation"); int temp = 0; Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSRotation"); int temp = 0;
@ -4768,6 +4786,7 @@ namespace DS4Windows
lsModInfo[device].maxOutput = rsModInfo[device].maxOutput = 100.0; lsModInfo[device].maxOutput = rsModInfo[device].maxOutput = 100.0;
l2ModInfo[device].antiDeadZone = r2ModInfo[device].antiDeadZone = 0; l2ModInfo[device].antiDeadZone = r2ModInfo[device].antiDeadZone = 0;
l2ModInfo[device].maxZone = r2ModInfo[device].maxZone = 100; l2ModInfo[device].maxZone = r2ModInfo[device].maxZone = 100;
l2ModInfo[device].maxOutput = r2ModInfo[device].maxOutput = 100.0;
LSRotation[device] = 0.0; LSRotation[device] = 0.0;
RSRotation[device] = 0.0; RSRotation[device] = 0.0;
SXDeadzone[device] = SZDeadzone[device] = 0.25; SXDeadzone[device] = SZDeadzone[device] = 0.25;

View File

@ -425,6 +425,7 @@
<RowDefinition Style="{StaticResource gridRowHeight}"></RowDefinition> <RowDefinition Style="{StaticResource gridRowHeight}"></RowDefinition>
<RowDefinition Style="{StaticResource gridRowHeight}"></RowDefinition> <RowDefinition Style="{StaticResource gridRowHeight}"></RowDefinition>
<RowDefinition Style="{StaticResource gridRowHeight}"></RowDefinition> <RowDefinition Style="{StaticResource gridRowHeight}"></RowDefinition>
<RowDefinition Style="{StaticResource gridRowHeight}"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -454,14 +455,20 @@
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding R2AntiDeadZone}" MinWidth="50" Grid.Row="3" Grid.Column="2" Maximum="1.0" Minimum="0.0" Increment="0.1" <xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding R2AntiDeadZone}" MinWidth="50" Grid.Row="3" Grid.Column="2" Maximum="1.0" Minimum="0.0" Increment="0.1"
Margin="{StaticResource spaceMargin}" /> Margin="{StaticResource spaceMargin}" />
<Label Content="Sensitivity:" Grid.Row="4" Grid.Column="0" /> <Label Content="Max Output:" Grid.Row="4" Grid.Column="0" />
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding L2Sens}" MinWidth="50" Grid.Row="4" Grid.Column="1" Maximum="10.0" Minimum="0.1" Increment="0.1" <xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding L2MaxOutput}" MinWidth="50" Grid.Row="4" Grid.Column="1" Maximum="1.0" Minimum="0.0" Increment="0.1"
Margin="{StaticResource spaceMargin}" /> Margin="{StaticResource spaceMargin}" />
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding R2Sens}" MinWidth="50" Grid.Row="4" Grid.Column="2" Maximum="10.0" Minimum="0.1" Increment="0.1" <xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding R2MaxOutput}" MinWidth="50" Grid.Row="4" Grid.Column="2" Maximum="1.0" Minimum="0.0" Increment="0.1"
Margin="{StaticResource spaceMargin}" /> Margin="{StaticResource spaceMargin}" />
<Label Content="Output Curve:" Grid.Row="5" Grid.Column="0" /> <Label Content="Sensitivity:" Grid.Row="5" Grid.Column="0" />
<ComboBox Grid.Row="5" Grid.Column="1" SelectedIndex="{Binding L2OutputCurveIndex}" <xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding L2Sens}" MinWidth="50" Grid.Row="5" Grid.Column="1" Maximum="10.0" Minimum="0.1" Increment="0.1"
Margin="{StaticResource spaceMargin}" />
<xctk:DoubleUpDown d:IsHidden="True" FormatString="F2" Value="{Binding R2Sens}" MinWidth="50" Grid.Row="5" Grid.Column="2" Maximum="10.0" Minimum="0.1" 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 L2OutputCurveIndex}"
Margin="{StaticResource spaceMargin}"> Margin="{StaticResource spaceMargin}">
<ComboBoxItem Content="Linear" /> <ComboBoxItem Content="Linear" />
<ComboBoxItem Content="Enhanced Precision" /> <ComboBoxItem Content="Enhanced Precision" />
@ -471,7 +478,7 @@
<ComboBoxItem Content="Easeout Cubic" /> <ComboBoxItem Content="Easeout Cubic" />
<ComboBoxItem Content="Custom" /> <ComboBoxItem Content="Custom" />
</ComboBox> </ComboBox>
<ComboBox Grid.Row="5" Grid.Column="2" SelectedIndex="{Binding R2OutputCurveIndex}" <ComboBox Grid.Row="6" Grid.Column="2" SelectedIndex="{Binding R2OutputCurveIndex}"
Margin="{StaticResource spaceMargin}"> Margin="{StaticResource spaceMargin}">
<ComboBoxItem Content="Linear" /> <ComboBoxItem Content="Linear" />
<ComboBoxItem Content="Enhanced Precision" /> <ComboBoxItem Content="Enhanced Precision" />
@ -482,13 +489,13 @@
<ComboBoxItem Content="Custom" /> <ComboBoxItem Content="Custom" />
</ComboBox> </ComboBox>
<DockPanel Grid.Row="6" Grid.Column="1" IsEnabled="{Binding L2CustomCurveSelected}"> <DockPanel Grid.Row="7" Grid.Column="1" IsEnabled="{Binding L2CustomCurveSelected}">
<Button x:Name="l2CustomEditorBtn" Content="..." Tag="L2" Width="20" DockPanel.Dock="Right" Click="CustomEditorBtn_Click" <Button x:Name="l2CustomEditorBtn" Content="..." Tag="L2" Width="20" DockPanel.Dock="Right" Click="CustomEditorBtn_Click"
Margin="{StaticResource spaceMargin}" /> Margin="{StaticResource spaceMargin}" />
<TextBox Text="{Binding L2CustomCurve,FallbackValue='0.00, 0.00, 1.00, 1.00'}" DockPanel.Dock="Left" <TextBox Text="{Binding L2CustomCurve,FallbackValue='0.00, 0.00, 1.00, 1.00'}" DockPanel.Dock="Left"
Margin="{StaticResource spaceMargin}" /> Margin="{StaticResource spaceMargin}" />
</DockPanel> </DockPanel>
<DockPanel Grid.Row="6" Grid.Column="2" IsEnabled="{Binding R2CustomCurveSelected}"> <DockPanel Grid.Row="7" Grid.Column="2" IsEnabled="{Binding R2CustomCurveSelected}">
<Button x:Name="r2CustomEditorBtn" Content="..." Tag="R2" Width="20" DockPanel.Dock="Right" Click="CustomEditorBtn_Click" <Button x:Name="r2CustomEditorBtn" Content="..." Tag="R2" Width="20" DockPanel.Dock="Right" Click="CustomEditorBtn_Click"
Margin="{StaticResource spaceMargin}" /> Margin="{StaticResource spaceMargin}" />
<TextBox Text="{Binding R2CustomCurve,FallbackValue='0.00, 0.00, 1.00, 1.00'}" DockPanel.Dock="Left" <TextBox Text="{Binding R2CustomCurve,FallbackValue='0.00, 0.00, 1.00, 1.00'}" DockPanel.Dock="Left"

View File

@ -849,6 +849,18 @@ namespace DS4WinWPF.DS4Forms.ViewModels
set => Global.R2ModInfo[device].antiDeadZone = (int)(value * 100.0); set => Global.R2ModInfo[device].antiDeadZone = (int)(value * 100.0);
} }
public double L2MaxOutput
{
get => Global.L2ModInfo[device].maxOutput / 100.0;
set => Global.L2ModInfo[device].maxOutput = value * 100.0;
}
public double R2MaxOutput
{
get => Global.R2ModInfo[device].maxOutput / 100.0;
set => Global.R2ModInfo[device].maxOutput = value * 100.0;
}
public double L2Sens public double L2Sens
{ {
get => Global.L2Sens[device]; get => Global.L2Sens[device];