| Summary: | SDL does not support WM_XBUTTON events (mouse side buttons do not work) | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Forest Hale <lordhavoc> |
| Component: | events | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P1 | ||
| Version: | 1.2.11 | ||
| Hardware: | x86 | ||
| OS: | Windows (All) | ||
| URL: | http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/mouseinputreference/mouseinputmessages/wm_xbuttondown.asp | ||
| Attachments: | First shot at implementation for 1.2. | ||
|
Description
Forest Hale
2006-08-27 07:30:29 UTC
Bumping a bunch of bugs to Priority 1 for consideration for the 1.2.12 release. --ryan. Created attachment 214 [details]
First shot at implementation for 1.2.
Here's a patch against the latest Subversion revision of SDL 1.2 ... this is completely untested, and may not even compile.
This patch adds WM_XBUTTON support to the windib target. Buttons show up as indexes 6 and 7 to accomodate the mousewheel being buttons 4 and 5...this patch should handle buttons 8, 9, etc, if Windows supports more than XBUTTON1 and XBUTTON2 in the future.
The DirectInput code would need to use something newer than the DirectInput2 interfaces to get up to 8 buttons (DIMOUSESTATE supports 4, we need DIMOUSESTATE2). This patch does not touch that.
If someone with Windows and a mouse with a lot of buttons could test this, I'd appreciate it.
--ryan.
WM_XBUTTON has been heavily tested in DarkPlaces previously, it's probably worth referring to the code here: http://svn.icculus.org/twilight/trunk/darkplaces/vid_wgl.c?view=markup Your patch seems to assume that the wParam contains a button index, which is incorrect, they contain bit flags just like MK_LBUTTON, MK_RBUTTON, and MK_MBUTTON (which exist in the WM_[LRM]BUTTONDOWN/UP events), here are the values: #ifndef MK_XBUTTON1 #define MK_XBUTTON1 0x0020 #define MK_XBUTTON2 0x0040 // LordHavoc: lets hope this allows more buttons in the future... #define MK_XBUTTON3 0x0080 #define MK_XBUTTON4 0x0100 #define MK_XBUTTON5 0x0200 #define MK_XBUTTON6 0x0400 #define MK_XBUTTON7 0x0800 #endif The event could conceivably have multiple set (although I doubt that ever happens), which means multiple SDL button events need to be produced.
> Your patch seems to assume that the wParam contains a button index, which is
> incorrect, they contain bit flags just like MK_LBUTTON, MK_RBUTTON, and
> MK_MBUTTON (which exist in the WM_[LRM]BUTTONDOWN/UP events), here are the
> values:
According to the MSDN link in the URL field, the low-order bits are a mask of currently-pressed buttons as you described, and is in fact what DarkPlaces uses.
The high-order bits specify exactly one button, the one that triggered the event, and that works better for SDL's purposes.
--ryan.
Ahh, that's very cool actually. :) Okay, I have tested this patch and found one bug in it: case WM_XBUTTONUP: xbuttonval = GET_XBUTTON_WPARAM(wParam); button = SDL_BUTTON_WHEELDOWN + xbuttonval; state = SDL_PRESSED; break; Should use SDL_RELEASED With that fixed, it works perfectly. (In reply to comment #6) > Should use SDL_RELEASED Crap, I always screw up cut-and-pastes. :) Thanks for catching that! This is fixed in svn revision #3086 for the 1.2 branch (and will go into the upcoming 1.2.12 release), and #3088 for the 1.3 branch. --ryan. In case SDL lacks DirectInput support for button4/5 this diff may be a useful reference: http://svn.icculus.org/twilight/trunk/darkplaces/vid_wgl.c?r1=7317&r2=7489&p1=trunk/darkplaces/vid_wgl.c&p2=trunk/darkplaces/vid_wgl.c As I don't see any such bug in the bugzilla I'm just mentioning this on this already resolved bug about button4 in GDI input. We'll update the DirectInput interface we use to a newer version for SDL 1.3, I'm sure, but we don't want to change the dependencies for 1.2 at this point. --ryan. (In reply to comment #9) > We'll update the DirectInput interface we use to a newer version for SDL 1.3, > I'm sure, but we don't want to change the dependencies for 1.2 at this point. > > --ryan. Hmm? DarkPlaces uses DirectInput 3, there's no older version. |