From 9707138ff7ba19217d00fb03d7e9c1d9ac77dcf0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 2 Mar 2013 20:44:16 -0800 Subject: [PATCH] Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input. --- include/SDL_events.h | 29 +++++++------ include/SDL_touch.h | 54 ++++++++++-------------- src/events/SDL_mouse.c | 15 ++++--- src/events/SDL_mouse_c.h | 9 ++-- src/main/beos/SDL_BApp.h | 6 +-- src/video/android/SDL_androidtouch.c | 8 ++-- src/video/cocoa/SDL_cocoamouse.m | 6 ++- src/video/cocoa/SDL_cocoawindow.m | 8 ++-- src/video/directfb/SDL_DirectFB_events.c | 8 ++-- src/video/nds/SDL_ndsevents.c | 6 +-- src/video/uikit/SDL_uikitview.m | 8 ++-- src/video/windows/SDL_windowsevents.c | 12 +++--- src/video/x11/SDL_x11events.c | 13 +++--- src/video/x11/SDL_x11xinput2.c | 2 +- 14 files changed, 92 insertions(+), 92 deletions(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index 1d39b3222..fce02bf75 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -151,8 +151,8 @@ typedef struct SDL_WindowEvent Uint8 padding1; Uint8 padding2; Uint8 padding3; - int data1; /**< event dependent data */ - int data2; /**< event dependent data */ + Sint32 data1; /**< event dependent data */ + Sint32 data2; /**< event dependent data */ } SDL_WindowEvent; /** @@ -180,8 +180,8 @@ typedef struct SDL_TextEditingEvent Uint32 timestamp; Uint32 windowID; /**< The window with keyboard focus, if any */ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ - int start; /**< The start cursor of selected editing text */ - int length; /**< The length of selected editing text */ + Sint32 start; /**< The start cursor of selected editing text */ + Sint32 length; /**< The length of selected editing text */ } SDL_TextEditingEvent; @@ -205,14 +205,15 @@ typedef struct SDL_MouseMotionEvent Uint32 type; /**< ::SDL_MOUSEMOTION */ 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; - int x; /**< X coordinate, relative to window */ - int y; /**< Y coordinate, relative to window */ - int xrel; /**< The relative motion in the X direction */ - int yrel; /**< The relative motion in the Y direction */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ + Sint32 xrel; /**< The relative motion in the X direction */ + Sint32 yrel; /**< The relative motion in the Y direction */ } SDL_MouseMotionEvent; /** @@ -223,12 +224,13 @@ typedef struct SDL_MouseButtonEvent Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ Uint32 timestamp; Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ Uint8 button; /**< The mouse button index */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 padding1; Uint8 padding2; - int x; /**< X coordinate, relative to window */ - int y; /**< Y coordinate, relative to window */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ } SDL_MouseButtonEvent; /** @@ -239,8 +241,9 @@ typedef struct SDL_MouseWheelEvent Uint32 type; /**< ::SDL_MOUSEWHEEL */ Uint32 timestamp; Uint32 windowID; /**< The window with mouse focus, if any */ - int x; /**< The amount scrolled horizontally */ - int y; /**< The amount scrolled vertically */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Sint32 x; /**< The amount scrolled horizontally */ + Sint32 y; /**< The amount scrolled vertically */ } SDL_MouseWheelEvent; /** @@ -467,7 +470,7 @@ typedef struct SDL_UserEvent Uint32 type; /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */ Uint32 timestamp; Uint32 windowID; /**< The associated window if any */ - int code; /**< User defined event code */ + Sint32 code; /**< User defined event code */ void *data1; /**< User defined data pointer */ void *data2; /**< User defined data pointer */ } SDL_UserEvent; diff --git a/include/SDL_touch.h b/include/SDL_touch.h index c4820792f..de7ccf48d 100644 --- a/include/SDL_touch.h +++ b/include/SDL_touch.h @@ -40,30 +40,25 @@ extern "C" { /* *INDENT-ON* */ #endif - typedef Sint64 SDL_TouchID; typedef Sint64 SDL_FingerID; - -struct SDL_Finger { - SDL_FingerID id; - Uint16 x; - Uint16 y; - Uint16 pressure; - Uint16 xdelta; - Uint16 ydelta; - Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */ - SDL_bool down; -}; - -typedef struct SDL_Touch SDL_Touch; -typedef struct SDL_Finger SDL_Finger; - - -struct SDL_Touch { - +typedef struct SDL_Finger +{ + SDL_FingerID id; + Uint16 x; + Uint16 y; + Uint16 pressure; + Uint16 xdelta; + Uint16 ydelta; + Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */ + SDL_bool down; +} SDL_Finger; + +typedef struct SDL_Touch +{ /* Free the touch when it's time */ - void (*FreeTouch) (SDL_Touch * touch); + void (*FreeTouch) (struct SDL_Touch * touch); /* data common for tablets */ float pressure_max, pressure_min; @@ -89,28 +84,23 @@ struct SDL_Touch { SDL_Finger** fingers; void *driverdata; -}; +} SDL_Touch; +/* Used as the device ID for mouse events simulated with touch input */ +#define SDL_TOUCH_MOUSEID ((Uint32)-1) /* Function prototypes */ /** - * \brief Get the touch object at the given id. - * - * + * \brief Get the touch object with the given id. */ - extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id); - - +extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id); /** - * \brief Get the finger object of the given touch, at the given id. - * - * + * \brief Get the finger object of the given touch, with the given id. */ - extern - DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id); +extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 35274c8b9..ba3eec2d1 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -81,7 +81,7 @@ SDL_ResetMouse(void) #endif for (i = 1; i <= sizeof(mouse->buttonstate)*8; ++i) { if (mouse->buttonstate & SDL_BUTTON(i)) { - SDL_SendMouseButton(mouse->focus, SDL_RELEASED, i); + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, i); } } SDL_assert(mouse->buttonstate == 0); @@ -174,7 +174,7 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate) } int -SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y) +SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; @@ -252,6 +252,7 @@ SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y) SDL_Event event; event.motion.type = SDL_MOUSEMOTION; event.motion.windowID = mouse->focus ? mouse->focus->id : 0; + event.motion.which = mouseID; event.motion.state = mouse->buttonstate; event.motion.x = mouse->x; event.motion.y = mouse->y; @@ -266,7 +267,7 @@ SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y) } int -SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button) +SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; @@ -304,11 +305,12 @@ SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button) if (SDL_GetEventState(type) == SDL_ENABLE) { SDL_Event event; event.type = type; + event.button.windowID = mouse->focus ? mouse->focus->id : 0; + event.button.which = mouseID; event.button.state = state; event.button.button = button; event.button.x = mouse->x; event.button.y = mouse->y; - event.button.windowID = mouse->focus ? mouse->focus->id : 0; posted = (SDL_PushEvent(&event) > 0); } @@ -321,7 +323,7 @@ SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button) } int -SDL_SendMouseWheel(SDL_Window * window, int x, int y) +SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; @@ -340,6 +342,7 @@ SDL_SendMouseWheel(SDL_Window * window, int x, int y) SDL_Event event; event.type = SDL_MOUSEWHEEL; event.wheel.windowID = mouse->focus ? mouse->focus->id : 0; + event.wheel.which = mouseID; event.wheel.x = x; event.wheel.y = y; posted = (SDL_PushEvent(&event) > 0); @@ -396,7 +399,7 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) if (mouse->WarpMouse) { mouse->WarpMouse(window, x, y); } else { - SDL_SendMouseMotion(window, 0, x, y); + SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y); } } diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 2fc27eac7..7cb13cb3d 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -25,6 +25,8 @@ #include "SDL_mouse.h" +typedef Uint32 SDL_MouseID; + struct SDL_Cursor { struct SDL_Cursor *next; @@ -55,6 +57,7 @@ typedef struct int (*SetRelativeMouseMode) (SDL_bool enabled); /* Data common to all mice */ + SDL_MouseID mouseID; SDL_Window *focus; int x; int y; @@ -86,13 +89,13 @@ extern void SDL_SetDefaultCursor(SDL_Cursor * cursor); extern void SDL_SetMouseFocus(SDL_Window * window); /* Send a mouse motion event */ -extern int SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y); +extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y); /* Send a mouse button event */ -extern int SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button); +extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button); /* Send a mouse wheel event */ -extern int SDL_SendMouseWheel(SDL_Window * window, int x, int y); +extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y); /* Shutdown the mouse subsystem */ extern void SDL_MouseQuit(void); diff --git a/src/main/beos/SDL_BApp.h b/src/main/beos/SDL_BApp.h index 5ac285551..5bde94c18 100644 --- a/src/main/beos/SDL_BApp.h +++ b/src/main/beos/SDL_BApp.h @@ -221,7 +221,7 @@ class SDL_BApp : public BApplication { return; } win = GetSDLWindow(winID); - SDL_SendMouseMotion(win, 0, x, y); + SDL_SendMouseMotion(win, 0, 0, x, y); /* Tell the application that the mouse passed over, redraw needed */ BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); @@ -239,7 +239,7 @@ class SDL_BApp : public BApplication { return; } win = GetSDLWindow(winID); - SDL_SendMouseButton(win, state, button); + SDL_SendMouseButton(win, 0, state, button); } void _HandleMouseWheel(BMessage *msg) { @@ -254,7 +254,7 @@ class SDL_BApp : public BApplication { return; } win = GetSDLWindow(winID); - SDL_SendMouseWheel(win, xTicks, yTicks); + SDL_SendMouseWheel(win, 0, xTicks, yTicks); } void _HandleKey(BMessage *msg) { diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 67e3f9426..87386de26 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -89,10 +89,10 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio Android_GetWindowCoordinates(x, y, &window_x, &window_y); /* send moved event */ - SDL_SendMouseMotion(NULL, 0, window_x, window_y); + SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y); /* send mouse down event */ - SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); + SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT); leftFingerDown = fingerId; } @@ -103,7 +103,7 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio Android_GetWindowCoordinates(x, y, &window_x, &window_y); /* send moved event */ - SDL_SendMouseMotion(NULL, 0, window_x, window_y); + SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y); } SDL_SendTouchMotion(touchDeviceId, fingerId, SDL_FALSE, x, y, p); break; @@ -111,7 +111,7 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio case ACTION_POINTER_1_UP: if (fingerId == leftFingerDown) { /* send mouse up */ - SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); + SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT); leftFingerDown = 0; } SDL_SendFingerDown(touchDeviceId, fingerId, SDL_FALSE, x, y, p); diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 158fa17cd..5b5981827 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -223,13 +223,15 @@ [event type] == NSOtherMouseDragged)) { float x = [event deltaX]; float y = [event deltaY]; - SDL_SendMouseMotion(mouse->focus, 1, (int)x, (int)y); + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, (int)x, (int)y); } } void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) { + SDL_Mouse *mouse = SDL_GetMouse(); + float x = [event deltaX]; float y = [event deltaY]; @@ -243,7 +245,7 @@ } else if (y < 0) { y -= 0.9f; } - SDL_SendMouseWheel(window, (int)x, (int)y); + SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y); } void diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 5c9fd082d..5a3d6cc83 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -200,7 +200,7 @@ - (void)windowDidBecomeKey:(NSNotification *)aNotification y = (int)(window->h - point.y); if (x >= 0 && x < window->w && y >= 0 && y < window->h) { - SDL_SendMouseMotion(window, 0, x, y); + SDL_SendMouseMotion(window, 0, 0, x, y); SDL_SetCursor(NULL); } } @@ -263,7 +263,7 @@ - (void)mouseDown:(NSEvent *)theEvent button = [theEvent buttonNumber] + 1; break; } - SDL_SendMouseButton(_data->window, SDL_PRESSED, button); + SDL_SendMouseButton(_data->window, 0, SDL_PRESSED, button); } - (void)rightMouseDown:(NSEvent *)theEvent @@ -294,7 +294,7 @@ - (void)mouseUp:(NSEvent *)theEvent button = [theEvent buttonNumber] + 1; break; } - SDL_SendMouseButton(_data->window, SDL_RELEASED, button); + SDL_SendMouseButton(_data->window, 0, SDL_RELEASED, button); } - (void)rightMouseUp:(NSEvent *)theEvent @@ -342,7 +342,7 @@ - (void)mouseMoved:(NSEvent *)theEvent CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); } } - SDL_SendMouseMotion(window, 0, x, y); + SDL_SendMouseMotion(window, 0, 0, x, y); } - (void)mouseDragged:(NSEvent *)theEvent diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index c04eed499..8ee0b9085 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -40,13 +40,13 @@ #include "SDL_DirectFB_events.h" #if USE_MULTI_API -#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(id, relative, x, y, p) -#define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(id, state, button) +#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(w, id, relative, x, y, p) +#define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(w, id, state, button) #define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(id, state, scancode) #define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(id, text) #else -#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(w, relative, x, y) -#define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(w, state, button) +#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(w, id, relative, x, y) +#define SDL_SendMouseButton_ex(w, id, state, button) SDL_SendMouseButton(w, id, state, button) #define SDL_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(state, scancode) #define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(text) #endif diff --git a/src/video/nds/SDL_ndsevents.c b/src/video/nds/SDL_ndsevents.c index 8132aae23..97933a46a 100644 --- a/src/video/nds/SDL_ndsevents.c +++ b/src/video/nds/SDL_ndsevents.c @@ -37,15 +37,15 @@ NDS_PumpEvents(_THIS) scanKeys(); /* TODO: defer click-age */ if (keysDown() & KEY_TOUCH) { - SDL_SendMouseButton(0, SDL_PRESSED, 0); + SDL_SendMouseButton(NULL, 0, SDL_PRESSED, 0); } else if (keysUp() & KEY_TOUCH) { - SDL_SendMouseButton(0, SDL_RELEASED, 0); + SDL_SendMouseButton(NULL, 0, SDL_RELEASED, 0); } if (keysHeld() & KEY_TOUCH) { touchPosition t; touchRead(&t); - SDL_SendMouseMotion(0, 0, t.px, t.py); + SDL_SendMouseMotion(NULL, 0, 0, t.px, t.py); } } diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index ddbfe8f5e..20701d84d 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -104,10 +104,10 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO]; /* send moved event */ - SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); + SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y); /* send mouse down event */ - SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); + SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT); leftFingerDown = (SDL_FingerID)touch; } @@ -144,7 +144,7 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event while(touch) { if ((SDL_FingerID)touch == leftFingerDown) { /* send mouse up */ - SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); + SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT); leftFingerDown = 0; } @@ -189,7 +189,7 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO]; /* send moved event */ - SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); + SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y); } CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 356bcfd8c..1b3937833 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -191,11 +191,11 @@ WIN_CheckWParamMouseButton( SDL_bool bwParamMousePressed, SDL_bool bSDLMousePres { if ( bwParamMousePressed && !bSDLMousePressed ) { - SDL_SendMouseButton(data->window, SDL_PRESSED, button); + SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button); } else if ( !bwParamMousePressed && bSDLMousePressed ) { - SDL_SendMouseButton(data->window, SDL_RELEASED, button); + SDL_SendMouseButton(data->window, 0, SDL_RELEASED, button); } } @@ -376,7 +376,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_MOUSEMOVE: if( !SDL_GetMouse()->relative_mode ) - SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam)); + SDL_SendMouseMotion(data->window, 0, 0, LOWORD(lParam), HIWORD(lParam)); /* don't break here, fall through to check the wParam like the button presses */ case WM_LBUTTONUP: case WM_RBUTTONUP: @@ -408,7 +408,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) { - SDL_SendMouseMotion(data->window, 1, (int)mouse->lLastX, (int)mouse->lLastY); + SDL_SendMouseMotion(data->window, 0, 1, (int)mouse->lLastX, (int)mouse->lLastY); } else { @@ -420,7 +420,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) initialMousePoint.y = mouse->lLastY; } - SDL_SendMouseMotion(data->window, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) ); + SDL_SendMouseMotion(data->window, 0, 1, (int)(mouse->lLastX-initialMousePoint.x), (int)(mouse->lLastY-initialMousePoint.y) ); initialMousePoint.x = mouse->lLastX; initialMousePoint.y = mouse->lLastY; @@ -435,7 +435,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // FIXME: This may need to accumulate deltas up to WHEEL_DELTA short motion = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; - SDL_SendMouseWheel(data->window, 0, motion); + SDL_SendMouseWheel(data->window, 0, 0, motion); break; } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index a377d4cec..fa8543d8e 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -448,24 +448,23 @@ X11_DispatchEvent(_THIS) printf("window %p: X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); #endif - SDL_SendMouseMotion(data->window, 0, xevent.xmotion.x, xevent.xmotion.y); + SDL_SendMouseMotion(data->window, 0, 0, xevent.xmotion.x, xevent.xmotion.y); } } break; case ButtonPress:{ int ticks = 0; - if (X11_IsWheelEvent(display,&xevent,&ticks) == SDL_TRUE) { - SDL_SendMouseWheel(data->window, 0, ticks); - } - else { - SDL_SendMouseButton(data->window, SDL_PRESSED, xevent.xbutton.button); + if (X11_IsWheelEvent(display,&xevent,&ticks)) { + SDL_SendMouseWheel(data->window, 0, 0, ticks); + } else { + SDL_SendMouseButton(data->window, 0, SDL_PRESSED, xevent.xbutton.button); } } break; case ButtonRelease:{ - SDL_SendMouseButton(data->window, SDL_RELEASED, xevent.xbutton.button); + SDL_SendMouseButton(data->window, 0, SDL_RELEASED, xevent.xbutton.button); } break; diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 9a1b6e9aa..16fd252c5 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -142,7 +142,7 @@ X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie) parse_valuators(rawev->raw_values,rawev->valuators.mask, rawev->valuators.mask_len,relative_cords,2); - SDL_SendMouseMotion(mouse->focus,1,(int)relative_cords[0],(int)relative_cords[1]); + SDL_SendMouseMotion(mouse->focus,mouse->mouseID,1,(int)relative_cords[0],(int)relative_cords[1]); return 1; } break;