Yesterday I came across a problem when trying to get mouse wheel events
working using the following code under Linux:
SDL_PumpEvents();
if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_WHEELUP))
printf(“Wheel up event\n”);
I was hoping that it was just a misconfiguration on my part, but drew a
blank on that.
On further examination it seems that X11_PumpEvents does actually process
the button press and release events on mouse wheel up or down. The
problem is that it loops through both of them them during the same
function call, therefore when SDL_ButtonState is returned by
SDL_GetMouseState it no longer contains the wheel event data.
Hopefully that makes sense.
Anyway I’ve included a patch against CVS below which fixes the problem.
Basically, if it comes across ButtonPress and ButtonRelease events (for
the wheel mouse) during a single call to X11_PumpEvents the latter doesn’t
get processed this cycle but gets moved to the next one.
There’s probably a better way to do this, so if anyone has one I’d be
interested.
http://www.jadara.org.uk/~jjos/tmp/sdl-wheel-event-fix.diff
Cheers,
-James