From fd2e61178b7043591bf806ff7e63eac8e87ba943 Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 21:54:11 +0900 Subject: [PATCH 1/5] fixed AB/IDLE detent bytes to little endian --- .../Override/OverrideSetting.cs | 15 ++++++--------- .../Override/OverrideSettingFor434.cs | 18 ++++++++---------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs index d7907a4..22fba82 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs @@ -440,20 +440,17 @@ protected virtual void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devic { if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() >= 0) { - double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); + double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); double iIdle = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetIDLE(); - const double MAXIN = 65536; - const double MAXOUT = 14848; + iAB = iAB * 15000 / 65536; + iIdle = iIdle * 15000 / 65536; - iAB = -iAB * (MAXOUT / MAXIN) + MAXOUT; - iIdle = -iIdle * (MAXOUT / MAXIN) + MAXOUT; - - byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); + byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); byte[] idle = BitConverter.GetBytes((int)iIdle).Reverse().ToArray(); - bs[1] = ab[1]; - bs[5] = idle[1]; + bs[5] = ab[2]; + bs[1] = idle[2]; } } } diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs index 75e3d24..03ff881 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.IO; +using System.Linq; using System.Text; using System.Xml.Serialization; @@ -58,20 +59,17 @@ protected override void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devi { if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() >= 0) { - double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); + double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); double iIdle = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetIDLE(); - const double MAXIN = 65536; - const double MAXOUT = 14848; + iAB = iAB * 15000 / 65536; + iIdle = iIdle * 15000 / 65536; - iAB = -iAB * (MAXOUT / MAXIN) + MAXOUT; - iIdle = -iIdle * (MAXOUT / MAXIN) + MAXOUT; + byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); + byte[] idle = BitConverter.GetBytes((int)iIdle).Reverse().ToArray(); - byte[] ab = BitConverter.GetBytes((int)iAB); - byte[] idle = BitConverter.GetBytes((int)iIdle); - - bs[1] = ab[1]; - bs[5] = idle[1]; + bs[5] = ab[2]; + bs[1] = idle[2]; } } } From 83add145fafa8590f48aa122719cc32be4e2319c Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 21:54:46 +0900 Subject: [PATCH 2/5] Fixed AB/IDLE detent when throttle axis is inverted. --- Falcon BMS Alternative Launcher/Override/OverrideSetting.cs | 6 ++++++ .../Override/OverrideSettingFor434.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs index 22fba82..e955408 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs @@ -446,6 +446,12 @@ protected virtual void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devic iAB = iAB * 15000 / 65536; iIdle = iIdle * 15000 / 65536; + if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert()) + { + iAB = 15000 - iAB; + iIdle = 15000 - iIdle; + } + byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); byte[] idle = BitConverter.GetBytes((int)iIdle).Reverse().ToArray(); diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs index 03ff881..3b05074 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs @@ -65,6 +65,12 @@ protected override void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devi iAB = iAB * 15000 / 65536; iIdle = iIdle * 15000 / 65536; + if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert()) + { + iAB = 15000 - iAB; + iIdle = 15000 - iIdle; + } + byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); byte[] idle = BitConverter.GetBytes((int)iIdle).Reverse().ToArray(); From 82b9edee02726a5e26e82535d0a50ee86b1c85c5 Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 22:29:49 +0900 Subject: [PATCH 3/5] Fixed throttle invert doesn't apply AB/IDLE position properly --- .../Override/OverrideSetting.cs | 12 +++++----- .../Override/OverrideSettingFor434.cs | 12 +++++----- .../Windows/AxisAssignWindow.xaml.cs | 24 ++++++++----------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs index e955408..5b39b4a 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs @@ -443,20 +443,20 @@ protected virtual void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devic double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); double iIdle = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetIDLE(); - iAB = iAB * 15000 / 65536; - iIdle = iIdle * 15000 / 65536; + iAB = iAB * 15000 / CommonConstants.AXISMAX; + iIdle = iIdle * 15000 / CommonConstants.AXISMAX; - if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert()) + if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert() == false) { - iAB = 15000 - iAB; + iAB = 15000 - iAB; iIdle = 15000 - iIdle; } byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); byte[] idle = BitConverter.GetBytes((int)iIdle).Reverse().ToArray(); - bs[5] = ab[2]; - bs[1] = idle[2]; + bs[1] = ab[2]; + bs[5] = idle[2]; } } } diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs index 3b05074..6ef802b 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs @@ -62,20 +62,20 @@ protected override void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devi double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); double iIdle = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetIDLE(); - iAB = iAB * 15000 / 65536; - iIdle = iIdle * 15000 / 65536; + iAB = iAB * 15000 / CommonConstants.AXISMAX; + iIdle = iIdle * 15000 / CommonConstants.AXISMAX; - if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert()) + if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert() == false) { - iAB = 15000 - iAB; + iAB = 15000 - iAB; iIdle = 15000 - iIdle; } byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); byte[] idle = BitConverter.GetBytes((int)iIdle).Reverse().ToArray(); - bs[5] = ab[2]; - bs[1] = idle[2]; + bs[1] = ab[2]; + bs[5] = idle[2]; } } } diff --git a/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs b/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs index 9c2749d..5a32938 100644 --- a/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs +++ b/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs @@ -518,26 +518,22 @@ private void SetAB_Click(object sender, RoutedEventArgs e) { if (status != Status.ShowAxisStatus) return; - int ABposition; - ABposition = CommonConstants.AXISMAX - MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); - if (MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp) > CommonConstants.AXISMAX) - ABposition = CommonConstants.AXISMAX; - AB = ABposition; - if (AB > CommonConstants.AXISMAX - CommonConstants.AXISMAX / 128) - AB = CommonConstants.AXISMAX; + + if (Invert.IsChecked == true) + AB = CommonConstants.AXISMIN + MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); + else + AB = CommonConstants.AXISMAX - MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); } private void SetIDLE_Click(object sender, RoutedEventArgs e) { if (status != Status.ShowAxisStatus) return; - int IDLEposition; - IDLEposition = CommonConstants.AXISMAX - MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); - if (MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp) < 0) - IDLEposition = CommonConstants.AXISMIN; - IDLE = IDLEposition; - if (IDLE < CommonConstants.AXISMAX / 128) - IDLE = CommonConstants.AXISMIN; + + if (Invert.IsChecked == true) + IDLE = CommonConstants.AXISMIN + MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); + else + IDLE = CommonConstants.AXISMAX - MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); } private void MetroWindow_MouseDown(object sender, MouseButtonEventArgs e) From 500ec27448359acc233e0c94cbd69ea12841382b Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 22:36:58 +0900 Subject: [PATCH 4/5] formatting --- Falcon BMS Alternative Launcher/Input/CommonConstants.cs | 3 +++ .../Override/OverrideSetting.cs | 8 ++++---- .../Override/OverrideSettingFor434.cs | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Falcon BMS Alternative Launcher/Input/CommonConstants.cs b/Falcon BMS Alternative Launcher/Input/CommonConstants.cs index d967c8d..2d92e07 100644 --- a/Falcon BMS Alternative Launcher/Input/CommonConstants.cs +++ b/Falcon BMS Alternative Launcher/Input/CommonConstants.cs @@ -29,5 +29,8 @@ public static class CommonConstants public static readonly int AXISMIN = 0; public static readonly int AXISMAX = 65536; + + public static readonly int BINAXISMIN = 0; + public static readonly int BINAXISMAX = 15000; } } diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs index 5b39b4a..acf03d5 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs @@ -443,13 +443,13 @@ protected virtual void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devic double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); double iIdle = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetIDLE(); - iAB = iAB * 15000 / CommonConstants.AXISMAX; - iIdle = iIdle * 15000 / CommonConstants.AXISMAX; + iAB = iAB * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX; + iIdle = iIdle * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX; if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert() == false) { - iAB = 15000 - iAB; - iIdle = 15000 - iIdle; + iAB = CommonConstants.BINAXISMAX - iAB; + iIdle = CommonConstants.BINAXISMAX - iIdle; } byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs index 6ef802b..8c891a3 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs @@ -62,13 +62,13 @@ protected override void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devi double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); double iIdle = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetIDLE(); - iAB = iAB * 15000 / CommonConstants.AXISMAX; - iIdle = iIdle * 15000 / CommonConstants.AXISMAX; + iAB = iAB * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX; + iIdle = iIdle * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX; if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert() == false) { - iAB = 15000 - iAB; - iIdle = 15000 - iIdle; + iAB = CommonConstants.BINAXISMAX - iAB; + iIdle = CommonConstants.BINAXISMAX - iIdle; } byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); From 4b76fb4764a0f0f1481948d9f83f196b0a2ec431 Mon Sep 17 00:00:00 2001 From: chihirobelmo Date: Fri, 1 Jul 2022 22:42:34 +0900 Subject: [PATCH 5/5] invelid value check and format --- .../Override/OverrideSetting.cs | 4 ++-- .../Windows/AxisAssignWindow.xaml.cs | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs index acf03d5..2979d0a 100644 --- a/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs +++ b/Falcon BMS Alternative Launcher/Override/OverrideSetting.cs @@ -440,7 +440,7 @@ protected virtual void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devic { if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber() >= 0) { - double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); + double iAB = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetAB(); double iIdle = deviceControl.joyAssign[((InGameAxAssgn)inGameAxis[nme.ToString()]).GetDeviceNumber()].detentPosition.GetIDLE(); iAB = iAB * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX; @@ -452,7 +452,7 @@ protected virtual void SaveJoystickCal(Hashtable inGameAxis, DeviceControl devic iIdle = CommonConstants.BINAXISMAX - iIdle; } - byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); + byte[] ab = BitConverter.GetBytes((int)iAB).Reverse().ToArray(); byte[] idle = BitConverter.GetBytes((int)iIdle).Reverse().ToArray(); bs[1] = ab[2]; diff --git a/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs b/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs index 5a32938..6ab7f02 100644 --- a/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs +++ b/Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs @@ -523,6 +523,11 @@ private void SetAB_Click(object sender, RoutedEventArgs e) AB = CommonConstants.AXISMIN + MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); else AB = CommonConstants.AXISMAX - MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); + + if (AB > CommonConstants.AXISMAX) + AB = CommonConstants.AXISMAX; + if (AB < CommonConstants.AXISMIN) + AB = CommonConstants.AXISMIN; } private void SetIDLE_Click(object sender, RoutedEventArgs e) @@ -534,6 +539,11 @@ private void SetIDLE_Click(object sender, RoutedEventArgs e) IDLE = CommonConstants.AXISMIN + MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); else IDLE = CommonConstants.AXISMAX - MainWindow.deviceControl.joyAssign[devNumTmp].JoyAxisState(phyAxNumTmp); + + if (IDLE > CommonConstants.AXISMAX) + IDLE = CommonConstants.AXISMAX; + if (IDLE < CommonConstants.AXISMIN) + IDLE = CommonConstants.AXISMIN; } private void MetroWindow_MouseDown(object sender, MouseButtonEventArgs e)