v2026.9.6
All Bundles
Bundle SDL2 multimedia library for 2D graphics, input handling, audio playback, and window management. Core types: Window, Renderer, Texture, Surface, Event, and Mixer. Compile with -lib sdl2.

Cursor

Mouse cursor operations

Operations

CaptureMouse # function

Capture the mouse and to track input outside an SDL window

function : CaptureMouse(enabled:Bool) ~ Int

Parameters

NameTypeDescription
enabledBooltrue to enable capturing, false to disable.

Return

TypeDescription
Int0 on success or -1 if not supported

GetGlobalMouseState # function

Retrieve the current global state of the mouse

function : GetGlobalMouseState(x:IntRef, y:IntRef) ~ Int

Parameters

NameTypeDescription
xIntRefcoordinate of the mouse cursor position relative to the focus window
yIntRefcoordinate of the mouse cursor position relative to the focus window

Return

TypeDescription
Intcurrent button state as a bitmask

GetGlobalMouseState # function

Retrieve the current global state of the mouse

function : GetGlobalMouseState(p:Point) ~ Int

Parameters

NameTypeDescription
pPointx and y coordinates of the mouse cursor position relative to the focus window

Return

TypeDescription
Intcurrent button state as a bitmask

GetMouseState # function

Retrieve the current state of the mouse

function : GetMouseState(x:IntRef, y:IntRef) ~ Int

Parameters

NameTypeDescription
xIntRefcoordinate of the mouse cursor position relative to the focus window
yIntRefcoordinate of the mouse cursor position relative to the focus window

Return

TypeDescription
Intcurrent button state as a bitmask

GetMouseState # function

Retrieve the current state of the mouse

function : GetMouseState(p:Point) ~ Int

Parameters

NameTypeDescription
pPointx and y coordinates of the mouse cursor position relative to the focus window

Return

TypeDescription
Intcurrent button state as a bitmask

GetRelativeMouseMode # function

Whether relative mouse mode is currently on.

function : GetRelativeMouseMode() ~ Bool

Return

TypeDescription
Booltrue when the mouse is captured for relative motion

SetRelativeMouseMode # function

Turn relative mouse mode on or off. This is what mouse-look needs. It hides the cursor, locks it to the window, and makes motion events report unbounded deltas -- read them with MouseMotionEvent->GetRelX/GetRelY. Without it the pointer stops at the screen edge and the view stops turning with it. Turn it off before showing a menu, or the user cannot click anything.

function : SetRelativeMouseMode(enabled:Bool) ~ Int

Parameters

NameTypeDescription
enabledBooltrue to capture the mouse for look control

Return

TypeDescription
Int0 on success, or -1 if the platform does not support it

WarpMouseGlobal # function

Move the mouse to the given position in global screen space

function : WarpMouseGlobal(x:Int, y:Int) ~ Int

Parameters

NameTypeDescription
xIntx coordinate
yInty coordinate

Return

TypeDescription
Int0 on success or a negative error code on failure