sdlSetWindowRelativeMouseMode function mouse
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.
\param window the window to change. \param enabled true to enable relative mode, false to disable. \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety This function should only be called on the main thread.
\since This function is available since SDL 3.2.0.
\sa SDL_GetWindowRelativeMouseMode
extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled)
Implementation
bool sdlSetWindowRelativeMouseMode(Pointer<SdlWindow> window, bool enabled) {
final sdlSetWindowRelativeMouseModeLookupFunction = _libSdl
.lookupFunction<
Uint8 Function(Pointer<SdlWindow> window, Uint8 enabled),
int Function(Pointer<SdlWindow> window, int enabled)
>('SDL_SetWindowRelativeMouseMode');
return sdlSetWindowRelativeMouseModeLookupFunction(window, enabled ? 1 : 0) ==
1;
}