The events API lets you attach callbacks for user input and query the real-time state of the mouse and keyboard. Callbacks are registered once before the render loop and are invoked automatically byDocumentation 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.
GHandleWindowEvents as matching X11 events arrive. Query functions (GQueryMouse, GQueryKeyboard, GQueryKeyDown) can be called at any time — including inside GSimpleWindowLoop’s on_every callback — to poll current device state.
GEventAttachKey
Callback function.
key is the ASCII code for printable characters, or one of the LWXGL key constants for non-printable keys (see below). A value of 0 is never delivered.LWXGL_KEY_FN + n where n is the function-key number (1–12). For example, F1 produces code 151 and F12 produces 162.
F12 is reserved. Pressing F12 toggles the built-in debug performance overlay and is never forwarded to the
Key callback. Ctrl+Escape is also reserved and triggers GDeleteWindow.GEventAttachClick
Callback function.
x and y are the window-relative pixel coordinates of the cursor at the time of release. btn is the X button number: 1 = left, 2 = middle, 3 = right.GEventAttachDelete
WM_DELETE_WINDOW client message). The return value of the callback controls whether the close is allowed.
Callback function. Return
1 to allow the window to close (sets the closing flag). Return 0 to block the close — the window remains open and the render loop continues.GEnableResizing
Callback function.
w and h are the new window dimensions in pixels.GQueryMouse
on_every callback of GSimpleWindowLoop.
Receives the cursor’s current X position in window-relative pixels. Set to
-1 when the cursor is outside the window.Receives the cursor’s current Y position in window-relative pixels. Set to
-1 when the cursor is outside the window.Receives the currently pressed button number (
1=left, 2=middle, 3=right), or 0 if no button is pressed. Only one button is tracked at a time; the first button pressed takes precedence until it is released.GQueryKeyboard
pressed_keys array. Each slot holds the character code of a currently held key, or 0 if that slot is empty. LWXGL tracks up to 8 simultaneous key presses. Character codes use the same values delivered to the GEventAttachKey callback, including the LWXGL key constants for arrow and function keys.
The returned pointer is valid for the lifetime of the window. Do not free it.
GQueryKeyDown
1 if the key with character code ch is currently held down, 0 otherwise. Equivalent to scanning the full GQueryKeyboard array for ch, but more convenient for checking individual keys.
Character code to test. Use ASCII values for printable characters or the LWXGL key constants for arrows and function keys.