mini_arcade_core.scenes.systems.builtins.actions

Action-map based input bindings for scene systems.

Attributes

Classes

ActionState

Normalized per-action state.

ActionSnapshot

Per-frame snapshot for all mapped actions.

ActionBinding

Strategy contract for one logical action binding.

DigitalActionBinding

Digital action sourced from keyboard and/or named buttons.

AxisActionBinding

Axis action sourced from analog axes and optional digital fallbacks.

ActionMap

Mapping of action IDs to concrete binding strategies.

ActionIntentSystem

Input system that converts an ActionMap snapshot into scene intent.

ConfiguredActionIntentSystem

Action-intent system configured directly from gameplay.controls settings.

Functions

action_map_from_bindings_config(→ ActionMap)

Build an ActionMap from YAML-friendly binding dictionaries.

action_map_from_controls_config(→ ActionMap)

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:

ActionState

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

pressed(action: str) bool[source]

Check if the action was pressed this frame.

Parameters:

action (str) – The name of the action to check.

Returns:

True if the action was pressed this frame, False otherwise.

Return type:

bool

released(action: str) bool[source]

Check if the action was released this frame.

Parameters:

action (str) – The name of the action to check.

Returns:

True if the action was released this frame, False otherwise.

Return type:

bool

class mini_arcade_core.scenes.systems.builtins.actions.ActionBinding[source]

Bases: Protocol

Strategy 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:

ActionState

class mini_arcade_core.scenes.systems.builtins.actions.DigitalActionBinding[source]

Bases: ActionBinding

Digital 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:

ActionState

class mini_arcade_core.scenes.systems.builtins.actions.AxisActionBinding[source]

Bases: ActionBinding

Axis 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:

ActionState

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:

ActionSnapshot

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.

action_map: ActionMap
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.