simvx.core.input¶
Input Action Map system for SimVX.
Provides type-safe key enumerations, input bindings, an action map, and rich input events. The Input singleton tracks keyboard, mouse, and gamepad state and resolves named actions to physical inputs via InputMap.
Actions are registered through InputMap.add_action() with typed Key/MouseButton/JoyButton bindings. Direct key/button state is queried through Input.is_key_pressed(Key.X) etc.
Module Contents¶
Classes¶
Keyboard key codes (matching GLFW key values). |
|
Mouse button codes (matching GLFW). |
|
Gamepad button codes (matching GLFW/SDL standard gamepad). |
|
Gamepad axis codes. |
|
Mouse cursor capture modes. |
|
A single input binding — maps to a key, mouse button, or gamepad input. |
|
Keyboard input event with rich metadata. |
|
Mouse button input event. |
|
Maps action names to physical inputs. Class-level singleton. |
|
Static input manager. Tracks keyboard, mouse, and gamepad state. |
Functions¶
Convert a Key enum to its string name. |
|
Convert a string key name to matching Key enum values. |
Data¶
API¶
- simvx.core.input.log¶
‘getLogger(…)’
- class simvx.core.input.Key¶
Bases:
enum.IntEnumKeyboard key codes (matching GLFW key values).
Initialization
Initialize self. See help(type(self)) for accurate signature.
- SPACE¶
32
- APOSTROPHE¶
39
- COMMA¶
44
- MINUS¶
45
- PERIOD¶
46
- SLASH¶
47
- KEY_0¶
48
- KEY_1¶
49
- KEY_2¶
50
- KEY_3¶
51
- KEY_4¶
52
- KEY_5¶
53
- KEY_6¶
54
- KEY_7¶
55
- KEY_8¶
56
- KEY_9¶
57
- SEMICOLON¶
59
- EQUAL¶
61
- A¶
65
- B¶
66
- C¶
67
- D¶
68
- E¶
69
- F¶
70
- G¶
71
- H¶
72
- I¶
73
- J¶
74
- K¶
75
- L¶
76
- M¶
77
- N¶
78
- O¶
79
- P¶
80
- Q¶
81
- R¶
82
- S¶
83
- T¶
84
- U¶
85
- V¶
86
- W¶
87
- X¶
88
- Y¶
89
- Z¶
90
- LEFT_BRACKET¶
91
- BACKSLASH¶
92
- RIGHT_BRACKET¶
93
- GRAVE_ACCENT¶
96
- ESCAPE¶
256
- ENTER¶
257
- TAB¶
258
- BACKSPACE¶
259
- INSERT¶
260
- DELETE¶
261
- RIGHT¶
262
- LEFT¶
263
- DOWN¶
264
- UP¶
265
- PAGE_UP¶
266
- PAGE_DOWN¶
267
- HOME¶
268
- END¶
269
- CAPS_LOCK¶
280
- SCROLL_LOCK¶
281
- NUM_LOCK¶
282
- PRINT_SCREEN¶
283
- PAUSE¶
284
- F1¶
290
- F2¶
291
- F3¶
292
- F4¶
293
- F5¶
294
- F6¶
295
- F7¶
296
- F8¶
297
- F9¶
298
- F10¶
299
- F11¶
300
- F12¶
301
- KP_0¶
320
- KP_1¶
321
- KP_2¶
322
- KP_3¶
323
- KP_4¶
324
- KP_5¶
325
- KP_6¶
326
- KP_7¶
327
- KP_8¶
328
- KP_9¶
329
- KP_DECIMAL¶
330
- KP_DIVIDE¶
331
- KP_MULTIPLY¶
332
- KP_SUBTRACT¶
333
- KP_ADD¶
334
- KP_ENTER¶
335
- LEFT_SHIFT¶
340
- LEFT_CONTROL¶
341
- LEFT_ALT¶
342
- LEFT_SUPER¶
343
- RIGHT_SHIFT¶
344
- RIGHT_CONTROL¶
345
- RIGHT_ALT¶
346
- RIGHT_SUPER¶
347
- MENU¶
348
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- class simvx.core.input.MouseButton¶
Bases:
enum.IntEnumMouse button codes (matching GLFW).
Initialization
Initialize self. See help(type(self)) for accurate signature.
- LEFT¶
0
- RIGHT¶
1
- MIDDLE¶
2
- BUTTON_4¶
3
- BUTTON_5¶
4
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- class simvx.core.input.JoyButton¶
Bases:
enum.IntEnumGamepad button codes (matching GLFW/SDL standard gamepad).
Initialization
Initialize self. See help(type(self)) for accurate signature.
- A¶
0
- B¶
1
- X¶
2
- Y¶
3
- LEFT_BUMPER¶
4
- RIGHT_BUMPER¶
5
- BACK¶
6
- START¶
7
- GUIDE¶
8
- LEFT_THUMB¶
9
- RIGHT_THUMB¶
10
- DPAD_UP¶
11
- DPAD_RIGHT¶
12
- DPAD_DOWN¶
13
- DPAD_LEFT¶
14
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- class simvx.core.input.JoyAxis¶
Bases:
enum.IntEnumGamepad axis codes.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- LEFT_X¶
0
- LEFT_Y¶
1
- RIGHT_X¶
2
- RIGHT_Y¶
3
- LEFT_TRIGGER¶
4
- RIGHT_TRIGGER¶
5
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- class simvx.core.input.MouseCaptureMode¶
Bases:
enum.IntEnumMouse cursor capture modes.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- VISIBLE¶
0
- HIDDEN¶
1
- CAPTURED¶
2
- CONFINED¶
3
- __abs__()¶
- __add__()¶
- __and__()¶
- __bool__()¶
- __ceil__()¶
- __delattr__()¶
- __dir__()¶
- __divmod__()¶
- __eq__()¶
- __float__()¶
- __floor__()¶
- __floordiv__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getnewargs__()¶
- __getstate__()¶
- __gt__()¶
- __hash__()¶
- __index__()¶
- __int__()¶
- __invert__()¶
- __le__()¶
- __lshift__()¶
- __lt__()¶
- __mod__()¶
- __mul__()¶
- __ne__()¶
- __neg__()¶
- __new__()¶
- __or__()¶
- __pos__()¶
- __pow__()¶
- __radd__()¶
- __rand__()¶
- __rdivmod__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __rfloordiv__()¶
- __rlshift__()¶
- __rmod__()¶
- __rmul__()¶
- __ror__()¶
- __round__()¶
- __rpow__()¶
- __rrshift__()¶
- __rshift__()¶
- __rsub__()¶
- __rtruediv__()¶
- __rxor__()¶
- __setattr__()¶
- __sizeof__()¶
- __str__()¶
- __sub__()¶
- __subclasshook__()¶
- __truediv__()¶
- __trunc__()¶
- __xor__()¶
- as_integer_ratio()¶
- bit_count()¶
- bit_length()¶
- conjugate()¶
- class denominator¶
- class imag¶
- is_integer()¶
- class numerator¶
- class real¶
- to_bytes()¶
- __deepcopy__(memo)¶
- __copy__()¶
- name()¶
- value()¶
- simvx.core.input.key_to_name(key: simvx.core.input.Key) str¶
Convert a Key enum to its string name.
- simvx.core.input.name_to_keys(name: str) list[simvx.core.input.Key]¶
Convert a string key name to matching Key enum values.
- class simvx.core.input.InputBinding¶
A single input binding — maps to a key, mouse button, or gamepad input.
- key: simvx.core.input.Key | None¶
None
- mouse_button: simvx.core.input.MouseButton | None¶
None
- joy_button: simvx.core.input.JoyButton | None¶
None
- joy_axis: simvx.core.input.JoyAxis | None¶
None
- joy_axis_positive: bool¶
True
- deadzone: float¶
0.2
- class simvx.core.input.InputEventKey(key: simvx.core.input.Key, pressed: bool, echo: bool = False, shift: bool = False, ctrl: bool = False, alt: bool = False)¶
Keyboard input event with rich metadata.
Initialization
- __slots__¶
(‘key’, ‘pressed’, ‘echo’, ‘shift’, ‘ctrl’, ‘alt’, ‘handled’)
- __repr__() str¶
- class simvx.core.input.InputEventMouse(button: simvx.core.input.MouseButton, pressed: bool, position: tuple[float, float] = (0.0, 0.0), shift: bool = False, ctrl: bool = False, alt: bool = False)¶
Mouse button input event.
Initialization
- __slots__¶
(‘button’, ‘pressed’, ‘position’, ‘shift’, ‘ctrl’, ‘alt’, ‘handled’)
- __repr__() str¶
- class simvx.core.input.InputMap¶
Maps action names to physical inputs. Class-level singleton.
- classmethod add_action(name: str, bindings: list[simvx.core.input.InputBinding | simvx.core.input.Key | simvx.core.input.MouseButton | simvx.core.input.JoyButton] | None = None)¶
Register a named action with optional initial bindings.
Convenience: passing bare Key/MouseButton/JoyButton values auto-wraps them.
- classmethod remove_action(name: str)¶
Remove a named action and all its bindings.
- classmethod add_binding(name: str, binding: simvx.core.input.InputBinding | simvx.core.input.Key | simvx.core.input.MouseButton | simvx.core.input.JoyButton)¶
Add a binding to an existing action. Creates the action if it does not exist.
- classmethod remove_binding(name: str, binding: simvx.core.input.InputBinding)¶
Remove a specific binding from an action.
- classmethod get_bindings(name: str) list[simvx.core.input.InputBinding]¶
Return bindings for an action (empty list if unknown).
- classmethod has_action(name: str) bool¶
Check if an action is registered.
- classmethod get_actions() list[str]¶
Return all registered action names.
- classmethod clear()¶
Remove all actions and bindings.
- class simvx.core.input.Input¶
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¶
Check if any input mapped to the action is currently held.
- classmethod is_action_just_pressed(action: str) bool¶
Check if any input mapped to the action was pressed this frame.
- classmethod is_action_just_released(action: str) bool¶
Check if any input mapped to the action was released this frame.
- classmethod get_action_strength(action: str) float¶
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¶
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¶
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.Key) bool¶
Check if a specific key is currently held down.
- classmethod is_key_just_pressed(key: simvx.core.input.Key) bool¶
Check if a specific key was pressed this frame (not held from previous).
- classmethod is_key_just_released(key: simvx.core.input.Key) bool¶
Check if a specific key was released this frame.
- classmethod is_mouse_button_pressed(button: simvx.core.input.MouseButton) bool¶
Check if a mouse button is currently held.
- classmethod is_mouse_button_just_pressed(button: simvx.core.input.MouseButton) bool¶
Check if a mouse button was pressed this frame.
- classmethod is_mouse_button_just_released(button: simvx.core.input.MouseButton) bool¶
Check if a mouse button was released this frame.
- classmethod get_mouse_position() simvx.core.math.types.Vec2¶
Get current mouse position in screen coordinates.
- classmethod get_mouse_delta() simvx.core.math.types.Vec2¶
Get mouse movement delta this frame.
- classmethod get_scroll_delta() tuple[float, float]¶
Get scroll wheel delta this frame (x, y).
- classmethod set_mouse_capture_mode(mode: simvx.core.input.MouseCaptureMode)¶
Set mouse cursor capture mode. Platform adapter applies the change.
- classmethod get_mouse_capture_mode() simvx.core.input.MouseCaptureMode¶
Get the current mouse capture mode.
- classmethod get_gamepad_axis(pad_id: int = 0, axis: str | simvx.core.input.JoyAxis = 'left_x') float¶
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.JoyButton = 'a') bool¶
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¶
Get stick as Vec2 with deadzone applied.
- classmethod get_touches() dict[int, tuple[float, float, float]]¶
Return dict of active touches: {finger_id: (x, y, pressure)}.
- classmethod get_touches_just_pressed() dict[int, tuple[float, float, float]]¶
Return touches that started this frame.
- classmethod get_touches_just_released() set[int]¶
Return finger IDs that were lifted this frame.