Skip to main content

UserInput

Trait UserInput 

Source
pub trait UserInput:
    Send
    + Sync
    + Debug {
    // Required methods
    fn kind(&self) -> InputControlKind;
    fn decompose(&self) -> BasicInputs;
}
Expand description

A trait for defining the behavior expected from different user input sources.

Required Methods§

Source

fn kind(&self) -> InputControlKind

Defines the kind of behavior that the input should be.

Source

fn decompose(&self) -> BasicInputs

Returns the set of primitive inputs that make up this input.

These inputs are used to detect clashes between different user inputs, and are stored in a BasicInputs for easy comparison.

For inputs that represent a simple, atomic control, this method should always return a BasicInputs::Simple that only contains the input itself.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl UserInput for GamepadAxis

Source§

impl UserInput for GamepadButton

Source§

fn kind(&self) -> InputControlKind

GamepadButton acts as a button.

Source§

fn decompose(&self) -> BasicInputs

Creates a BasicInputs that only contains the GamepadButton itself, as it represents a simple physical button.

Source§

impl UserInput for KeyCode

Source§

fn kind(&self) -> InputControlKind

KeyCode acts as a button.

Source§

fn decompose(&self) -> BasicInputs

Returns a BasicInputs that only contains the KeyCode itself, as it represents a simple physical button.

Source§

impl UserInput for MouseButton

Source§

fn kind(&self) -> InputControlKind

MouseButton acts as a button.

Source§

fn decompose(&self) -> BasicInputs

Returns a BasicInputs that only contains the MouseButton itself, as it represents a simple physical button.

Implementors§