Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.

This commit is contained in:
Sam Lantinga 2013-03-02 20:44:16 -08:00
parent c02018f852
commit 71ea3033fa
14 changed files with 91 additions and 91 deletions

View file

@ -151,8 +151,8 @@ typedef struct SDL_WindowEvent
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
int data1; /**< event dependent data */ Sint32 data1; /**< event dependent data */
int data2; /**< event dependent data */ Sint32 data2; /**< event dependent data */
} SDL_WindowEvent; } SDL_WindowEvent;
/** /**
@ -180,8 +180,8 @@ typedef struct SDL_TextEditingEvent
Uint32 timestamp; Uint32 timestamp;
Uint32 windowID; /**< The window with keyboard focus, if any */ Uint32 windowID; /**< The window with keyboard focus, if any */
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
int start; /**< The start cursor of selected editing text */ Sint32 start; /**< The start cursor of selected editing text */
int length; /**< The length of selected editing text */ Sint32 length; /**< The length of selected editing text */
} SDL_TextEditingEvent; } SDL_TextEditingEvent;
@ -205,14 +205,15 @@ typedef struct SDL_MouseMotionEvent
Uint32 type; /**< ::SDL_MOUSEMOTION */ Uint32 type; /**< ::SDL_MOUSEMOTION */
Uint32 timestamp; Uint32 timestamp;
Uint32 windowID; /**< The window with mouse focus, if any */ 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 state; /**< The current button state */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
int x; /**< X coordinate, relative to window */ Sint32 x; /**< X coordinate, relative to window */
int y; /**< Y coordinate, relative to window */ Sint32 y; /**< Y coordinate, relative to window */
int xrel; /**< The relative motion in the X direction */ Sint32 xrel; /**< The relative motion in the X direction */
int yrel; /**< The relative motion in the Y direction */ Sint32 yrel; /**< The relative motion in the Y direction */
} SDL_MouseMotionEvent; } SDL_MouseMotionEvent;
/** /**
@ -223,12 +224,13 @@ typedef struct SDL_MouseButtonEvent
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
Uint32 timestamp; Uint32 timestamp;
Uint32 windowID; /**< The window with mouse focus, if any */ 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 button; /**< The mouse button index */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
int x; /**< X coordinate, relative to window */ Sint32 x; /**< X coordinate, relative to window */
int y; /**< Y coordinate, relative to window */ Sint32 y; /**< Y coordinate, relative to window */
} SDL_MouseButtonEvent; } SDL_MouseButtonEvent;
/** /**
@ -239,8 +241,9 @@ typedef struct SDL_MouseWheelEvent
Uint32 type; /**< ::SDL_MOUSEWHEEL */ Uint32 type; /**< ::SDL_MOUSEWHEEL */
Uint32 timestamp; Uint32 timestamp;
Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 windowID; /**< The window with mouse focus, if any */
int x; /**< The amount scrolled horizontally */ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
int y; /**< The amount scrolled vertically */ Sint32 x; /**< The amount scrolled horizontally */
Sint32 y; /**< The amount scrolled vertically */
} SDL_MouseWheelEvent; } SDL_MouseWheelEvent;
/** /**
@ -467,7 +470,7 @@ typedef struct SDL_UserEvent
Uint32 type; /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */ Uint32 type; /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
Uint32 timestamp; Uint32 timestamp;
Uint32 windowID; /**< The associated window if any */ 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 *data1; /**< User defined data pointer */
void *data2; /**< User defined data pointer */ void *data2; /**< User defined data pointer */
} SDL_UserEvent; } SDL_UserEvent;

View file

