Category: Input
Syntax:
inpClipMouseToWindow:Void()
Void
Confines mouse cursor to window client area (prevents cursor from leaving window).
Takes no parameters.
Returns nothing.
View detailed documentation online
; FPS game setup - clip and hide cursor at start
Function SetupFPSControls()
inpClipMouseToWindow() ; Confine cursor to window
inpSetMouseVisible(False) ; Hide cursor for immersion
EndFunction
; Call at game start
SetupFPSControls()
; Main mouse-look loop - accumulate the angles, then use them however you
; draw. A raycaster feeds camYaw into its ray direction; a top-down game
; would aim the player sprite with it.
camYaw! = camYaw! + inpGetMouseDeltaX() * sensitivity!
camPitch! = camPitch! - inpGetMouseDeltaY() * sensitivity!
If camPitch! > 89.0 Then camPitch! = 89.0
If camPitch! < -89.0 Then camPitch! = -89.0
; Release cursor when showing pause menu
If inpIsKeyHit(VKEY_ESCAPE) Then
paused% = Not paused%
If paused% Then
inpUnclipMouse() ; Free cursor for menu
inpSetMouseVisible(True) ; Show cursor
Else
inpClipMouseToWindow() ; Re-clip for gameplay
inpSetMouseVisible(False) ; Hide cursor
EndIf
EndIf
; RTS game - clip when window active
Function OnWindowActivate()
If gameStarted% And Not menuActive% Then
inpClipMouseToWindow() ; Clip when window gains focus
EndIf
EndFunction
Function OnWindowDeactivate()
inpUnclipMouse() ; Release when window loses focus
EndFunction
; Handle window resize - re-clip to new window size
Function OnWindowResize()
If mouseCli pped% Then
inpClipMouseToWindow() ; Update clip rectangle to new size
EndIf
EndFunction
; Toggle clipping with debug key
If inpIsKeyHit(VKEY_F12) Then
debugUnclipped% = Not debugUnclipped%
If debugUnclipped% Then
inpUnclipMouse()
Print "Mouse unclipped (debug mode)"
Else
inpClipMouseToWindow()
Print "Mouse clipped to window"
EndIf
EndIf
; Windowed game with focus detection
While running%
sysUpdateEvents()
If inpIsWindowActive() Then
; Window active - clip mouse if not paused
If Not paused% And Not mouseClipped% Then
inpClipMouseToWindow()
mouseClipped% = True
EndIf
Else
; Window inactive - release mouse
If mouseClipped% Then
inpUnclipMouse()
mouseClipped% = False
EndIf
EndIf
; ... game logic ...
Wend
```
[meta]
since = "1.0"
status = "stable"
BambooBasic © 2026 Michael Denathorn