mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-01-19 07:51:54 +00:00
handle up to 8 buttons with SDL2 based on https://github.com/RobertBeckebans/RBDOOM-3-BFG/pull/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
This commit is contained in:
parent
48511003b6
commit
32feff2be1
1 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue