ui-glfw
Garnet UI GLFW
Create Garnet::UI::GLFWInput.new(window, router) after opening a GLFW window. Poll events on the host owner, and call router.present after presenting the corresponding UI frame. The adapter handles cursor, click, wheel, focus, tab navigation and committed text. Call close before destroying the window to detach its callbacks.
Focused text fields accept platform clipboard and undo shortcuts. Use Command or Control with A, C, X, V and Z. Shift-Z or Control-Y redoes an edit. GLFW forwards committed characters. The router also accepts preedit from native host adapters that supply it.
Pass on_unhandled_key: to route unclaimed keys to application code without replacing the GLFW key callback. Text focus and presented modals reserve unclaimed presses for the UI. Each forwarded press receives a release, including on window blur or adapter close. Applications with polled controls can check router.captures_keyboard? before applying keyboard movement.
Call poll_gamepad(joystick) once per frame for the controller selected by the application. D-pad presses move spatial focus and the primary button activates the focused element. No polling runs inside the native callbacks.
When the application already polls controllers, pass its selected normalized pad to input.route_gamepad(pad). This accepts the same device instance gameplay reads. A handled navigation, activation, or escape press stays claimed until release. Outside GLFW, require garnet-ui/gamepad and call router.route_gamepad(pad) directly.
For keyboard gameplay bindings, pass actions: and optionally keyboard_device: to the constructor. Bind keys with their GLFW enum value. Unclaimed transitions and synthesized releases go to that action map. Pass on_blur: -> { pads.blur } when the application owns a pad registry.
Sharing input with gameplay
This adapter owns the window's input callbacks, so don't install your own on_key beside it. Pass devices: Garnet::Input::Devices and unclaimed key transitions (plus synthesized releases on blur or close) and focus changes reach that Devices as neutral Input::Keys for gameplay. New applications should use Garnet::App::Desktop with the UI plugin (garnet-ui/plugin) instead: the host feeds Input::Devices once and the UI claims input first through Devices#intercept.
ui-glfw
- 0
- 0
- 0
- 2
- 3
- 1 day ago
- November 30, 2026
MIT License
Wed, 02 Dec 2026 02:09:06 GMT