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:
Sébastien Noel 2015-10-11 12:46:36 +02:00 committed by Daniel Gibson
parent 48511003b6
commit 32feff2be1

View file

@ -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;