From 3353b4afcd90c47cd458f803376f786c291d668d Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Tue, 21 Jan 2020 03:46:24 -0600 Subject: [PATCH] Added max output setting for L2 and R2 --- DS4Windows/DS4Control/Mapping.cs | 18 +++++++++++++-- DS4Windows/DS4Control/ProfilePropGroups.cs | 1 + DS4Windows/DS4Control/ScpUtil.cs | 19 +++++++++++++++ DS4Windows/DS4Forms/ProfileEditor.xaml | 23 ++++++++++++------- .../ViewModels/ProfileSettingsViewModel.cs | 12 ++++++++++ 5 files changed, 63 insertions(+), 10 deletions(-) diff --git a/DS4Windows/DS4Control/Mapping.cs b/DS4Windows/DS4Control/Mapping.cs index dbb1591..523c241 100644 --- a/DS4Windows/DS4Control/Mapping.cs +++ b/DS4Windows/DS4Control/Mapping.cs @@ -817,7 +817,8 @@ namespace DS4Windows byte l2Deadzone = l2ModInfo.deadZone; int l2AntiDeadzone = l2ModInfo.antiDeadZone; 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 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) { tempL2AntiDead = l2AntiDeadzone * 0.01; @@ -860,7 +867,8 @@ namespace DS4Windows byte r2Deadzone = r2ModInfo.deadZone; int r2AntiDeadzone = r2ModInfo.antiDeadZone; 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 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) { tempR2AntiDead = r2AntiDeadzone * 0.01; diff --git a/DS4Windows/DS4Control/ProfilePropGroups.cs b/DS4Windows/DS4Control/ProfilePropGroups.cs index 7ed77cc..f1492bb 100644 --- a/DS4Windows/DS4Control/ProfilePropGroups.cs +++ b/DS4Windows/DS4Control/ProfilePropGroups.cs @@ -23,6 +23,7 @@ namespace DS4Windows public byte deadZone; // Trigger deadzone is expressed in axis units public int antiDeadZone; public int maxZone = 100; + public double maxOutput = 100.0; } public class GyroMouseInfo diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 9d2d9b7..039b9af 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -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 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 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 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); @@ -3223,6 +3225,22 @@ namespace DS4Windows } 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 { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LSRotation"); int temp = 0; @@ -4768,6 +4786,7 @@ namespace DS4Windows lsModInfo[device].maxOutput = rsModInfo[device].maxOutput = 100.0; l2ModInfo[device].antiDeadZone = r2ModInfo[device].antiDeadZone = 0; l2ModInfo[device].maxZone = r2ModInfo[device].maxZone = 100; + l2ModInfo[device].maxOutput = r2ModInfo[device].maxOutput = 100.0; LSRotation[device] = 0.0; RSRotation[device] = 0.0; SXDeadzone[device] = SZDeadzone[device] = 0.25; diff --git a/DS4Windows/DS4Forms/ProfileEditor.xaml b/DS4Windows/DS4Forms/ProfileEditor.xaml index acc1b56..a1c1d2b 100644 --- a/DS4Windows/DS4Forms/ProfileEditor.xaml +++ b/DS4Windows/DS4Forms/ProfileEditor.xaml @@ -425,6 +425,7 @@ + @@ -454,14 +455,20 @@ -