simvx.graphics.input_adapter

Adapter to bridge platform input events to simvx.core.Input singleton.

Backend-agnostic — works with GLFW, SDL3, or any backend that delivers the same integer key codes and action constants.

Module Contents

Functions

key_callback

Process key event and update Input state.

mouse_button_callback

Process mouse button event.

set_ui_callbacks

Install UI routing callbacks (called by App._run_with_tree).

clear_ui_callbacks

Reset all UI routing callbacks to None.

reset_primary_finger

Reset primary finger tracking (call on scene change).

cursor_pos_callback

Process cursor position event and update Input state.

scroll_callback

Process scroll event and update Input state.

char_callback

Process character input event (typed characters).

key_callback_with_ui

Key callback that also routes key events to UI.

mouse_button_callback_with_ui

Mouse callback that also routes clicks to UI.

touch_callback

Process touch event — updates Input state AND routes primary finger through UI.

poll_gamepads

Poll gamepads via the window backend and update Input state.

Data

API

simvx.graphics.input_adapter.log[source]

‘getLogger(…)’

simvx.graphics.input_adapter.key_callback(key: int, action: int, mods: int) None[source]

Process key event and update Input state.

Args: key: Platform key code (integer, shared by GLFW/SDL3). action: _PRESS (1), _RELEASE (0), or _REPEAT (2). mods: Modifier bits (shift, ctrl, alt, etc.)

simvx.graphics.input_adapter.mouse_button_callback(button: int, action: int, mods: int) None[source]

Process mouse button event.

Args: button: Mouse button index (0=left, 1=right, 2=middle). action: _PRESS (1) or _RELEASE (0). mods: Modifier bits.

simvx.graphics.input_adapter.set_ui_callbacks(*, char=None, key=None, mouse=None, motion=None, scroll=None, touch=None)[source]

Install UI routing callbacks (called by App._run_with_tree).

simvx.graphics.input_adapter.clear_ui_callbacks()[source]

Reset all UI routing callbacks to None.

simvx.graphics.input_adapter.reset_primary_finger()[source]

Reset primary finger tracking (call on scene change).

simvx.graphics.input_adapter.cursor_pos_callback(x: float, y: float) None[source]

Process cursor position event and update Input state.

simvx.graphics.input_adapter.scroll_callback(x_offset: float, y_offset: float) None[source]

Process scroll event and update Input state.

simvx.graphics.input_adapter.char_callback(codepoint: int) None[source]

Process character input event (typed characters).

simvx.graphics.input_adapter.key_callback_with_ui(key: int, action: int, mods: int) None[source]

Key callback that also routes key events to UI.

simvx.graphics.input_adapter.mouse_button_callback_with_ui(button: int, action: int, mods: int) None[source]

Mouse callback that also routes clicks to UI.

simvx.graphics.input_adapter.touch_callback(finger_id: int, action: int, x: float, y: float, pressure: float) None[source]

Process touch event — updates Input state AND routes primary finger through UI.

The primary finger (first finger to touch down) is emulated as mouse input so all existing UI widgets work with touch out of the box. Multi-touch data still flows through Input._touches for game code and GestureRecognizer.

Args: finger_id: Unique finger identifier. action: 0=down, 1=up, 2=move. x, y: Position in window pixel coordinates. pressure: Touch pressure 0.0-1.0.

simvx.graphics.input_adapter.poll_gamepads(window_backend: Any) None[source]

Poll gamepads via the window backend and update Input state.

simvx.graphics.input_adapter.__all__

[‘key_callback’, ‘mouse_button_callback’, ‘cursor_pos_callback’, ‘scroll_callback’, ‘char_callback’,…