Skip to content

Commit

Permalink
Implemented SDL_GetMouseState().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 13, 2013
1 parent 24cf080 commit 259fc2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/SDL12_compat.c
Expand Up @@ -41,7 +41,6 @@
// !!! IMPLEMENT_ME SDL_GetKeyName
// !!! IMPLEMENT_ME SDL_GetKeyState
// !!! IMPLEMENT_ME SDL_GetModState
// !!! IMPLEMENT_ME SDL_GetMouseState
// !!! IMPLEMENT_ME SDL_GetRelativeMouseState
// !!! IMPLEMENT_ME SDL_LockSurface
// !!! IMPLEMENT_ME SDL_LowerBlit
Expand Down Expand Up @@ -1940,6 +1939,21 @@ SDL_WM_GrabInput(SDL_GrabMode mode)
return (SDL_GrabMode) SDL_GetWindowGrab(VideoWindow20);
}

Uint8
SDL_GetMouseState(int *x, int *y)
{
const Uint32 state20 = SDL20_GetMouseState(x, y);
Uint8 retval = (state20 & 0x7); /* left, right, and middle will match. */

/* the X[12] buttons are different in 1.2; mousewheel was in the way. */
if (state20 & SDL_BUTTON(SDL_BUTTON_X1))
retval |= (1<<5);
if (state20 & SDL_BUTTON(SDL_BUTTON_X2))
retval |= (1<<6);

return retval;
}

void
SDL_WarpMouse(Uint16 x, Uint16 y)
{
Expand Down
2 changes: 2 additions & 0 deletions src/SDL20_syms.h
Expand Up @@ -50,6 +50,8 @@ SDL20_SYM(SDL_bool,SetClipRect,(SDL_Surface *a, const SDL_Rect *b),(a,b),return)
SDL20_SYM(int,FillRect,(SDL_Surface *a,const SDL_Rect *b,Uint32 c),(a,b,c),return)
SDL20_SYM(SDL_bool,IntersectRect,(const SDL_Rect *a,const SDL_Rect *b,SDL_Rect *c),(a,b,c),return)

SDL20_SYM(Uint32,GetMouseState,(int *a, int *b),(a,b),return)

SDL20_SYM_PASSTHROUGH(int,ShowCursor,(int a),(a),return)
SDL20_SYM(SDL_Cursor *,CreateCursor,(const Uint8 *a,const Uint8 *b,int c,int d,int e,int f),(a,b,c,d,e,f),return)
SDL20_SYM(void,SetCursor,(SDL_Cursor *a),(a),)
Expand Down

0 comments on commit 259fc2b

Please sign in to comment.