Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Falcon BMS Alternative Launcher/Input/CommonConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static class CommonConstants

public static readonly int AXISMIN = 0;
public static readonly int AXISMAX = 65536;
public static readonly int AXIS_NEUTRAL_TOLERANCE = AXISMAX / 128;

public static readonly int FLUSHTIME1 = 900;
public static readonly int FLUSHTIME2 = 1500;
Expand Down
44 changes: 32 additions & 12 deletions Falcon BMS Alternative Launcher/Windows/AxisAssignWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,21 +326,41 @@ private void ShowAxisStatus()
+ ((AxisNumName)phyAxNumTmp).ToString().Replace('_', ' ') + " : "
+ MainWindow.deviceControl.GetJoystickMappings()[devNumTmp].GetSanitizedProductName();

if (whoCalledWindow != AxisName.Throttle.ToString() & whoCalledWindow != AxisName.Throttle_Right.ToString())
return;
AxisValueProgress.Foreground = CommonConstants.LIGHTBLUE;
check_ABIDLE.Visibility = Visibility.Hidden;
if ( (Invert.IsChecked == false && CommonConstants.AXISMAX + AxisValueProgress.Value < IDLE) || (Invert.IsChecked == true && CommonConstants.AXISMIN + AxisValueProgress.Value < IDLE))

if (whoCalledWindow == AxisName.Cursor_X.ToString() | whoCalledWindow == AxisName.Cursor_Y.ToString())
{
AxisValueProgress.Foreground = CommonConstants.LIGHTRED;
check_ABIDLE.Visibility = Visibility.Visible;
check_ABIDLE.Content = "IDLE CUTOFF";
if (Math.Abs(AxisValueProgress.Value) < CommonConstants.AXISMAX * 0.5 - CommonConstants.AXIS_NEUTRAL_TOLERANCE |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This compound-if seems needlessly confusing, to me. (Why are we taking Abs of the AxisValueProgress.. can it ever be negative? And what is up with the bitwise-OR vs logical OR..?)

Taking Abs of the distance from center, is what I would normally expect to see..

float axisCenter = CommonConstants.AXISMAX * 0.5;

if (Math.Abs(AxisValueProgress.Value-axisCenter) > CommonConstants.AXIS_NEUTRAL_TOLERANCE) { ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually what might be better.. is we modify the ApplyDeadZone() function above, to return a bool indicating if the axis in the deadzone or not. (Or maybe a separate method, "IsInDeadZone" or something. Haven't looked closely at it.)

Then, this indicator would be naturally dynamic.. no need for CommonConstants.AXIS_NEUTRAL_TOLERANCE

And it would serve to help people set appropriate deadzone size.

Math.Abs(AxisValueProgress.Value) > CommonConstants.AXISMAX * 0.5 + CommonConstants.AXIS_NEUTRAL_TOLERANCE)
{
AxisValueProgress.Foreground = CommonConstants.LIGHTRED;
check_ABIDLE.Visibility = Visibility.Visible;
check_ABIDLE.Content = "NOT NEUTRAL";
}
else
{
AxisValueProgress.Foreground = CommonConstants.LIGHTBLUE;
check_ABIDLE.Visibility = Visibility.Hidden;
check_ABIDLE.Content = "NOT NEUTRAL";
}
}
if ( (Invert.IsChecked == false && CommonConstants.AXISMAX + AxisValueProgress.Value > AB) || (Invert.IsChecked == true && CommonConstants.AXISMIN + AxisValueProgress.Value > AB) )

if (whoCalledWindow == AxisName.Throttle.ToString() | whoCalledWindow == AxisName.Throttle_Right.ToString())
{
AxisValueProgress.Foreground = CommonConstants.LIGHTGREEN;
check_ABIDLE.Visibility = Visibility.Visible;
check_ABIDLE.Content = "AB";
AxisValueProgress.Foreground = CommonConstants.LIGHTBLUE;
check_ABIDLE.Visibility = Visibility.Hidden;

if ((Invert.IsChecked == false && CommonConstants.AXISMAX + AxisValueProgress.Value < IDLE) || (Invert.IsChecked == true && CommonConstants.AXISMIN + AxisValueProgress.Value < IDLE))
{
AxisValueProgress.Foreground = CommonConstants.LIGHTRED;
check_ABIDLE.Visibility = Visibility.Visible;
check_ABIDLE.Content = "IDLE CUTOFF";
}
if ((Invert.IsChecked == false && CommonConstants.AXISMAX + AxisValueProgress.Value > AB) || (Invert.IsChecked == true && CommonConstants.AXISMIN + AxisValueProgress.Value > AB))
{
AxisValueProgress.Foreground = CommonConstants.LIGHTGREEN;
check_ABIDLE.Visibility = Visibility.Visible;
check_ABIDLE.Content = "AB";
}
}
}

Expand Down
Loading