simvx.core.input.state¶
Input — singleton for querying current input state.
Module Contents¶
Classes¶
Static input manager. Tracks keyboard, mouse, and gamepad state. |
API¶
- class simvx.core.input.state.Input[source]¶
Static input manager. Tracks keyboard, mouse, and gamepad state.
Actions are registered via InputMap; query with is_action_pressed() etc. Direct key/button queries use is_key_pressed(Key.X) / is_mouse_button_pressed(MouseButton.LEFT).
- classmethod is_action_pressed(action: str) bool[source]¶
Check if any input mapped to the action is currently held.
- classmethod is_action_just_pressed(action: str) bool[source]¶
Check if any input mapped to the action was pressed this frame.
- classmethod is_action_just_released(action: str) bool[source]¶
Check if any input mapped to the action was released this frame.
- classmethod get_action_strength(action: str) float[source]¶
Return action strength: 1.0 for digital press, analog value for axes.
- get_strength¶
None
- classmethod get_axis(negative_action: str, positive_action: str) float[source]¶
Return axis value from two opposing actions. Range [-1, 1].
- classmethod get_vector(neg_x: str, pos_x: str, neg_y: str, pos_y: str) simvx.core.math.types.Vec2[source]¶
Return a normalized 2D direction vector from four input actions.
Handles diagonal normalization so magnitude never exceeds 1.0.
- classmethod is_key_pressed(key: simvx.core.input.enums.Key) bool[source]¶
Check if a specific key is currently held down.
- classmethod is_key_just_pressed(key: simvx.core.input.enums.Key) bool[source]¶
Check if a specific key was pressed this frame (not held from previous).
- classmethod is_key_just_released(key: simvx.core.input.enums.Key) bool[source]¶
Check if a specific key was released this frame.
- classmethod is_mouse_button_pressed(button: simvx.core.input.enums.MouseButton) bool[source]¶
Check if a mouse button is currently held.
- classmethod is_mouse_button_just_pressed(button: simvx.core.input.enums.MouseButton) bool[source]¶
Check if a mouse button was pressed this frame.
- classmethod is_mouse_button_just_released(button: simvx.core.input.enums.MouseButton) bool[source]¶
Check if a mouse button was released this frame.
- classmethod get_mouse_position() simvx.core.math.types.Vec2[source]¶
Get current mouse position in screen coordinates.
- classmethod get_mouse_delta() simvx.core.math.types.Vec2[source]¶
Get mouse movement delta this frame.
- classmethod get_scroll_delta() tuple[float, float][source]¶
Get scroll wheel delta this frame (x, y).
- classmethod set_touch_emulation(enabled: bool = True)[source]¶
Enable mouse-to-touch emulation (useful for testing touch on desktop).
When enabled, left mouse button presses/releases and mouse moves also generate touch events with finger_id=0. This lets GestureRecognizer and other touch-consuming code work with a mouse.
- classmethod set_mouse_capture_mode(mode: simvx.core.input.enums.MouseCaptureMode)[source]¶
Set mouse cursor capture mode. Platform adapter applies the change.
- classmethod get_mouse_capture_mode() simvx.core.input.enums.MouseCaptureMode[source]¶
Get the current mouse capture mode.
- classmethod get_gamepad_axis(pad_id: int = 0, axis: str | simvx.core.input.enums.JoyAxis = 'left_x') float[source]¶
Get gamepad axis value [-1, 1].
Accepts either a string name (legacy) or JoyAxis enum.
- classmethod is_gamepad_pressed(pad_id: int = 0, button: str | simvx.core.input.enums.JoyButton = 'a') bool[source]¶
Check if gamepad button is pressed.
Accepts either a string name (legacy) or JoyButton enum.
- classmethod get_gamepad_vector(pad_id: int = 0, stick: str = 'left') simvx.core.math.types.Vec2[source]¶
Get stick as Vec2 with deadzone applied.
- classmethod inject_key(key: int | simvx.core.input.enums.Key, pressed: bool) None[source]¶
Inject a synthetic key event. Same path as platform adapters.
- classmethod inject_mouse_button(button: int | simvx.core.input.enums.MouseButton, pressed: bool) None[source]¶
Inject a synthetic mouse button event. Same path as platform adapters.
- classmethod get_touches() dict[int, tuple[float, float, float]][source]¶
Return dict of active touches: {finger_id: (x, y, pressure)}.
- classmethod get_touches_just_pressed() dict[int, tuple[float, float, float]][source]¶
Return touches that started this frame.
- classmethod get_touches_just_released() set[int][source]¶
Return finger IDs that were lifted this frame.