Trait leafwing_input_manager::user_input::UserInput  
source · pub trait UserInput:
    Send
    + Sync
    + Debug
    + DynClone
    + DynEq
    + DynHash
    + Reflect
    + Serialize {
    // Required methods
    fn kind(&self) -> InputControlKind;
    fn decompose(&self) -> BasicInputs;
}Expand description
A trait for defining the behavior expected from different user input sources.
Implementers of this trait should provide methods for accessing and processing user input data.
§Examples
use std::hash::{Hash, Hasher};
use bevy::prelude::*;
use bevy::math::{Vec2, FloatOrd};
use serde::{Deserialize, Serialize};
use leafwing_input_manager::prelude::*;
use leafwing_input_manager::axislike::{DualAxisType};
use leafwing_input_manager::clashing_inputs::BasicInputs;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Reflect, Serialize, Deserialize)]
pub struct MouseScrollAlwaysFiveOnYAxis;
// Add this attribute for ensuring proper serialization and deserialization.
#[serde_typetag]
impl UserInput for MouseScrollAlwaysFiveOnYAxis {
    fn kind(&self) -> InputControlKind {
        // Returns the kind of input this represents.
        //
        // In this case, it represents an axial input.
        InputControlKind::Axis
    }
    fn decompose(&self) -> BasicInputs {
        // Gets the most basic form of this input for clashing input detection.
        //
        // This input is not buttonlike, so it uses `None`.
        BasicInputs::None
    }
}
// Remember to register your input - it will ensure everything works smoothly!
let mut app = App::new();
app.register_user_input::<MouseScrollAlwaysFiveOnYAxis>();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.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Box<dyn UserInput>
 
impl<'de> Deserialize<'de> for Box<dyn UserInput>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
    D: Deserializer<'de>,
 
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
    D: Deserializer<'de>,
source§impl FromReflect for Box<dyn UserInput>
 
impl FromReflect for Box<dyn UserInput>
source§fn from_reflect(reflect: &dyn Reflect) -> Option<Self>
 
fn from_reflect(reflect: &dyn Reflect) -> Option<Self>
Self from a reflected value.source§fn take_from_reflect(
    reflect: Box<dyn Reflect>,
) -> Result<Self, Box<dyn Reflect>>
 
fn take_from_reflect( reflect: Box<dyn Reflect>, ) -> Result<Self, Box<dyn Reflect>>
Self using,
constructing the value using from_reflect if that fails. Read moresource§impl GetTypeRegistration for Box<dyn UserInput>
 
impl GetTypeRegistration for Box<dyn UserInput>
source§fn get_type_registration() -> TypeRegistration
 
fn get_type_registration() -> TypeRegistration
TypeRegistration for this type.source§fn register_type_dependencies(registry: &mut TypeRegistry)
 
fn register_type_dependencies(registry: &mut TypeRegistry)
source§impl<'eq> PartialEq<&Box<dyn UserInput + Send + Sync + 'eq>> for Box<dyn UserInput + Send + Sync + 'eq>
 
impl<'eq> PartialEq<&Box<dyn UserInput + Send + Sync + 'eq>> for Box<dyn UserInput + Send + Sync + 'eq>
source§impl Reflect for Box<dyn UserInput>
 
impl Reflect for Box<dyn UserInput>
source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
 
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
source§fn as_any_mut(&mut self) -> &mut dyn Any
 
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any.source§fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
 
fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
source§fn as_reflect(&self) -> &dyn Reflect
 
fn as_reflect(&self) -> &dyn Reflect
source§fn as_reflect_mut(&mut self) -> &mut dyn Reflect
 
fn as_reflect_mut(&mut self) -> &mut dyn Reflect
source§fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
 
fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
source§fn reflect_kind(&self) -> ReflectKind
 
fn reflect_kind(&self) -> ReflectKind
source§fn reflect_ref(&self) -> ReflectRef<'_>
 
fn reflect_ref(&self) -> ReflectRef<'_>
source§fn reflect_mut(&mut self) -> ReflectMut<'_>
 
fn reflect_mut(&mut self) -> ReflectMut<'_>
source§fn reflect_owned(self: Box<Self>) -> ReflectOwned
 
fn reflect_owned(self: Box<Self>) -> ReflectOwned
source§fn clone_value(&self) -> Box<dyn Reflect>
 
fn clone_value(&self) -> Box<dyn Reflect>
Reflect trait object. Read moresource§fn reflect_hash(&self) -> Option<u64>
 
fn reflect_hash(&self) -> Option<u64>
source§fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
 
fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
source§fn serializable(&self) -> Option<Serializable<'_>>
 
fn serializable(&self) -> Option<Serializable<'_>>
source§fn is_dynamic(&self) -> bool
 
fn is_dynamic(&self) -> bool
source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for AxislikeChord
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for AxislikeChord
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for ButtonlikeChord
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for ButtonlikeChord
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for DualAxislikeChord
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for DualAxislikeChord
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadButtonType
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadButtonType
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadControlAxis
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadControlAxis
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadControlDirection
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadControlDirection
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadStick
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadStick
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadVirtualAxis
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadVirtualAxis
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadVirtualDPad
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for GamepadVirtualDPad
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for KeyCode
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for KeyCode
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for KeyboardVirtualAxis
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for KeyboardVirtualAxis
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for KeyboardVirtualDPad
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for KeyboardVirtualDPad
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for ModifierKey
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for ModifierKey
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseButton
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseButton
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseMove
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseMove
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseMoveAxis
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseMoveAxis
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseMoveDirection
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseMoveDirection
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseScroll
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseScroll
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseScrollAxis
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseScrollAxis
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseScrollDirection
 
impl<'de> RegisterTypeTag<'de, dyn UserInput> for MouseScrollDirection
source§fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
 
fn register_typetag(registry: &mut MapRegistry<dyn UserInput>)
MapRegistry.source§impl TypePath for Box<dyn UserInput>
 
impl TypePath for Box<dyn UserInput>
source§fn type_path() -> &'static str
 
fn type_path() -> &'static str
source§fn short_type_path() -> &'static str
 
fn short_type_path() -> &'static str
source§fn type_ident() -> Option<&'static str>
 
fn type_ident() -> Option<&'static str>
source§fn crate_name() -> Option<&'static str>
 
fn crate_name() -> Option<&'static str>
impl<'eq> Eq for dyn UserInput + 'eq
impl<'eq> Eq for dyn UserInput + Send + 'eq
impl<'eq> Eq for dyn UserInput + Send + Sync + 'eq
impl<'eq> Eq for dyn UserInput + Sync + 'eq
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.