Opened 17 years ago

Closed 10 years ago

Last modified 10 years ago

#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)

patch195.diff (4.5 KB ) - added by Alan Jacobs Richardson 11 years ago.
Support as many mouse buttons as SDL does. That's 255!

Download all attachments as: .zip

Change History (9)

comment:1 by Andrew, 14 years ago

Milestone: BetaBacklog

comment:2 by historic_bruno, 11 years ago

Keywords: sdl simple added

by Alan Jacobs Richardson, 11 years ago

Attachment: patch195.diff added

Support as many mouse buttons as SDL does. That's 255!

comment:3 by Alan Jacobs Richardson, 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 Josh, 10 years ago

Keywords: patch review added

comment:5 by Josh, 10 years ago

Cc: historic_bruno added

comment:6 by JoshuaJB, 10 years ago

Owner: set to JoshuaJB
Resolution: fixed
Status: newclosed

In 15609:

Support more mouse buttons. Fixes #195. Patch by 01d55 with some minor cleanup.

comment:7 by Josh, 10 years ago

Keywords: sdl simple patch review removed
Milestone: BacklogAlpha 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.

comment:8 by JoshuaJB, 10 years ago

In 15610:

Fixed some keys not being recognized after r15609. Refs #195.

Note: See TracTickets for help on using tickets.