@ -40,12 +40,11 @@ extern "C" {
/* *INDENT-ON* */ /* *INDENT-ON* */
#endif #endif
typedef Sint64 SDL_TouchID; typedef Sint64 SDL_TouchID;
typedef Sint64 SDL_FingerID; typedef Sint64 SDL_FingerID;
typedef struct SDL_Finger
struct SDL_Finger { {
SDL_FingerID id; SDL_FingerID id;
Uint16 x; Uint16 x;
Uint16 y; Uint16 y;
@ -54,16 +53,12 @@ struct SDL_Finger {
Uint16 ydelta; Uint16 ydelta;
Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */ Uint16 last_x, last_y,last_pressure; /* the last reported coordinates */
SDL_bool down; SDL_bool down;
}; } SDL_Finger;
typedef struct SDL_Touch SDL_Touch;
typedef struct SDL_Finger SDL_Finger;
struct SDL_Touch {
typedef struct SDL_Touch
{
/* Free the touch when it's time */ /* Free the touch when it's time */
void (*FreeTouch) (SDL_Touch * touch); void (*FreeTouch) (struct SDL_Touch * touch);
/* data common for tablets */ /* data common for tablets */
float pressure_max, pressure_min; float pressure_max, pressure_min;
@ -89,28 +84,23 @@ struct SDL_Touch {
SDL_Finger** fingers; SDL_Finger** fingers;
void *driverdata; void *driverdata;
}; } SDL_Touch;
/* Used as the device ID for mouse events simulated with touch input */
#define SDL_TOUCH_MOUSEID ((Uint32)-1)
/* Function prototypes */ /* 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 extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);
DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -81,7 +81,7 @@ SDL_ResetMouse(void)
#endif #endif
for (i = 1; i <= sizeof(mouse->buttonstate)*8; ++i) { for (i = 1; i <= sizeof(mouse->buttonstate)*8; ++i) {
if (mouse->buttonstate & SDL_BUTTON(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); SDL_assert(mouse->buttonstate == 0);
@ -174,7 +174,7 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
} }
int 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(); SDL_Mouse *mouse = SDL_GetMouse();
int posted; int posted;
@ -252,6 +252,7 @@ SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
SDL_Event event; SDL_Event event;
event.motion.type = SDL_MOUSEMOTION; event.motion.type = SDL_MOUSEMOTION;
event.motion.windowID = mouse->focus ? mouse->focus->id : 0; event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
event.motion.which = mouseID;
event.motion.state = mouse->buttonstate; event.motion.state = mouse->buttonstate;
event.motion.x = mouse->x; event.motion.x = mouse->x;
event.motion.y = mouse->y; event.motion.y = mouse->y;
@ -266,7 +267,7 @@ SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
} }
int 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(); SDL_Mouse *mouse = SDL_GetMouse();
int posted; int posted;
@ -304,11 +305,12 @@ SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
if (SDL_GetEventState(type) == SDL_ENABLE) { if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.type = type; event.type = type;
event.button.windowID = mouse->focus ? mouse->focus->id : 0;
event.button.which = mouseID;
event.button.state = state; event.button.state = state;
event.button.button = button; event.button.button = button;
event.button.x = mouse->x; event.button.x = mouse->x;
event.button.y = mouse->y; event.button.y = mouse->y;
event.button.windowID = mouse->focus ? mouse->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
} }
@ -321,7 +323,7 @@ SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
} }
int 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(); SDL_Mouse *mouse = SDL_GetMouse();
int posted; int posted;
@ -340,6 +342,7 @@ SDL_SendMouseWheel(SDL_Window * window, int x, int y)
SDL_Event event; SDL_Event event;
event.type = SDL_MOUSEWHEEL; event.type = SDL_MOUSEWHEEL;
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0; event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
event.wheel.which = mouseID;
event.wheel.x = x; event.wheel.x = x;
event.wheel.y = y; event.wheel.y = y;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
@ -396,7 +399,7 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
if (mouse->WarpMouse) { if (mouse->WarpMouse) {
mouse->WarpMouse(window, x, y); mouse->WarpMouse(window, x, y);
} else { } else {
SDL_SendMouseMotion(window, 0, x, y); SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y);
} }
} }

View file

@ -25,6 +25,8 @@
#include "SDL_mouse.h" #include "SDL_mouse.h"
typedef Uint32 SDL_MouseID;
struct SDL_Cursor struct SDL_Cursor
{ {
struct SDL_Cursor *next; struct SDL_Cursor *next;
@ -55,6 +57,7 @@ typedef struct
int (*SetRelativeMouseMode) (SDL_bool enabled); int (*SetRelativeMouseMode) (SDL_bool enabled);
/* Data common to all mice */ /* Data common to all mice */
SDL_MouseID mouseID;
SDL_Window *focus; SDL_Window *focus;
int x; int x;
int y; int y;
@ -86,13 +89,13 @@ extern void SDL_SetDefaultCursor(SDL_Cursor * cursor);
extern void SDL_SetMouseFocus(SDL_Window * window); extern void SDL_SetMouseFocus(SDL_Window * window);
/* Send a mouse motion event */ /* 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 */ /* 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 */ /* 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 */ /* Shutdown the mouse subsystem */
extern void SDL_MouseQuit(void); extern void SDL_MouseQuit(void);

View file

@ -221,7 +221,7 @@ private:
return; return;
} }
win = GetSDLWindow(winID); 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 */ /* Tell the application that the mouse passed over, redraw needed */
BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); BE_UpdateWindowFramebuffer(NULL,win,NULL,-1);
@ -239,7 +239,7 @@ private:
return; return;
} }
win = GetSDLWindow(winID); win = GetSDLWindow(winID);
SDL_SendMouseButton(win, state, button); SDL_SendMouseButton(win, 0, state, button);
} }
void _HandleMouseWheel(BMessage *msg) { void _HandleMouseWheel(BMessage *msg) {
@ -254,7 +254,7 @@ private:
return; return;
} }
win = GetSDLWindow(winID); win = GetSDLWindow(winID);
SDL_SendMouseWheel(win, xTicks, yTicks); SDL_SendMouseWheel(win, 0, xTicks, yTicks);
} }
void _HandleKey(BMessage *msg) { void _HandleKey(BMessage *msg) {

View file

@ -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); Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */ /* 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 */ /* 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; 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); Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */ /* 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); SDL_SendTouchMotion(touchDeviceId, fingerId, SDL_FALSE, x, y, p);
break; 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: case ACTION_POINTER_1_UP:
if (fingerId == leftFingerDown) { if (fingerId == leftFingerDown) {
/* send mouse up */ /* send mouse up */
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
leftFingerDown = 0; leftFingerDown = 0;
} }
SDL_SendFingerDown(touchDeviceId, fingerId, SDL_FALSE, x, y, p); SDL_SendFingerDown(touchDeviceId, fingerId, SDL_FALSE, x, y, p);

