Skip to main content

Axislike

Trait Axislike 

Source
pub trait Axislike:
    UserInput
    + DynClone
    + DynEq
    + DynHash
    + Reflect
    + Serialize {
    // Required method
    fn get_value(
        &self,
        input_store: &CentralInputStore,
        gamepad: Entity,
    ) -> Option<f32>;

    // Provided methods
    fn value(&self, input_store: &CentralInputStore, gamepad: Entity) -> f32 { ... }
    fn set_value(&self, world: &mut World, value: f32) { ... }
    fn set_value_as_gamepad(
        &self,
        world: &mut World,
        value: f32,
        _gamepad: Option<Entity>,
    ) { ... }
}
Expand description

A trait used for axis-like user inputs, which provide a continuous value.

Required Methods§

Source

fn get_value( &self, input_store: &CentralInputStore, gamepad: Entity, ) -> Option<f32>

Gets the current value of the input as an f32.

Provided Methods§

Source

fn value(&self, input_store: &CentralInputStore, gamepad: Entity) -> f32

Gets the current value of the input as an f32.

Source

fn set_value(&self, world: &mut World, value: f32)

Simulate an axis-like input by sending the appropriate message.

This method defaults to calling Axislike::set_value_as_gamepad if not overridden, as is the case for gamepad-reliant inputs.

Source

fn set_value_as_gamepad( &self, world: &mut World, value: f32, _gamepad: Option<Entity>, )

Simulate an axis-like input, pretending to be the provided gamepad Entity.

This method defaults to calling Axislike::set_value if not overridden, as is the case for things like a mouse wheel.

Use find_gamepad inside of this method to search for a gamepad to press the button on if the provided gamepad is None.

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for Box<dyn Axislike>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'eq> Eq for dyn Axislike + 'eq

Source§

impl<'eq> Eq for dyn Axislike + Send + 'eq

Source§

impl<'eq> Eq for dyn Axislike + Sync + 'eq

Source§

impl<'eq> Eq for dyn Axislike + Send + Sync + 'eq

Source§

impl FromReflect for Box<dyn Axislike>

Source§

fn from_reflect(reflect: &dyn PartialReflect) -> Option<Self>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl GetTypeRegistration for Box<dyn Axislike>

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(_registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl<'hash> Hash for dyn Axislike + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'hash> Hash for dyn Axislike + Send + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'hash> Hash for dyn Axislike + Sync + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'hash> Hash for dyn Axislike + Send + Sync + 'hash

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'eq> PartialEq for dyn Axislike + 'eq

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq for dyn Axislike + Send + 'eq

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq for dyn Axislike + Sync + 'eq

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq for dyn Axislike + Send + Sync + 'eq

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq<&Box<dyn Axislike + 'eq>> for Box<dyn Axislike + 'eq>

Source§

fn eq(&self, other: &&Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq<&Box<dyn Axislike + Send + 'eq>> for Box<dyn Axislike + Send + 'eq>

Source§

fn eq(&self, other: &&Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq<&Box<dyn Axislike + Sync + 'eq>> for Box<dyn Axislike + Sync + 'eq>

Source§

fn eq(&self, other: &&Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'eq> PartialEq<&Box<dyn Axislike + Sync + Send + 'eq>> for Box<dyn Axislike + Send + Sync + 'eq>

Source§

fn eq(&self, other: &&Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialReflect for Box<dyn Axislike>

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<Self>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn into_partial_reflect(self: Box<Self>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &dyn PartialReflect

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut dyn PartialReflect

Casts this type to a mutable, reflected value. Read more
Source§

fn try_into_reflect( self: Box<Self>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&dyn Reflect>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails.
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn reflect_partial_eq( &self, _value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn reflect_partial_cmp( &self, _value: &(dyn PartialReflect + 'static), ) -> Option<Ordering>

Returns a “partial comparison” result. Read more
Source§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl Reflect for Box<dyn Axislike>

Source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &dyn Any

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &dyn Reflect

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut dyn Reflect

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl<'de> RegisterTypeTag<'de, dyn Axislike> for AxislikeChord

Source§

fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Axislike>)

Registers the specified type tag into the InfallibleMapRegistry.
Source§

impl<'de> RegisterTypeTag<'de, dyn Axislike> for GamepadAxis

Source§

fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Axislike>)

Registers the specified type tag into the InfallibleMapRegistry.
Source§

impl<'de> RegisterTypeTag<'de, dyn Axislike> for SpecificGamepadAxis

Source§

fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Axislike>)

Registers the specified type tag into the InfallibleMapRegistry.
Source§

impl<'de> RegisterTypeTag<'de, dyn Axislike> for GamepadControlAxis

Source§

fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Axislike>)

Registers the specified type tag into the InfallibleMapRegistry.
Source§

impl<'de> RegisterTypeTag<'de, dyn Axislike> for MouseMoveAxis

Source§

fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Axislike>)

Registers the specified type tag into the InfallibleMapRegistry.
Source§

impl<'de> RegisterTypeTag<'de, dyn Axislike> for MouseScrollAxis

Source§

fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Axislike>)

Registers the specified type tag into the InfallibleMapRegistry.
Source§

impl<'de> RegisterTypeTag<'de, dyn Axislike> for VirtualAxis

Source§

fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Axislike>)

Registers the specified type tag into the InfallibleMapRegistry.
Source§

impl Serialize for dyn Axislike + '_

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TypePath for Box<dyn Axislike>

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl Typed for Box<dyn Axislike>

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Axislike for GamepadAxis

Source§

fn get_value( &self, input_store: &CentralInputStore, gamepad: Entity, ) -> Option<f32>

Implementors§