Confines mouse cursor to window client area (prevents cursor from leaving window).
Takes no parameters.
Returns nothing.
Input
Parameters & Returns
Parameters
This function takes no parameters.
Returns
Void
Quick Summary
Confines mouse cursor to window client area (prevents cursor from leaving window).
Takes no parameters.
Returns nothing.
Technical Exegesis...
Confines mouse cursor to window client area (prevents cursor from leaving window). Takes no parameters. Returns nothing. Uses Win32 ClipCursor API to restrict mouse movement to window bounds.
This function clips mouse. Mouse clipping: prevents cursor from moving outside window rectangle, cursor hits invisible wall at window edges, useful for FPS camera control and immersive games, user cannot accidentally click outside window during gameplay.
Confines mouse cursor to window client area (prevents cursor from leaving window). Takes no parameters. Returns nothing. Uses Win32 ClipCursor API to restrict mouse movement to window bounds.
This function clips mouse. Mouse clipping: prevents cursor from moving outside window rectangle, cursor hits invisible wall at window edges, useful for FPS camera control and immersive games, user cannot accidentally click outside window during gameplay. Window detection: automatically uses active graphics window, checks g_3D_hwnd first (3D graphics window), falls back to g_hwnd if legacy 2D graphics enabled, gets window client area rectangle (excludes title bar and borders). ClipCursor API: Win32 function that restricts cursor to specified screen rectangle, GetClientRect gets window's client area dimensions, ClientToScreen converts client coordinates to screen coordinates, ClipCursor sets global cursor clip region (affects entire OS). Use cases: (1) FPS camera control (mouse look without cursor escaping), (2) RTS games (prevent clicks outside game area), (3) Fullscreen games (keep cursor contained), (4) Immersive experiences (user focus on game window), (5) Mouse delta tracking (prevent cursor hitting screen edge). Common patterns: FPS setup = clip mouse + hide cursor at start, RTS = clip mouse during gameplay, release on menu, windowed mode = clip when window active, release when inactive, fullscreen = always clipped, window mode = clip on demand. Typical usage: call once at game start for continuous clipping, call when window gains focus (user clicks into window), pair with inpUnclipMouse for menu/pause states, combine with inpSetMouseVisible(False) to hide cursor for FPS games. Window activation: clipping respects window focus, if user Alt-Tabs away, Windows may release clip, re-clip when window regains focus (handle WM_ACTIVATE message), or call function periodically to maintain clip. Coordinate conversion: GetClientRect returns client-relative coordinates (0,0 at top-left), ClientToScreen converts to screen coordinates (absolute pixel position), ClipCursor requires screen coordinates (global desktop space), conversion ensures correct clipping rectangle. Edge behavior: cursor stops at window edges (cannot move further), cursor position clamped to clip rectangle, useful for mouse delta (cursor never hits screen edge), FPS camera can rotate infinitely without cursor escaping. Release clipping: call inpUnclipMouse to remove restriction, clipping persists until released or window loses focus, Windows may auto-release on window deactivation, explicitly release when showing menus or pausing. Client area: clips to client area only (excludes title bar, borders, menu bar), user can still interact with window controls (close button, minimize, maximize), prevents cursor from leaving drawable game area, title bar still accessible for window dragging. Multiple windows: clips to whichever window is active (3D or 2D), if both graphics modes inactive, does nothing, clip rectangle updates if window resized (need to re-call function), one clip region active at a time (system-wide restriction). Performance: negligible cost (single Win32 API call), no per-frame cost after initial clip, only call when needed (focus gain, start, window resize), minimal CPU overhead. Window resize: clip rectangle based on current window size, if window resized, clip rectangle outdated, re-call function after resize to update clip region, or handle WM_SIZE message to auto-re-clip. Fullscreen vs windowed: fullscreen mode often clips automatically, windowed mode requires explicit clipping, clip more important in windowed (prevent accidental outside clicks), fullscreen cursor naturally contained by screen bounds. User experience: improves FPS camera control (no cursor escape frustration), keeps player focused on game window, prevents accidental clicks to other applications, essential for immersive gameplay in windowed mode. Debug/development: may want to disable clipping during development, easier to switch to other windows/debuggers, use conditional compilation or debug flag to skip clipping, or toggle with debug key (F12 to unclip). Related window functions: inpUnclipMouse removes clipping (frees cursor), inpSetMouseVisible controls cursor visibility (often hidden when clipped), inpGetMouseX/Y read cursor position (within clipped area), window focus events determine when to clip/unclip. Common mistake: forgetting to unclip when showing menu, user cannot click menu buttons outside game view, always pair clip with appropriate unclip, handle pause/menu states to release cursor. Example workflow: (1) game starts -> clip mouse + hide cursor, (2) user plays FPS game (mouse controls camera, can't escape window), (3) user presses ESC for menu -> unclip mouse + show cursor, (4) user closes menu -> clip mouse + hide cursor, (5) repeat. Related: inpUnclipMouse releases cursor confinement (removes clip rectangle), inpSetMouseVisible hides/shows cursor (commonly paired with clipping), inpIsWindowActive detects focus (determines when to clip), inpGetMouseDeltaX/Y reads mouse movement (useful with clipping for camera control).