View file

@ -223,13 +223,15 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
[event type] == NSOtherMouseDragged)) { [event type] == NSOtherMouseDragged)) {
float x = [event deltaX]; float x = [event deltaX];
float y = [event deltaY]; 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 void
Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
{ {
SDL_Mouse *mouse = SDL_GetMouse();
float x = [event deltaX]; float x = [event deltaX];
float y = [event deltaY]; float y = [event deltaY];
@ -243,7 +245,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
} else if (y < 0) { } else if (y < 0) {
y -= 0.9f; y -= 0.9f;
} }
SDL_SendMouseWheel(window, (int)x, (int)y); SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y);
} }
void void

View file

@ -200,7 +200,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
y = (int)(window->h - point.y); y = (int)(window->h - point.y);
if (x >= 0 && x < window->w && y >= 0 && y < window->h) { 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); SDL_SetCursor(NULL);
} }
} }
@ -263,7 +263,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
button = [theEvent buttonNumber] + 1; button = [theEvent buttonNumber] + 1;
break; break;
} }
SDL_SendMouseButton(_data->window, SDL_PRESSED, button); SDL_SendMouseButton(_data->window, 0, SDL_PRESSED, button);
} }
- (void)rightMouseDown:(NSEvent *)theEvent - (void)rightMouseDown:(NSEvent *)theEvent
@ -294,7 +294,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
button = [theEvent buttonNumber] + 1; button = [theEvent buttonNumber] + 1;
break; break;
} }
SDL_SendMouseButton(_data->window, SDL_RELEASED, button); SDL_SendMouseButton(_data->window, 0, SDL_RELEASED, button);
} }
- (void)rightMouseUp:(NSEvent *)theEvent - (void)rightMouseUp:(NSEvent *)theEvent
@ -342,7 +342,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
} }
} }
SDL_SendMouseMotion(window, 0, x, y); SDL_SendMouseMotion(window, 0, 0, x, y);
} }
- (void)mouseDragged:(NSEvent *)theEvent - (void)mouseDragged:(NSEvent *)theEvent

View file

@ -40,13 +40,13 @@
#include "SDL_DirectFB_events.h" #include "SDL_DirectFB_events.h"
#if USE_MULTI_API #if USE_MULTI_API
#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(id, relative, x, y, p) #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(id, state, button) #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_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(id, state, scancode)
#define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(id, text) #define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(id, text)
#else #else
#define SDL_SendMouseMotion_ex(w, id, relative, x, y, p) SDL_SendMouseMotion(w, relative, x, y) #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, state, button) #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_SendKeyboardKey_ex(id, state, scancode) SDL_SendKeyboardKey(state, scancode)
#define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(text) #define SDL_SendKeyboardText_ex(id, text) SDL_SendKeyboardText(text)
#endif #endif

