logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SDL_SetWindowRelativeMouseMode - Set relative mouse mode for a window.

Availability

       This function is available since SDL 3.2.0.

Description

       While  the  window has focus and relative mouse mode is enabled, the cursor is hidden, the mouse position
       is constrained to the window, and SDL will report continuous relative mouse motion even if the  mouse  is
       at the edge of the window.

       If  you'd like to keep the mouse position fixed while in relative mode you can use SDL_SetWindowMouseRect
       (). If you'd like the cursor to be at a specific  location  when  relative  mode  ends,  you  should  use
       SDL_WarpMouseInWindow () before disabling relative mode.

       This function will flush any pending mouse motion for this window.

Function Parameters

window the window to change.

       enabled
              true to enable relative mode, false to disable.

Header File

       Defined in SDL3/SDL_mouse.h

Name

       SDL_SetWindowRelativeMouseMode - Set relative mouse mode for a window.

Return Value

       Returns true on success or false on failure; call

       SDL_GetError () for more information.

See Also

(3), SDL_GetWindowRelativeMouseMode(3)

Simple Directmedia Layer                           SDL 3.2.10                  SDL_SetWindowRelativeMouseMode(3)

Synopsis

#include"SDL3/SDL.h"boolSDL_SetWindowRelativeMouseMode(SDL_Window*window,boolenabled);

Thread Safety

       This function should only be called on the main thread.

See Also