From f5c1094d03c317a93d4f088c34e7a89c16a2b2bf Mon Sep 17 00:00:00 2001 From: Nadia Holmquist Pedersen Date: Thu, 7 Jul 2022 23:16:28 +0200 Subject: [PATCH] Fix triggers being recognized as negative analog stick values when assigning an input if the axis is moved too slowly. --- src/frontend/qt_sdl/InputConfig/MapButton.h | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/frontend/qt_sdl/InputConfig/MapButton.h b/src/frontend/qt_sdl/InputConfig/MapButton.h index ca210f9f..15415210 100644 --- a/src/frontend/qt_sdl/InputConfig/MapButton.h +++ b/src/frontend/qt_sdl/InputConfig/MapButton.h @@ -245,19 +245,21 @@ protected: Sint16 axisval = SDL_JoystickGetAxis(joy, i); int diff = abs(axisval - axesRest[i]); - if (axesRest[i] < -16384 && axisval >= 0) + if (diff >= 16384) { - *mapping = (oldmap & 0xFFFF) | 0x10000 | (2 << 20) | (i << 24); - click(); - return; - } - else if (diff > 16384) - { - int axistype; - if (axisval > 0) axistype = 0; - else axistype = 1; + if (axesRest[i] < -16384) // Trigger + { + *mapping = (oldmap & 0xFFFF) | 0x10000 | (2 << 20) | (i << 24); + } + else // Analog stick + { + int axistype; + if (axisval > 0) axistype = 0; + else axistype = 1; + + *mapping = (oldmap & 0xFFFF) | 0x10000 | (axistype << 20) | (i << 24); + } - *mapping = (oldmap & 0xFFFF) | 0x10000 | (axistype << 20) | (i << 24); click(); return; }