View file

@ -37,15 +37,15 @@ NDS_PumpEvents(_THIS)
scanKeys(); scanKeys();
/* TODO: defer click-age */ /* TODO: defer click-age */
if (keysDown() & KEY_TOUCH) { if (keysDown() & KEY_TOUCH) {
SDL_SendMouseButton(0, SDL_PRESSED, 0); SDL_SendMouseButton(NULL, 0, SDL_PRESSED, 0);
} else if (keysUp() & KEY_TOUCH) { } else if (keysUp() & KEY_TOUCH) {
SDL_SendMouseButton(0, SDL_RELEASED, 0); SDL_SendMouseButton(NULL, 0, SDL_RELEASED, 0);
} }
if (keysHeld() & KEY_TOUCH) { if (keysHeld() & KEY_TOUCH) {
touchPosition t; touchPosition t;
touchRead(&t); touchRead(&t);
SDL_SendMouseMotion(0, 0, t.px, t.py); SDL_SendMouseMotion(NULL, 0, 0, t.px, t.py);
} }
} }

View file

@ -104,10 +104,10 @@
CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO]; CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
/* send moved event */ /* 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 */ /* 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; leftFingerDown = (SDL_FingerID)touch;
} }
@ -144,7 +144,7 @@
while(touch) { while(touch) {
if ((SDL_FingerID)touch == leftFingerDown) { if ((SDL_FingerID)touch == leftFingerDown) {
/* send mouse up */ /* send mouse up */
SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
leftFingerDown = 0; leftFingerDown = 0;
} }
@ -189,7 +189,7 @@
CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO]; CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
/* send moved event */ /* 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]; CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];

View file

@ -191,11 +191,11 @@ WIN_CheckWParamMouseButton( SDL_bool bwParamMousePressed, SDL_bool bSDLMousePres
{ {
if ( bwParamMousePressed && !bSDLMousePressed ) if ( bwParamMousePressed && !bSDLMousePressed )
{ {
SDL_SendMouseButton(data->window, SDL_PRESSED, button); SDL_SendMouseButton(data->window, 0, SDL_PRESSED, button);
} }
else if ( !bwParamMousePressed && bSDLMousePressed ) 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: case WM_MOUSEMOVE:
if( !SDL_GetMouse()->relative_mode ) 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 */ /* don't break here, fall through to check the wParam like the button presses */
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_RBUTTONUP: case WM_RBUTTONUP:
@ -408,7 +408,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if((mouse->usFlags & 0x01) == MOUSE_MOVE_RELATIVE) 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 else
{ {
@ -420,7 +420,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
initialMousePoint.y = mouse->lLastY; 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.x = mouse->lLastX;
initialMousePoint.y = mouse->lLastY; 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 // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
short motion = GET_WHEEL_DELTA_WPARAM(wParam) / 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; break;
} }

View file

@ -448,24 +448,23 @@ X11_DispatchEvent(_THIS)
printf("window %p: X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); printf("window %p: X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
#endif #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; break;
case ButtonPress:{ case ButtonPress:{
int ticks = 0; int ticks = 0;
if (X11_IsWheelEvent(display,&xevent,&ticks) == SDL_TRUE) { if (X11_IsWheelEvent(display,&xevent,&ticks)) {
SDL_SendMouseWheel(data->window, 0, ticks); SDL_SendMouseWheel(data->window, 0, 0, ticks);
} } else {
else { SDL_SendMouseButton(data->window, 0, SDL_PRESSED, xevent.xbutton.button);
SDL_SendMouseButton(data->window, SDL_PRESSED, xevent.xbutton.button);
} }
} }
break; break;
case ButtonRelease:{ case ButtonRelease:{
SDL_SendMouseButton(data->window, SDL_RELEASED, xevent.xbutton.button); SDL_SendMouseButton(data->window, 0, SDL_RELEASED, xevent.xbutton.button);
} }
break; break;

View file

@ -142,7 +142,7 @@ X11_HandleXinput2Event(SDL_VideoData *videodata,XGenericEventCookie *cookie)
parse_valuators(rawev->raw_values,rawev->valuators.mask, parse_valuators(rawev->raw_values,rawev->valuators.mask,
rawev->valuators.mask_len,relative_cords,2); 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; return 1;
} }
break; break;