leafwing_input_manager::user_input::updating

Trait UpdatableInput

source
pub trait UpdatableInput: 'static {
    type SourceData: Resource;

    // Required method
    fn compute(
        central_input_store: ResMut<'_, CentralInputStore>,
        source_data: Res<'_, Self::SourceData>,
    );
}
Expand description

A trait that enables user input to be updated based on the state of the world.

This trait is intended to be used for the values stored inside of CentralInputStore. For the actual user inputs that you might bind actions to, use UserInput instead.

The values of each UserInput type will be computed by calling the methods on CentralInputStore, and so the UpdatableInput trait is only needed when defining new kinds of input that we can derive user-facing inputs from.

In simple cases, a type will be both UserInput and UpdatableInput, however when configuration is needed (such as for processed axes or virtual d-pads), two distinct types must be used.

To add a new kind of input, call CentralInputStore::register_input_kind during App setup.

Required Associated Types§

source

type SourceData: Resource

The resource data that must be fetched from the world in order to update the user input.

§Panics

This type cannot be CentralInputStore, as that would cause mutable aliasing and panic at runtime.

Required Methods§

source

fn compute( central_input_store: ResMut<'_, CentralInputStore>, source_data: Res<'_, Self::SourceData>, )

A system that updates the central store of user input based on the state of the world.

When defining these systems, use the update methods on CentralInputStore to store the new values.

§Warning

This system should not be added manually: instead, call CentralInputStore::register_input_kind.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl UpdatableInput for KeyCode

source§

type SourceData = ButtonInput<KeyCode>

source§

fn compute( central_input_store: ResMut<'_, CentralInputStore>, source_data: Res<'_, Self::SourceData>, )

source§

impl UpdatableInput for MouseButton

source§

type SourceData = ButtonInput<MouseButton>

source§

fn compute( central_input_store: ResMut<'_, CentralInputStore>, source_data: Res<'_, Self::SourceData>, )

source§

impl UpdatableInput for GamepadAxis

source§

type SourceData = Axis<GamepadAxis>

source§

fn compute( central_input_store: ResMut<'_, CentralInputStore>, source_data: Res<'_, Self::SourceData>, )

source§

impl UpdatableInput for GamepadButton

source§

type SourceData = ButtonInput<GamepadButton>

source§

fn compute( central_input_store: ResMut<'_, CentralInputStore>, source_data: Res<'_, Self::SourceData>, )

Implementors§