simvx.graphics.input_adapter¶
Desktop windowing shim: GLFW/SDL3 events to :class:InputRouter.
Backend-agnostic: GLFW and SDL3 deliver the same integer key codes, the same action constants, and the same modifier bit positions, so one shim serves both.
Everything this module does is translation – action ints to pressed/echo
booleans, a mods bitfield to four flags, the platform’s button ordering to
- class:
MouseButton. What an event means to the engine lives in- mod:
simvx.core.input.router, shared with the browser runtime.
Module Contents¶
Functions¶
Install the router these callbacks feed (called by FrameLoop.on_setup). |
|
Process a key event. |
|
Process a mouse button event. |
|
Process a cursor position event. |
|
Process a scroll event. |
|
Process a character input event (typed characters). |
|
Process a touch event. |
|
Poll gamepads via the window backend and publish one frame of state. |
Data¶
API¶
- simvx.graphics.input_adapter.log¶
‘getLogger(…)’
- simvx.graphics.input_adapter.set_router(router: simvx.core.input.InputRouter | None) None¶
Install the router these callbacks feed (called by FrameLoop.on_setup).
- simvx.graphics.input_adapter.key_callback(key: int, action: int, mods: int) None¶
Process a key event.
Args: key: Platform key code (integer, shared by GLFW/SDL3). action: _PRESS (1), _RELEASE (0), or _REPEAT (2). mods: Modifier bits (shift, ctrl, alt, super).
- simvx.graphics.input_adapter.mouse_button_callback(button: int, action: int, mods: int) None¶
Process a mouse button event.
Args: button: Platform button index (0=left, 1=right, 2=middle). action: _PRESS (1) or _RELEASE (0). mods: Modifier bits.
- simvx.graphics.input_adapter.cursor_pos_callback(x: float, y: float) None¶
Process a cursor position event.
Coordinates arrive in logical (screen) pixels, not physical framebuffer pixels. On HiDPI displays the framebuffer may be larger, but cursor coordinates and
tree.screen_sizeshare logical units, so the input layer needs no DPI scaling.
- simvx.graphics.input_adapter.scroll_callback(x_offset: float, y_offset: float) None¶
Process a scroll event.
- simvx.graphics.input_adapter.char_callback(codepoint: int) None¶
Process a character input event (typed characters).
- simvx.graphics.input_adapter.touch_callback(finger_id: int, action: int, x: float, y: float, pressure: float) None¶
Process a touch event.
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¶
Poll gamepads via the window backend and publish one frame of state.
The poll is a transaction, not an add-only write: a pad the backend stops reporting is dropped, so unplugging a controller releases its held buttons instead of leaving them pressed for the rest of the run. A backend that declares no gamepad support opens no transaction at all, because “I cannot see pads” must not be published as “every pad has gone”.
State goes to the tree the installed router serves, so a poll under an isolated tree lands in that tree rather than in the process-wide default.
- simvx.graphics.input_adapter.__all__¶
[‘set_router’, ‘key_callback’, ‘mouse_button_callback’, ‘cursor_pos_callback’, ‘scroll_callback’, ‘c…