Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
upgraded functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Wilczek committed Aug 6, 2008
1 parent 231fdd6 commit 0f199b1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 32 deletions.
12 changes: 7 additions & 5 deletions include/SDL_mouse.h
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/SDL_compat.c
Expand Up @@ -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) {
Expand Down
47 changes: 25 additions & 22 deletions src/events/SDL_mouse.c
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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: */

8 changes: 4 additions & 4 deletions src/events/SDL_mouse_c.h
Expand Up @@ -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);
Expand Down

0 comments on commit 0f199b1

Please sign in to comment.