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§
sourcefn kind(&self) -> InputControlKind
fn kind(&self) -> InputControlKind
Defines the kind of behavior that the input should be.
sourcefn decompose(&self) -> BasicInputs
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.
Implementations on Foreign Types§
source§impl UserInput for GamepadButtonType
impl UserInput for GamepadButtonType
source§fn kind(&self) -> InputControlKind
fn kind(&self) -> InputControlKind
GamepadButtonType
acts as a button.
source§fn decompose(&self) -> BasicInputs
fn decompose(&self) -> BasicInputs
Creates a BasicInputs
that only contains the GamepadButtonType
itself,
as it represents a simple physical button.
source§impl UserInput for KeyCode
impl UserInput for KeyCode
source§fn kind(&self) -> InputControlKind
fn kind(&self) -> InputControlKind
KeyCode
acts as a button.
source§fn decompose(&self) -> BasicInputs
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
impl UserInput for MouseButton
source§fn kind(&self) -> InputControlKind
fn kind(&self) -> InputControlKind
MouseButton
acts as a button.
source§fn decompose(&self) -> BasicInputs
fn decompose(&self) -> BasicInputs
Returns a BasicInputs
that only contains the MouseButton
itself,
as it represents a simple physical button.
source§impl UserInput for GamepadAxis
impl UserInput for GamepadAxis
Unlike GamepadButtonType
, this struct represents a specific axis on a specific gamepad.
In the majority of cases, GamepadControlAxis
or GamepadStick
should be used instead.
fn kind(&self) -> InputControlKind
fn decompose(&self) -> BasicInputs
source§impl UserInput for GamepadButton
impl UserInput for GamepadButton
Unlike GamepadButtonType
, this struct represents a specific button on a specific gamepad.
In the majority of cases, GamepadButtonType
should be used instead.