mirror of
https://github.com/encounter/SDL.git
synced 2025-12-12 06:45:10 +00:00
Implemented SDL_GetAbsoluteMouseState().
X11 only for now, but this should be doable on every platform, I think.
This commit is contained in:
@@ -469,6 +469,30 @@ SDL_GetRelativeMouseState(int *x, int *y)
|
||||
return mouse->buttonstate;
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_GetAbsoluteMouseState(int *x, int *y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
int tmpx, tmpy;
|
||||
|
||||
/* make sure these are never NULL for the backend implementations... */
|
||||
if (!x) {
|
||||
x = &tmpx;
|
||||
}
|
||||
if (!y) {
|
||||
y = &tmpy;
|
||||
}
|
||||
|
||||
*x = *y = 0;
|
||||
|
||||
if (!mouse->GetAbsoluteMouseState) {
|
||||
SDL_assert(0 && "This should really be implemented for every target.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return mouse->GetAbsoluteMouseState(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
|
||||
{
|
||||
|
||||
@@ -66,6 +66,9 @@ typedef struct
|
||||
/* Set mouse capture */
|
||||
int (*CaptureMouse) (SDL_Window * window);
|
||||
|
||||
/* Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. */
|
||||
Uint32 (*GetAbsoluteMouseState) (int *x, int *y);
|
||||
|
||||
/* Data common to all mice */
|
||||
SDL_MouseID mouseID;
|
||||
SDL_Window *focus;
|
||||
|
||||
Reference in New Issue
Block a user