Skip to content

Commit

Permalink
Mapper: Check against no emulated buttons so that 4-axis joysticks (w…
Browse files Browse the repository at this point in the history
…ith no buttons) don't trigger a divide by zero when you push a joystick button.
  • Loading branch information
joncampbell123 committed Dec 31, 2017
1 parent 9c07bc9 commit aaca801
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/gui/sdl_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,14 @@ class CStickBindGroup : public CBindGroup {
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
jbutton = &event->jbutton;
bool state;
state=jbutton->type==SDL_JOYBUTTONDOWN;
but = jbutton->button % emulated_buttons;
if (jbutton->which == stick) {
JOYSTICK_Button(emustick,but,state);
if (emulated_buttons != 0) {
jbutton = &event->jbutton;
bool state;
state=jbutton->type==SDL_JOYBUTTONDOWN;
but = jbutton->button % emulated_buttons;
if (jbutton->which == stick) {
JOYSTICK_Button(emustick, but, state);
}
}
break;
}
Expand Down

0 comments on commit aaca801

Please sign in to comment.