Skip to content

Commit

Permalink
handle up to 8 buttons with SDL2 based on RobertBeckebans/RBDOOM-3-BF…
Browse files Browse the repository at this point in the history
…G#213

it's buggy on Linux/X11 before 2.0.4, but it works fine on other platforms
extra bonus: don't generate garbage events for unknown mouse buttons
  • Loading branch information
twolife authored and DanielGibson committed Dec 13, 2015
1 parent 4851100 commit 32feff2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions neo/sys/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,18 @@ sysEvent_t Sys_GetEvent() {
mouse_polls.Append(mouse_poll_t(M_DELTAZ, -1));
break;
#endif
default:
#if SDL_VERSION_ATLEAST(2, 0, 0)
// handle X1 button and above
if( ev.button.button <= 8 ) // doesn't support more than 8 mouse buttons
{
int buttonIndex = ev.button.button - SDL_BUTTON_LEFT;
res.evValue = K_MOUSE1 + buttonIndex;
mouse_polls.Append( mouse_poll_t( M_ACTION1 + buttonIndex, ev.button.state == SDL_PRESSED ? 1 : 0 ) );
}
else
#endif
continue; // handle next event
}

res.evValue2 = ev.button.state == SDL_PRESSED ? 1 : 0;
Expand Down

0 comments on commit 32feff2

Please sign in to comment.