Returns current mouse cursor X coordinate in window space.
Takes no parameters.
Returns integer X position (horizontal pixel coordinate, 0=left edge of window).
Input
Parameters & Returns
Parameters
This function takes no parameters.
Returns
Int
Quick Summary
Returns current mouse cursor X coordinate in window space.
Takes no parameters.
Returns integer X position (horizontal pixel coordinate, 0=left edge of window).
Technical Exegesis...
Returns current mouse cursor X coordinate in window space. Takes no parameters. Returns integer X position (horizontal pixel coordinate, 0=left edge of window). Queries mouse cursor position relative to window client area, updates automatically each frame.
Coordinate system: 0=left edge of window (minimum X), increases rightward (positive direction), window width-1=right edge (maximum X, e.g.
Returns current mouse cursor X coordinate in window space. Takes no parameters. Returns integer X position (horizontal pixel coordinate, 0=left edge of window). Queries mouse cursor position relative to window client area, updates automatically each frame.
Coordinate system: 0=left edge of window (minimum X), increases rightward (positive direction), window width-1=right edge (maximum X, e.g., 1919 for 1920px window), coordinates in pixels (integer screen space), relative to window client area (excludes title bar and borders).
Use cases: (1) Cursor rendering (draw custom cursor at mouse position: b2dDrawImage(cursor, inpGetMouseX(), inpGetMouseY())), (2) UI interaction (check if mouse over button bounds), (3) Object selection (3D picking, ray cast from mouse position), (4) Camera control (mouse look, calculate rotation from mouse movement), (5) Drawing/painting tools (track mouse position for brush strokes).
Common patterns: cursor position = mouseX%=inpGetMouseX(): mouseY%=inpGetMouseY(); bounds check = If inpGetMouseX()>=buttonX AND inpGetMouseX()<buttonX+buttonWidth Then mouse over button; center offset = deltaX%=inpGetMouseX()-(windowWidth/2) (distance from center); coordinate conversion = worldX#=(inpGetMouseX()-cameraX)/zoom# (screen to world space).
Window vs screen space: inpGetMouseX returns window-relative coordinates (0,0=top-left of window client area), not screen-absolute coordinates (monitor position), coordinates remain valid when window moved (always relative to window), coordinates adjust when window resized (may need to handle resize events).
Out of bounds: mouse can leave window (coordinates become invalid when cursor outside), coordinates may be negative or exceed window bounds (when cursor outside client area), check bounds if needed (If mouseX>=0 AND mouseX<windowWidth Then inside window), some systems clamp to window bounds (depends on OS and windowing mode).
Performance: very fast query (~0.0001ms, simple variable access), safe for per-frame calls (negligible overhead), no input polling required (system updates cursor position automatically).
Coordinate precision: returns integer pixels (no sub-pixel precision), for smoother mouse tracking use inpGetMouseXSpeed (delta movement), high-DPI displays handled by system (coordinates in logical pixels, not physical).
Fullscreen mode: coordinates relative to fullscreen window (0,0=top-left of screen in fullscreen), same coordinate system as windowed mode (consistent API regardless of display mode).