input_sdl.cpp: Ignore joystick buttons beyond maximum supported number.

* Note that the code to map excess buttons to switches doesn't actually do anything useful while INPUT_MAX_BUTTONS and MAX_BUTTONS happen to be defined to the same number.
This commit is contained in:
Vas Crabb 2019-12-07 16:26:34 +11:00
parent 7c13daf354
commit a6608152b9

View File

@ -657,7 +657,8 @@ public:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
joystick.buttons[sdlevent.jbutton.button] = (sdlevent.jbutton.state == SDL_PRESSED) ? 0x80 : 0;
if (sdlevent.jbutton.button < MAX_BUTTONS)
joystick.buttons[sdlevent.jbutton.button] = (sdlevent.jbutton.state == SDL_PRESSED) ? 0x80 : 0;
break;
}
}
@ -1070,7 +1071,9 @@ public:
}
// loop over all buttons
for (int button = 0; button < SDL_JoystickNumButtons(joy); button++)
if (SDL_JoystickNumButtons(joy) > MAX_BUTTONS)
osd_printf_verbose("Joystick: ... Has %d buttons which exceeds supported %d buttons\n", SDL_JoystickNumButtons(joy), MAX_BUTTONS);
for (int button = 0; (button < MAX_BUTTONS) && (button < SDL_JoystickNumButtons(joy)); button++)
{
input_item_id itemid;