Skip to content

Commit

Permalink
Merge pull request #67 from chihirobelmo/65-when-the-throttle-is-inve…
Browse files Browse the repository at this point in the history
…rted-the-afterburner-detent-doesnt-work

Fixed throttle invert doesn't apply for AB/IDLE position properly. Also fixed AB/IDLE detent bytes to little-endian
  • Loading branch information
chihirobelmo authored Jul 1, 2022
2 parents 704e32b + 4b76fb4 commit f9473ed
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
3 changes: 3 additions & 0 deletions Falcon BMS Alternative Launcher/Input/CommonConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
15 changes: 9 additions & 6 deletions Falcon BMS Alternative Launcher/Override/OverrideSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,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();

const double MAXIN = 65536;
const double MAXOUT = 14848;
iAB = iAB * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX;
iIdle = iIdle * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX;

iAB = -iAB * (MAXOUT / MAXIN) + MAXOUT;
iIdle = -iIdle * (MAXOUT / MAXIN) + MAXOUT;
if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert() == false)
{
iAB = CommonConstants.BINAXISMAX - iAB;
iIdle = CommonConstants.BINAXISMAX - iIdle;
}

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[1] = ab[2];
bs[5] = idle[2];
}
}
}
Expand Down
22 changes: 13 additions & 9 deletions Falcon BMS Alternative Launcher/Override/OverrideSettingFor434.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

Expand Down Expand Up @@ -58,20 +59,23 @@ 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 * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX;
iIdle = iIdle * CommonConstants.BINAXISMAX / CommonConstants.AXISMAX;

iAB = -iAB * (MAXOUT / MAXIN) + MAXOUT;
iIdle = -iIdle * (MAXOUT / MAXIN) + MAXOUT;
if (((InGameAxAssgn)inGameAxis[nme.ToString()]).GetInvert() == false)
{
iAB = CommonConstants.BINAXISMAX - iAB;
iIdle = CommonConstants.BINAXISMAX - iIdle;
}

byte[] ab = BitConverter.GetBytes((int)iAB);
byte[] idle = BitConverter.GetBytes((int)iIdle);
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[1] = ab[2];
bs[5] = idle[2];
}
}
}
Expand Down
30 changes: 18 additions & 12 deletions Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -518,25 +518,31 @@ 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)

if (Invert.IsChecked == true)
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)
{
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)

if (Invert.IsChecked == true)
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;
}

Expand Down

0 comments on commit f9473ed

Please sign in to comment.