mini_arcade_core.scenes.systems.builtins.actions¶
Action-map based input bindings for scene systems.
Attributes¶
Classes¶
Normalized per-action state. |
|
Per-frame snapshot for all mapped actions. |
|
Strategy contract for one logical action binding. |
|
Digital action sourced from keyboard and/or named buttons. |
|
Axis action sourced from analog axes and optional digital fallbacks. |
|
Mapping of action IDs to concrete binding strategies. |
|
Input system that converts an ActionMap snapshot into scene intent. |
|
Action-intent system configured directly from gameplay.controls settings. |
Functions¶
|
Build an ActionMap from YAML-friendly binding dictionaries. |
|
Resolve one scene ActionMap from gameplay.controls config. |
Module Contents¶
- mini_arcade_core.scenes.systems.builtins.actions.BaseIntent¶
- mini_arcade_core.scenes.systems.builtins.actions.TContext¶
- mini_arcade_core.scenes.systems.builtins.actions.TIntent¶
- class mini_arcade_core.scenes.systems.builtins.actions.ActionState[source]¶
Normalized per-action state.
- value: float = 0.0¶
- down: bool = False¶
- pressed: bool = False¶
- released: bool = False¶
- class mini_arcade_core.scenes.systems.builtins.actions.ActionSnapshot[source]¶
Per-frame snapshot for all mapped actions.
- state(action: str) ActionState[source]¶
Get the ActionState for the given action, or a default if not found.
- Parameters:
action (str) – The name of the action to get the state for.
- Returns:
The ActionState for the given action, or a default if not found.
- Return type:
- value(action: str, default: float = 0.0) float[source]¶
Get the normalized value of the action, or a default if not found.
- Parameters:
action (str) – The name of the action to get the value for.
default (float) – The default value to return if the action is not found (default 0.0).
- Returns:
The normalized value of the action, or the default if not found.
- Return type:
float
- down(action: str) bool[source]¶
Check if the action is currently held down.
- Parameters:
action (str) – The name of the action to check.
- Returns:
True if the action is currently held down, False otherwise.
- Return type:
bool
- class mini_arcade_core.scenes.systems.builtins.actions.ActionBinding[source]¶
Bases:
ProtocolStrategy contract for one logical action binding.
- read(frame: mini_arcade_core.runtime.input_frame.InputFrame) ActionState[source]¶
Read the current state of this action from the input frame.
- Parameters:
frame (InputFrame) – The input frame containing raw input states.
- Returns:
The current ActionState for this binding.
- Return type:
- class mini_arcade_core.scenes.systems.builtins.actions.DigitalActionBinding[source]¶
Bases:
ActionBindingDigital action sourced from keyboard and/or named buttons.
- keys: tuple[mini_arcade_core.backend.keys.Key, Ellipsis] = ()¶
- buttons: tuple[str, Ellipsis] = ()¶
- read(frame: mini_arcade_core.runtime.input_frame.InputFrame) ActionState[source]¶
Read the current state of this action from the input frame.
- Parameters:
frame (InputFrame) – The input frame containing raw input states.
- Returns:
The current ActionState for this binding.
- Return type:
- class mini_arcade_core.scenes.systems.builtins.actions.AxisActionBinding[source]¶
Bases:
ActionBindingAxis action sourced from analog axes and optional digital fallbacks.
- axes: tuple[str, Ellipsis] = ()¶
- positive_keys: tuple[mini_arcade_core.backend.keys.Key, Ellipsis] = ()¶
- negative_keys: tuple[mini_arcade_core.backend.keys.Key, Ellipsis] = ()¶
- positive_buttons: tuple[str, Ellipsis] = ()¶
- negative_buttons: tuple[str, Ellipsis] = ()¶
- deadzone: float = 0.15¶
- scale: float = 1.0¶
- read(frame: mini_arcade_core.runtime.input_frame.InputFrame) ActionState[source]¶
Read the current state of this action from the input frame.
- Parameters:
frame (InputFrame) – The input frame containing raw input states.
- Returns:
The current ActionState for this binding.
- Return type:
- class mini_arcade_core.scenes.systems.builtins.actions.ActionMap[source]¶
Mapping of action IDs to concrete binding strategies.
- bindings: Mapping[str, ActionBinding]¶
- read(frame: mini_arcade_core.runtime.input_frame.InputFrame) ActionSnapshot[source]¶
Read the current state of all actions from the input frame.
- Parameters:
frame (InputFrame) – The input frame containing raw input states.
- Returns:
An ActionSnapshot containing the state of all actions.
- Return type:
- mini_arcade_core.scenes.systems.builtins.actions.action_map_from_bindings_config(bindings: Mapping[str, Any] | None) ActionMap[source]¶
Build an ActionMap from YAML-friendly binding dictionaries.
Supported entry formats per action: - digital:
type: digital keys: [ESCAPE] buttons: [pad_start]
- axis:
type: axis axes: [left_y] positive_keys: [S] negative_keys: [W] positive_buttons: [pad_down] negative_buttons: [pad_up] deadzone: 0.15 scale: 1.0
- mini_arcade_core.scenes.systems.builtins.actions.action_map_from_controls_config(controls_cfg: Mapping[str, Any] | None, *, scene_key: str, default_action_map: ActionMap) ActionMap[source]¶
Resolve one scene ActionMap from gameplay.controls config.
- Expected layout:
- gameplay:
- controls:
- <scene_key>:
bindings: {…}
- class mini_arcade_core.scenes.systems.builtins.actions.ActionIntentSystem[source]¶
Bases:
mini_arcade_core.scenes.systems.base_system.BaseSystem[TContext],Generic[TContext,TIntent]Input system that converts an ActionMap snapshot into scene intent.
- intent_factory: Callable[[ActionSnapshot, TContext], TIntent]¶
- name: str = 'action_intent'¶
- phase: int¶
- order: int = 10¶
- channel: str | None = None¶
- write_to_ctx_intent: bool = True¶
- step(ctx: TContext) None[source]¶
Perform a single step of the system within the given context.
- Parameters:
ctx (TSystemContext) – The system context.
- class mini_arcade_core.scenes.systems.builtins.actions.ConfiguredActionIntentSystem(*, controls: Mapping[str, Any] | None, scene_key: str, intent_factory: Callable[[ActionSnapshot, TContext], TIntent], fallback_bindings: Mapping[str, Any] | None = None, name: str = 'action_intent', phase: int = SystemPhase.INPUT, order: int = 10, channel: str | None = None, write_to_ctx_intent: bool = True)[source]¶
Bases:
ActionIntentSystem[TContext,TIntent],Generic[TContext,TIntent]Action-intent system configured directly from gameplay.controls settings.