In addition to event-driven callbacks, LWXGL exposes a set of synchronous query functions that let you poll the current input state at any point in yourDocumentation 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.
on_every frame callback. This is especially useful for smooth, frame-rate-driven movement — rather than reacting to a single key-press event, you can check QueryKeyDown every frame and move an object by a fixed delta multiplied by the frame delta time. All query functions are safe to call from any thread that has already called MainWindowLoop, but the values they return reflect the state as of the most recently processed X11 event batch.
QueryMouse
Fills three output pointers with the current mouse position and held button state.
x and y are set to -1. btn holds the button that is currently held down (press without release); it is 0 when no button is held.
Pointer to receive the current cursor X coordinate, or
-1 if the cursor is outside the window.Pointer to receive the current cursor Y coordinate, or
-1 if the cursor is outside the window.Pointer to receive the held button index.
0 = none held, 1 = left, 2 = middle, 3 = right, 4 = scroll-up held, 5 = scroll-down held.QueryKeyboard
Returns a pointer to LWXGL’s internal 8-slot array of currently held key codes.
EventAttachKey callback), or 0 if the slot is unused. The array is owned by LWXGL — do not free or write to it.
Returns: Pointer to an unsigned char[8] array of currently held character codes.
For checking a single specific key, prefer
QueryKeyDown — it is more readable and avoids manual array iteration.QueryKeyDown
Returns whether a specific key is currently held.
ch. Works with any value that could appear in the EventAttachKey callback: printable ASCII codes, KEY_LEFT / KEY_RIGHT / KEY_UP / KEY_DOWN, or KEY_FN + N for F-keys.
The character code or
KEY_* constant to query.1 if the key is currently held, 0 otherwise.
QueryModalOpen
Returns whether a modal dialog is currently visible.
1 if a modal spawned with SpawnModal is active, 0 otherwise. While a modal is open, EventAttachKey and EventAttachClick callbacks are suppressed, and most element interactions are disabled. Use this function to pause game logic or animations while the user interacts with a dialog.
Returns: 1 if a modal is open, 0 if not.
QueryScroll
Returns the current vertical scroll offset of the virtual canvas.
ReserveScroll. The offset is in pixels, where 0 means the top of the virtual canvas is aligned with the window’s top edge. The maximum value is virtual_canvas_height − window_height.
Returns: Current scroll offset in pixels. Always 0 if scroll mode is not active.
GetElapsedTime
Returns the total time elapsed since MainWindowLoop was first called.
double. Starts at 0.0 when MainWindowLoop begins.