#195 closed enhancement (fixed)
Support more mouse buttons
Reported by: | Philip Taylor | Owned by: | JoshuaJB |
---|---|---|---|
Priority: | If Time Permits | Milestone: | Alpha 17 |
Component: | Core engine | Keywords: | |
Cc: | historic_bruno | Patch: |
Description
Currently only five buttons (left, right, middle, wheel-up, wheel-down) are supported. It might be nice if users could map functions onto other buttons (e.g. my mouse has seven additional buttons).
Attachments (1)
Change History (9)
comment:1 by , 14 years ago
Milestone: | Beta → Backlog |
---|
comment:2 by , 11 years ago
Keywords: | sdl simple added |
---|
by , 11 years ago
Attachment: | patch195.diff added |
---|
comment:3 by , 11 years ago
I worked out a patch to address this.
How it works:
The input system maps SDL keyboard and mouse events to a single space by taking the keyboard event keys and stacking mouse buttons and modifier keys on top. That happens in KeyName.h. Previously, the modifier keys came after the mouse stuff, but now the mouse stuff claims a large block of numbers implicitly so the modifiers had to be moved to the front. Therefore mouse button codes start from the new enumerant MOUSE_BASE, whose value depends on whether SDL is at 2.0 or above (because the mouse wheel codes have to come before MOUSE_BASE if they're not caused by mouse events).
Hotkey.cpp is adjusted to account for MOUSE_BASE taking some responsibility from CUSTOM_SDL_KEYCODE, and the obsolete check for a maximum supported mouse button code is removed.
KeyName.cpp dynamically generates names for numbered mouse buttons, because it'd be real foolish to type out 510 nearly identical names by hand.
Finally, keys.txt is updated to document the new options!
I've tried this out building & running on Linux with a mouse that has a button 8 and a button 9. I was able to map the idle worker and idle soldier functions to those buttons.
comment:4 by , 10 years ago
Keywords: | patch review added |
---|
comment:5 by , 10 years ago
Cc: | added |
---|
comment:7 by , 10 years ago
Keywords: | sdl simple patch review removed |
---|---|
Milestone: | Backlog → Alpha 17 |
Thanks for the patch. I made some small changes in 15609 to correct the spacing in KeyName.cpp which did not follow our coding conventions.
Support as many mouse buttons as SDL does. That's 255!