Function SDL_SetWindowRelativeMouseMode
pub unsafe extern "C" fn SDL_SetWindowRelativeMouseMode(
window: *mut SDL_Window,
enabled: bool,
) -> bool
dep_sdl3
only.Expand description
Set relative mouse mode for a window.
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.
§Parameters
window
: the window to change.enabled
: true to enable relative mode, false to disable.
§Return value
Returns true on success or false on failure; call SDL_GetError()
for more
information.
§Thread safety
This function should only be called on the main thread.
§Availability
This function is available since SDL 3.2.0.