UI: Clamp analog speed to 0 on opposite value.

This commit is contained in:
Unknown W. Brackets 2022-07-05 16:07:09 -07:00
parent f18c1a6e8f
commit e159cb2b91
2 changed files with 5 additions and 4 deletions

View File

@ -134,5 +134,5 @@ enum class BackgroundAnimation {
enum class AnalogFpsMode {
AUTO = 0,
MAPPED_DIRECTION = 1,
MAPPED_TO_OPPOSITE = 2,
MAPPED_DIR_TO_OPPOSITE_DIR = 2,
};

View File

@ -408,7 +408,7 @@ void ControlMapper::ProcessAnalogSpeed(const AxisInput &axis, bool opposite) {
case JOYSTICK_AXIS_RY:
case JOYSTICK_AXIS_RZ:
// These, at least on directinput, can be used for triggers that go from mapped to opposite.
mode = AnalogFpsMode::MAPPED_TO_OPPOSITE;
mode = AnalogFpsMode::MAPPED_DIR_TO_OPPOSITE_DIR;
break;
default:
@ -421,9 +421,10 @@ void ControlMapper::ProcessAnalogSpeed(const AxisInput &axis, bool opposite) {
// Okay, now let's map it as appropriate.
if (mode == AnalogFpsMode::MAPPED_DIRECTION) {
value = fabsf(value);
// Clamp to 0 in this case if we're processing the opposite direction.
if (opposite)
return;
} else if (mode == AnalogFpsMode::MAPPED_TO_OPPOSITE) {
value = 0.0f;
} else if (mode == AnalogFpsMode::MAPPED_DIR_TO_OPPOSITE_DIR) {
value = fabsf(value);
if (opposite)
value = -value;