SDL_GetRelativeMouseState(3)

SDL_GetRelativeMouseState3

Query sdl's cache for the synchronous mouse button state and accumulated mouse delta since last call.

Usage

#include "SDL3/SDL.h"

SDL_MouseButtonFlags SDL_GetRelativeMouseState(float *x, float *y);

Header file

Defined in SDL3/SDL_mouse.h

Overview

This function returns the cached synchronous state as SDL understands it from the last pump of the event queue.

To query the platform for immediate asynchronous state, use

SDL_GetGlobalMouseState .

Passing non-NULL pointers to x or y will write the destination with respective x or y deltas accumulated since the last call to this function (or since event initialization).

This function is useful for reducing overhead by processing relative mouse inputs in one go per-frame instead of individually per-event, at the expense of losing the order between events within the frame (e.g. quickly pressing and releasing a button within the same frame).

Function parameters

x

a pointer to receive the x mouse delta accumulated since last call, can be NULL if unused.

y

a pointer to receive the y mouse delta accumulated since last call, can be NULL if unused.

Return value

( SDL_MouseButtonFlags ) Returns a 32-bit bitmask of the button state that can be bitwise-compared against the

SDL_BUTTON_MASK (X) macro.

Thread safety

This function should only be called on the main thread.

Releases

12 releases since Debian 3.0 (Woody); the text changed 2 times.

  1. 3.0–5.0
  2. 6.0–12
  3. 13

Availability

This function is available since SDL 3.2.0.

From libsdl3-doc 3.2.10+ds-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.