pub trait Buttonlike:
UserInput
+ DynClone
+ DynEq
+ DynHash
+ Reflect
+ Serialize {
// Required method
fn pressed(&self, input_store: &CentralInputStore, gamepad: Gamepad) -> bool;
// Provided methods
fn released(
&self,
input_store: &CentralInputStore,
gamepad: Gamepad,
) -> bool { ... }
fn press(&self, world: &mut World) { ... }
fn press_as_gamepad(&self, world: &mut World, _gamepad: Option<Gamepad>) { ... }
fn release(&self, world: &mut World) { ... }
fn release_as_gamepad(&self, world: &mut World, _gamepad: Option<Gamepad>) { ... }
}
Expand description
A trait used for buttonlike user inputs, which can be pressed or released.
Required Methods§
sourcefn pressed(&self, input_store: &CentralInputStore, gamepad: Gamepad) -> bool
fn pressed(&self, input_store: &CentralInputStore, gamepad: Gamepad) -> bool
Checks if the input is currently active.
Provided Methods§
sourcefn released(&self, input_store: &CentralInputStore, gamepad: Gamepad) -> bool
fn released(&self, input_store: &CentralInputStore, gamepad: Gamepad) -> bool
Checks if the input is currently inactive.
sourcefn press(&self, world: &mut World)
fn press(&self, world: &mut World)
Simulates a press of the buttonlike input by sending the appropriate event.
This method defaults to calling Buttonlike::press_as_gamepad
if not overridden,
as is the case for gamepad-reliant inputs.
sourcefn press_as_gamepad(&self, world: &mut World, _gamepad: Option<Gamepad>)
fn press_as_gamepad(&self, world: &mut World, _gamepad: Option<Gamepad>)
Simulate a press of the buttonlike input, pretending to be the provided Gamepad
.
This method defaults to calling Buttonlike::press
if not overridden,
as is the case for things like mouse buttons and keyboard keys.
Use find_gamepad
inside of this method to search for a gamepad to press the button on
if the provided gamepad is None
.
sourcefn release(&self, world: &mut World)
fn release(&self, world: &mut World)
Simulates a release of the buttonlike input by sending the appropriate event.
This method defaults to calling Buttonlike::release_as_gamepad
if not overridden,
as is the case for gamepad-reliant inputs.
sourcefn release_as_gamepad(&self, world: &mut World, _gamepad: Option<Gamepad>)
fn release_as_gamepad(&self, world: &mut World, _gamepad: Option<Gamepad>)
Simulate a release of the buttonlike input, pretending to be the provided Gamepad
.
This method defaults to calling Buttonlike::release
if not overridden,
as is the case for things like mouse buttons and keyboard keys.
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 Buttonlike>
impl<'de> Deserialize<'de> for Box<dyn Buttonlike>
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 Buttonlike>
impl FromReflect for Box<dyn Buttonlike>
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 Buttonlike>
impl GetTypeRegistration for Box<dyn Buttonlike>
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<'hash> Hash for dyn Buttonlike + 'hash
impl<'hash> Hash for dyn Buttonlike + 'hash
source§impl<'hash> Hash for dyn Buttonlike + Send + 'hash
impl<'hash> Hash for dyn Buttonlike + Send + 'hash
source§impl<'hash> Hash for dyn Buttonlike + Sync + 'hash
impl<'hash> Hash for dyn Buttonlike + Sync + 'hash
source§impl<'eq> PartialEq<&Box<dyn Buttonlike + 'eq>> for Box<dyn Buttonlike + 'eq>
impl<'eq> PartialEq<&Box<dyn Buttonlike + 'eq>> for Box<dyn Buttonlike + 'eq>
source§impl<'eq> PartialEq<&Box<dyn Buttonlike + Send + 'eq>> for Box<dyn Buttonlike + Send + 'eq>
impl<'eq> PartialEq<&Box<dyn Buttonlike + Send + 'eq>> for Box<dyn Buttonlike + Send + 'eq>
source§impl<'eq> PartialEq<&Box<dyn Buttonlike + Send + Sync + 'eq>> for Box<dyn Buttonlike + Send + Sync + 'eq>
impl<'eq> PartialEq<&Box<dyn Buttonlike + Send + Sync + 'eq>> for Box<dyn Buttonlike + Send + Sync + 'eq>
source§impl<'eq> PartialEq<&Box<dyn Buttonlike + Sync + 'eq>> for Box<dyn Buttonlike + Sync + 'eq>
impl<'eq> PartialEq<&Box<dyn Buttonlike + Sync + 'eq>> for Box<dyn Buttonlike + Sync + 'eq>
source§impl<'eq> PartialEq for dyn Buttonlike + 'eq
impl<'eq> PartialEq for dyn Buttonlike + 'eq
source§impl<'eq> PartialEq for dyn Buttonlike + Send + 'eq
impl<'eq> PartialEq for dyn Buttonlike + Send + 'eq
source§impl<'eq> PartialEq for dyn Buttonlike + Sync + 'eq
impl<'eq> PartialEq for dyn Buttonlike + Sync + 'eq
source§impl Reflect for Box<dyn Buttonlike>
impl Reflect for Box<dyn Buttonlike>
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 Buttonlike> for ButtonlikeChord
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for ButtonlikeChord
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for GamepadButton
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for GamepadButton
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for GamepadButtonType
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for GamepadButtonType
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for GamepadControlDirection
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for GamepadControlDirection
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for KeyCode
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for KeyCode
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for ModifierKey
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for ModifierKey
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for MouseButton
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for MouseButton
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for MouseMoveDirection
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for MouseMoveDirection
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for MouseScrollDirection
impl<'de> RegisterTypeTag<'de, dyn Buttonlike> for MouseScrollDirection
source§fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
fn register_typetag(registry: &mut InfallibleMapRegistry<dyn Buttonlike>)
InfallibleMapRegistry
.source§impl<'a> Serialize for dyn Buttonlike + 'a
impl<'a> Serialize for dyn Buttonlike + 'a
source§impl TypePath for Box<dyn Buttonlike>
impl TypePath for Box<dyn Buttonlike>
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>
source§impl Typed for Box<dyn Buttonlike>
impl Typed for Box<dyn Buttonlike>
impl<'eq> Eq for dyn Buttonlike + 'eq
impl<'eq> Eq for dyn Buttonlike + Send + 'eq
impl<'eq> Eq for dyn Buttonlike + Send + Sync + 'eq
impl<'eq> Eq for dyn Buttonlike + Sync + 'eq
Implementations on Foreign Types§
source§impl Buttonlike for GamepadButtonType
impl Buttonlike for GamepadButtonType
source§fn pressed(&self, input_store: &CentralInputStore, gamepad: Gamepad) -> bool
fn pressed(&self, input_store: &CentralInputStore, gamepad: Gamepad) -> bool
Checks if the specified button is currently pressed down.
source§fn press_as_gamepad(&self, world: &mut World, gamepad: Option<Gamepad>)
fn press_as_gamepad(&self, world: &mut World, gamepad: Option<Gamepad>)
Sends a GamepadEvent::Button
event with a magnitude of 1.0 in the direction defined by self
on the provided Gamepad
.
source§fn release_as_gamepad(&self, world: &mut World, gamepad: Option<Gamepad>)
fn release_as_gamepad(&self, world: &mut World, gamepad: Option<Gamepad>)
Sends a GamepadEvent::Button
event with a magnitude of 0.0 in the direction defined by self
on the provided Gamepad
.
source§impl Buttonlike for KeyCode
impl Buttonlike for KeyCode
source§fn pressed(&self, input_store: &CentralInputStore, _gamepad: Gamepad) -> bool
fn pressed(&self, input_store: &CentralInputStore, _gamepad: Gamepad) -> bool
Checks if the specified key is currently pressed down.
source§fn press(&self, world: &mut World)
fn press(&self, world: &mut World)
Sends a fake KeyboardInput
event to the world with ButtonState::Pressed
.
§Note
The logical_key
and window
fields will be filled with placeholder values.
source§fn release(&self, world: &mut World)
fn release(&self, world: &mut World)
Sends a fake KeyboardInput
event to the world with ButtonState::Released
.
§Note
The logical_key
and window
fields will be filled with placeholder values.
source§impl Buttonlike for MouseButton
impl Buttonlike for MouseButton
source§fn pressed(&self, input_store: &CentralInputStore, _gamepad: Gamepad) -> bool
fn pressed(&self, input_store: &CentralInputStore, _gamepad: Gamepad) -> bool
Checks if the specified button is currently pressed down.
source§fn press(&self, world: &mut World)
fn press(&self, world: &mut World)
Sends a fake MouseButtonInput
event to the world with ButtonState::Pressed
.
§Note
The window
field will be filled with a placeholder value.
source§fn release(&self, world: &mut World)
fn release(&self, world: &mut World)
Sends a fake MouseButtonInput
event to the world with ButtonState::Released
.
§Note
The window
field will be filled with a placeholder value.