A windowed action game can hide the OS cursor and lock/confine the mouse to the window. Input.cursor_mode(mode): 0 normal, 1 hidden (draw your own reticle), 2 locked (hidden + dissociated — the mouse feeds relative motion via Input.mouse_dx/dy and Input.mouse_x/y is a clamped virtual cursor, FPS/twin-stick aim), 3 confined (dissociated but visible; the mouse can't leave the window). The platform auto-releases (shows + reconnects) while the window is not key (Cmd-Tab) and on close, so the cursor is never left captured. Headless it is a no-op (DCE'd). Native macOS impl in cocoa.ll: [NSCursor hide]/[unhide] (ref-counted, toggled only on change so the count stays balanced across focus changes), CGAssociateMouseAndMouseCursorPosition, and CGGetLastMouseDelta for the relative virtual cursor, behind a new win_cursor_mode intrinsic. Windowed-only behaviour (not in the headless golden suite); example compiles headless and links windowed. Full suite 115/0, fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1.5 KiB
1.5 KiB
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| input-cursor_mode | Input.cursor_mode | input | namespace-method | Input.cursor_mode | Input.cursor_mode(mode) | Hide / lock / confine the OS mouse cursor to the window (windowed). | 36 | Input | cursor_mode |
Sets how a windowed game captures the OS mouse cursor:
0normal (default) — the cursor is visible and free.1hidden — the cursor is hidden while the window is focused, so a game can draw its own reticle.2locked — hidden and dissociated from the mouse; the mouse feeds relative motion throughInput.mouse_dx/mouse_dy, andInput.mouse_x/mouse_yis a clamped virtual cursor — the FPS / twin-stick aim mode.3confined — dissociated but visible; the mouse cannot leave the window.
The platform auto-releases (shows the cursor and reconnects it) while the window is not the key window (Cmd-Tab), and restores it on window close, so the cursor is never left captured. On a headless / non-windowed build it is a no-op.
program Aim {
property Tag { n: int = 0 }
model P { Tag }
@OnStart handler Boot { Input.cursor_mode(2) } # lock + hide for aiming
handler Draw phase Render {
Screen.clear(0x101018)
Screen.fill_rectangle(Input.mouse_x() - 2, Input.mouse_y() - 2, 4, 4, 0xffcc00)
Screen.show()
}
}