Expand description
SPDX-License-Identifier: MIT OR Apache-2.0
A flexible and ergonomic input action system for Bevy.
This library provides a structured way to handle input actions in Bevy, allowing you to define abstract input actions that can be mapped from various input sources (keyboard, mouse, gamepad, etc.) and consumed by game systems in a consistent way.
§Features
- Input Action Abstraction: Define abstract input actions separate from concrete inputs
- State Management: Track whether actions are active/idle and their current values
- Event-like System: React to action starts, updates, and stops
- Multi-source Input: Combine inputs from multiple sources into a single action state
- Conditional Systems: Feature-gated helpers for common input conditions
§Core Concepts
InputAction
: A trait representing an abstract input actionInputActionState
: Read the current state of an actionInputActionDrain
: Write action state from input systemsInputActionReader
: React to changes in action state
§Basic Usage
- Define your input action type (must implement
InputAction
) - Add the input action using
InputActionAppExt::add_input_action
- Write input systems that pour values into the
InputActionDrain
- Read the action state using
InputActionState
(orInputActionReader
for status updates)
§System Ordering
- Systems that write to
InputActionDrain
should run beforeInputActionSystem
- Systems that read from
InputActionState
typically run inUpdate
(afterPreUpdate
)
Re-exports§
pub use conditions::input_action_active;
conditions
pub use conditions::input_action_started;
conditions
pub use conditions::input_action_stopped;
conditions
pub use conditions::input_action_updated;
conditions
Modules§
- conditions
conditions
- SPDX-License-Identifier: MIT OR Apache-2.0
- prelude
- This module re-exports all necessary things to work with an input action.
Structs§
- Input
Action Drain - Provides write access to the input action drain.
- Input
Action Reader - Reader for input action status updates.
- Input
Action State - Provides read-only access to the current state of an input action.
- Input
Action System - Label for systems that update input actions.
Enums§
- Input
Action Status - Represents the status of an input action as read
from an
InputActionReader
.
Traits§
- Input
Action - Marker trait for all input actions.
- Input
Action AppExt - Extension trait for
App
andSubApp
.
Derive Macros§
- Input
Action derive
- Derive macro implementation for
InputAction
trait