| Summary: | No mouse wheel event on linux/x11 (incl. suggested patch) | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Matthias <matthias.schweinoch> |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: |
Patched SDL_x11events.c with mouse wheel support
diff / patch file for SDL_x11events.c |
||
Created attachment 597 [details]
diff / patch file for SDL_x11events.c
Thank you very much for your patch for SDL 1.3! Do you give me permission to release your code with SDL 1.3 and future versions of SDL under both the LGPL and a closed-source commercial license? (In reply to comment #2) > Thank you very much for your patch for SDL 1.3! > > Do you give me permission to release your code with SDL 1.3 and future > versions of SDL under both the LGPL and a closed-source commercial > license? You're welcome and: Yes, I do:-) Thanks, your patch is in! http://hg.libsdl.org/SDL/rev/4e46a7b6773d |
Created attachment 596 [details] Patched SDL_x11events.c with mouse wheel support On X11, SDL 1.3 does not generate a mouse wheel event. Instead, button down/buttton up events are generated by SDL. After looking at the code in SDL_x11events.c, I assume this is due to the fact that X11 does not have a dedicated mouse wheel event. I did a little research on the behavior of mouse wheel events on X11 systems. Apparently, mouse wheel events generate a button down/button up event with the same time, i.e. with exact same timestamp. Attached you can find my changes to SDL_x11events.c, which generates SDL mouse wheel events for those button down events that have a button release event immediately following it (for the same button, and with the same timestamp). I did have to make an assumption: As standard X11 implementations know only 5 buttons, I have mapped Button4 to "wheel up" (i.e. +1), and Button5 to "wheel down" (i.e. -1). Note that if you include this patch, no SDL button down/up events will be generated on X11 platforms for mouse wheel events (which is probably a significant change for those that have programmed their code to work with them).