From 0f199b1ab8914dc476893e8bf42a2b5dd268a87d Mon Sep 17 00:00:00 2001 From: Szymon Wilczek Date: Wed, 6 Aug 2008 08:48:43 +0000 Subject: [PATCH] upgraded functions --- include/SDL_mouse.h | 12 +++++----- src/SDL_compat.c | 2 +- src/events/SDL_mouse.c | 47 +++++++++++++++++++++------------------- src/events/SDL_mouse_c.h | 8 +++---- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/include/SDL_mouse.h b/include/SDL_mouse.h index 2abca6038..759ab0909 100644 --- a/include/SDL_mouse.h +++ b/include/SDL_mouse.h @@ -72,7 +72,7 @@ extern DECLSPEC int SDLCALL SDL_SelectMouse(int index); * * \brief Get the window which currently has focus for the currently selected mouse. */ -extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(void); +extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(int index); /** * \fn int SDL_SetRelativeMouseMode(SDL_bool enabled) @@ -92,7 +92,7 @@ extern DECLSPEC SDL_WindowID SDLCALL SDL_GetMouseFocusWindow(void); * * \sa SDL_GetRelativeMouseMode() */ -extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled, int index); +extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(int index, SDL_bool enabled); /** * \fn SDL_bool SDL_GetRelativeMouseMode() @@ -101,7 +101,7 @@ extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled, int index * * \sa SDL_SetRelativeMouseMode() */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); +extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(int index); /** * \fn Uint8 SDL_GetMouseState(int *x, int *y) @@ -113,7 +113,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); * mouse cursor position relative to the focus window for the currently * selected mouse. You can pass NULL for either x or y. */ -extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); +extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int index, int *x, int *y); /** * \fn Uint8 SDL_GetRelativeMouseState(int *x, int *y) @@ -124,7 +124,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); * be tested using the SDL_BUTTON(X) macros, and x and y are set to the * mouse deltas since the last call to SDL_GetRelativeMouseState(). */ -extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); +extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int index, int *x, int *y); /** * \fn void SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y) @@ -210,6 +210,8 @@ extern DECLSPEC char* SDLCALL SDL_GetMouseName(int index); extern DECLSPEC int SDLCALL SDL_GetCursorsNumber(int index); +extern DECLSPEC int SDLCALL SDL_GetCurrentCursor(int index); + #define SDL_BUTTON(X) (1 << ((X)-1)) #define SDL_BUTTON_LEFT 1 #define SDL_BUTTON_MIDDLE 2 diff --git a/src/SDL_compat.c b/src/SDL_compat.c index 0d29b44d4..1c1572a69 100644 --- a/src/SDL_compat.c +++ b/src/SDL_compat.c @@ -256,7 +256,7 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event) } selected = SDL_SelectMouse(event->wheel.which); - SDL_GetMouseState(&x, &y); + SDL_GetMouseState(selected, &x, &y); SDL_SelectMouse(selected); if (event->wheel.y > 0) { diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 28bc562bb..098264ecc 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -174,9 +174,9 @@ SDL_SelectMouse(int index) } SDL_WindowID -SDL_GetMouseFocusWindow() +SDL_GetMouseFocusWindow(int index) { - SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); + SDL_Mouse *mouse = SDL_GetMouse(index); if (!mouse) { return 0; @@ -196,7 +196,7 @@ FlushMouseMotion(void *param, SDL_Event * event) } int -SDL_SetRelativeMouseMode(SDL_bool enabled, int index) +SDL_SetRelativeMouseMode(int index, SDL_bool enabled) { SDL_Mouse *mouse = SDL_GetMouse(index); @@ -224,9 +224,9 @@ SDL_SetRelativeMouseMode(SDL_bool enabled, int index) } SDL_bool -SDL_GetRelativeMouseMode() +SDL_GetRelativeMouseMode(int index) { - SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); + SDL_Mouse *mouse = SDL_GetMouse(index); if (!mouse) { return SDL_FALSE; @@ -235,9 +235,9 @@ SDL_GetRelativeMouseMode() } Uint8 -SDL_GetMouseState(int *x, int *y) +SDL_GetMouseState(int index, int *x, int *y) { - SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); + SDL_Mouse *mouse = SDL_GetMouse(index); if (!mouse) { if (x) { @@ -259,9 +259,9 @@ SDL_GetMouseState(int *x, int *y) } Uint8 -SDL_GetRelativeMouseState(int *x, int *y) +SDL_GetRelativeMouseState(int index, int *x, int *y) { - SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); + SDL_Mouse *mouse = SDL_GetMouse(index); if (!mouse) { if (x) { @@ -494,10 +494,6 @@ SDL_SendMouseButton(int id, Uint8 state, Uint8 button) mouse->buttonstate |= SDL_BUTTON(button); break; case SDL_RELEASED: - //if (!(mouse->buttonstate & SDL_BUTTON(button))) { - // /* Ignore this event, no state change */ - // return 0; - //}*/ type = SDL_MOUSEBUTTONUP; mouse->buttonstate &= ~SDL_BUTTON(button); break; @@ -809,15 +805,22 @@ void SDL_ChangeEnd(int id, int end) int SDL_GetCursorsNumber(int index) { - if(index>=SDL_num_mice) - { - return -1; - } - if(SDL_mice[index]==NULL) - { - return -1; - } - return SDL_mice[index]->total_ends; + SDL_Mouse* mouse = SDL_GetMouse(index); + if(!mouse) + { + return -1; + } + return mouse->total_ends; +} + +int SDL_GetCurrentCursor(int index) +{ + SDL_Mouse* mouse = SDL_GetMouse(index); + if(!mouse) + { + return -1; + } + return mouse->current_end; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 6917a46f6..0355a8ab5 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -108,16 +108,16 @@ extern void SDL_DelMouse(int index); extern void SDL_ResetMouse(int index); /* Set the mouse focus window */ -extern void SDL_SetMouseFocus(int index, SDL_WindowID windowID); +extern void SDL_SetMouseFocus(int id, SDL_WindowID windowID); /* Send a mouse motion event for a mouse at an index */ -extern int SDL_SendMouseMotion(int index, int relative, int x, int y, int z); +extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z); /* Send a mouse button event for a mouse at an index */ -extern int SDL_SendMouseButton(int index, Uint8 state, Uint8 button); +extern int SDL_SendMouseButton(int id, Uint8 state, Uint8 button); /* Send a mouse wheel event for a mouse at an index */ -extern int SDL_SendMouseWheel(int index, int x, int y); +extern int SDL_SendMouseWheel(int id, int x, int y); /* Shutdown the mouse subsystem */ extern void SDL_MouseQuit(void);