Skip to content

Commit

Permalink
Fix triggers being recognized as negative analog stick values when as…
Browse files Browse the repository at this point in the history
…signing an input if the axis is moved too slowly.
  • Loading branch information
nadiaholmquist committed Jul 7, 2022
1 parent 35cbda9 commit f5c1094
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/frontend/qt_sdl/InputConfig/MapButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,21 @@ class JoyMapButton : public QPushButton
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;
}
Expand Down

0 comments on commit f5c1094

Please sign in to comment.