added analog input filtering in UI (fixes #578)

This commit is contained in:
thrust26 2020-05-27 10:14:16 +02:00
parent 97f6271412
commit f9de0deee7
2 changed files with 23 additions and 16 deletions

View File

@ -33,6 +33,8 @@
* Added that mouse sensitivity for Driving controller can be adjusted
* Added paddle filtering in UI to avoid unwanted navigation events
* Added selectable dialog fonts
* Added separate positioning of launcher, emulator and debugger

View File

@ -687,27 +687,32 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
}
j->axisLastValue[axis] = value;
}
#ifdef GUI_SUPPORT
else if(myHandler.hasOverlay())
{
// First, clamp the values to simulate digital input
// (the only thing that the underlying code understands)
if(value > Joystick::deadzone())
value = 32000;
else if(value < -Joystick::deadzone())
value = -32000;
else
value = 0;
// Now filter out consecutive, similar values
// (only pass on the event if the state has changed)
if(value != j->axisLastValue[axis])
// A value change lower than Joystick::deadzone indicates analog input which is ignored
if((abs(j->axisLastValue[axis] - value) > Joystick::deadzone()))
{
#ifdef GUI_SUPPORT
myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), convertAxisValue(value), button);
#endif
j->axisLastValue[axis] = value;
// First, clamp the values to simulate digital input
// (the only thing that the underlying code understands)
if(value > Joystick::deadzone())
value = 32000;
else if(value < -Joystick::deadzone())
value = -32000;
else
value = 0;
// Now filter out consecutive, similar values
// (only pass on the event if the state has changed)
if(value != j->axisLastValue[axis])
{
myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), convertAxisValue(value), button);
}
}
j->axisLastValue[axis] = value;
}
#endif
}
}