diff options
author | 2019-12-07 16:26:34 +1100 | |
---|---|---|
committer | 2019-12-07 16:30:42 +1100 | |
commit | a6608152b986b5789790721e6487bac921ae29ed (patch) | |
tree | 3d7ba59394db04b721e62ea58207a5944193e5db | |
parent | 7c13daf354ff2150b5cbcc27adbe12c3ebf9deca (diff) |
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.
-rw-r--r-- | src/osd/modules/input/input_sdl.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index d7cd185aca8..596895e9e39 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -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; |