Scroll to navigation

SDL_GetGlobalMouseState(3) SDL3 FUNCTIONS SDL_GetGlobalMouseState(3)

NAME

SDL_GetGlobalMouseState - Get the current state of the mouse in relation to the desktop.

HEADER FILE

Defined in SDL3/SDL_mouse.h

SYNOPSIS

#include "SDL3/SDL.h"
SDL_MouseButtonFlags SDL_GetGlobalMouseState(float *x, float *y);

DESCRIPTION

This works similarly to SDL_GetMouseState (), but the coordinates will be reported relative to the top-left of the desktop. This can be useful if you need to track the mouse outside of a specific window and SDL_CaptureMouse () doesn't fit your needs. For example, it could be useful if you need to track the mouse while dragging a window, where coordinates relative to a window might not be in sync at all times.

Note: SDL_GetMouseState () returns the mouse position as SDL understands it from the last pump of the event queue. This function, however, queries the OS for the current mouse position, and as such, might be a slightly less efficient function. Unless you know what you're doing and have a good reason to use this function, you probably want

SDL_GetMouseState () instead.

FUNCTION PARAMETERS

filled in with the current X coord relative to the desktop; can be NULL.
filled in with the current Y coord relative to the desktop; can be NULL.

RETURN VALUE

( SDL_MouseButtonFlags ) Returns the current button state as a bitmask which can be tested using the

SDL_BUTTON_MASK (X) macros.

AVAILABILITY

This function is available since SDL 3.1.3.

SEE ALSO

(3), SDL_CaptureMouse(3), (3), SDL_GetMouseState(3)

SDL 3.1.6 Simple Directmedia Layer