In addition to the event callback system, LWXGL exposes polling functions that let you read the current input state at any point during the frame. This is useful for smooth per-frame movement where you want to respond to keys that are held down, rather than reacting to individual press events. Polling and event callbacks are not mutually exclusive — both mechanisms read from the same internal state and can be used together.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/DRESsedAlarm184/LWXGL/llms.txt
Use this file to discover all available pages before exploring further.
Key Constants
| Constant | Value | Key |
|---|---|---|
KEY_LEFT | 170 | Left arrow |
KEY_RIGHT | 171 | Right arrow |
KEY_UP | 172 | Up arrow |
KEY_DOWN | 173 | Down arrow |
KEY_FN | 150 | Base value — add 1–12 for F1–F12 |
QueryKeyboard
EventAttachKey callback (ASCII for printable characters, or the special constants above). Slots that are not in use contain 0.
The array supports up to 8 simultaneously held keys. When more than 8 keys are held, additional presses are silently dropped.
Pointer to an 8-byte array owned by LWXGL. Do not
free() this pointer. The values are valid for the duration of the current frame callback.The array is updated at the start of each frame loop iteration by
_handle_window_events(). Reading it outside the frame callback (e.g. from a timer thread) may produce stale values.QueryKeyDown
1 if the key with value ch is currently held down, 0 otherwise. Equivalent to scanning the array returned by QueryKeyboard for a matching entry, but more convenient for checking individual keys.
Key value to test. Use ASCII for printable characters, or the
KEY_* constants for special keys.QueryMouse
| Output | Meaning |
|---|---|
*x | Cursor X position relative to the window origin, or -1 when outside the window |
*y | Cursor Y position relative to the window origin, or -1 when outside the window |
*btn | Currently held mouse button (1=left, 2=middle, 3=right), or 0 if none |
MotionNotify event; it becomes -1, -1 on LeaveNotify.
Output pointer for the cursor X coordinate.
Output pointer for the cursor Y coordinate.
Output pointer for the currently pressed button.
0 means no button is pressed.QueryMouse reflects the button held state (set on ButtonPress, cleared on ButtonRelease), not a click event. For click detection use EventAttachClick.