From 615e268e2693a7ced9d5a36a9c3740642da81406 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 20 May 2013 23:57:10 -0700 Subject: [PATCH] Fixed bug 1856 - (Patch) More bits for SDL_MouseMotionEvent.state Gerry JJ The state bitmask in SDL_MouseMotionEvent is stored in an Uint8. Unfortunately this doesn't actually have room for 8 buttons because SDL skips 4 button indices after the third mouse button (at least here on Linux x86-64, probably related to wheel handling?), so it's really just enough to track 4 buttons. For example, on a Logitech MX310 mouse I've got, even though the mouse has 6 buttons total, the left and right side buttons and extra middle button have indexes 8, 9 and 10, and the last two won't fit in the 8 bit button state. The source of the button state (in SDL_Mouse) is already 32-bit, and the state field in SDL_MouseMotionEvent is 32-bit aligned and followed by three 8-bit padding fields. So simply changing the SDL_MouseMotionEvent state to an Uint32 and removing the padding fields fixes this, and I think it should be binary compatible, at least for little endian. --- include/SDL_events.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index c2265bae6..ae0b0f166 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -221,10 +221,7 @@ typedef struct SDL_MouseMotionEvent Uint32 timestamp; Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ - Uint8 state; /**< The current button state */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; + Uint32 state; /**< The current button state */ Sint32 x; /**< X coordinate, relative to window */ Sint32 y; /**< Y coordinate, relative to window */ Sint32 xrel; /**< The relative motion in the X direction */