simvx.core.input.events

Input binding and event types.

Module Contents

Classes

InputBinding

A single input binding: maps to a key, mouse button, or gamepad input.

InputEventKey

Keyboard input event with rich metadata.

InputEventMouse

Mouse button input event.

Functions

key_combo_to_binding

Parse a combo such as "shift+tab" into a binding; None when spec is not one.

Data

API

simvx.core.input.events.MODIFIER_NAMES

(‘ctrl’, ‘shift’, ‘alt’)

class simvx.core.input.events.InputBinding[source]

A single input binding: maps to a key, mouse button, or gamepad input.

ctrl / shift / alt are REQUIRED modifiers, not exclusive ones: a binding that sets shift=True only matches while Shift is held, while a binding that leaves them all False matches whatever else is held. That keeps every unmodified binding behaving as it always has (a jump bound to Space still fires while the player holds Shift to run).

Key routing that has to tell one combo from another – the UI navigation actions, which must distinguish Tab from Shift+Tab – compares

Attr:

key_combo against the combo the router built for the event, so there the match is exact.

key: simvx.core.input.enums.Key | None

None

mouse_button: simvx.core.input.enums.MouseButton | None

None

joy_button: simvx.core.input.enums.JoyButton | None

None

joy_axis: simvx.core.input.enums.JoyAxis | None

None

joy_axis_positive: bool

True

deadzone: float

0.2

ctrl: bool

False

shift: bool

False

alt: bool

False

property key_combo: str | None[source]

The combo spelling of a key binding ("shift+tab"), or None if not a key.

Modifier order is ctrl, shift, alt, matching the combo string the UI router builds from the live modifier state.

simvx.core.input.events.key_combo_to_binding(spec: str) simvx.core.input.events.InputBinding | None[source]

Parse a combo such as "shift+tab" into a binding; None when spec is not one.

The inverse of :attr:InputBinding.key_combo, and the one place that spelling is understood: the input map, the project file and anything else that accepts a written binding all resolve combos through here, so a combo that an InputMap accepts is also one a simvx.toml can carry.

A bare key name is not a combo (there is nothing before the +) and returns None, leaving it to the caller’s own key lookup.

class simvx.core.input.events.InputEventKey(key: simvx.core.input.enums.Key, pressed: bool, echo: bool = False, shift: bool = False, ctrl: bool = False, alt: bool = False, meta: bool = False)[source]

Keyboard input event with rich metadata.

Initialization

__slots__

(‘key’, ‘pressed’, ‘echo’, ‘shift’, ‘ctrl’, ‘alt’, ‘meta’, ‘handled’)

__repr__() str[source]
class simvx.core.input.events.InputEventMouse(button: simvx.core.input.enums.MouseButton, pressed: bool, position: tuple[float, float] = (0.0, 0.0), shift: bool = False, ctrl: bool = False, alt: bool = False, meta: bool = False)[source]

Mouse button input event.

Initialization

__slots__

(‘button’, ‘pressed’, ‘position’, ‘shift’, ‘ctrl’, ‘alt’, ‘meta’, ‘handled’)

__repr__() str[source]