Struct amethyst_input::InputHandler
source · pub struct InputHandler<AX, AC>where
AX: Hash + Eq,
AC: Hash + Eq,{
pub bindings: Bindings<AX, AC>,
/* private fields */
}
Expand description
This struct holds state information about input devices.
For example, if a key is pressed on the keyboard, this struct will record that the key is pressed until it is released again.
Fields
bindings: Bindings<AX, AC>
Maps inputs to actions and axes.
Implementations
sourceimpl<AX, AC> InputHandler<AX, AC>where
AX: Hash + Eq + Clone + Send + Sync + 'static,
AC: Hash + Eq + Clone + Send + Sync + 'static,
impl<AX, AC> InputHandler<AX, AC>where
AX: Hash + Eq + Clone + Send + Sync + 'static,
AC: Hash + Eq + Clone + Send + Sync + 'static,
sourcepub fn send_event(
&mut self,
event: &Event,
event_handler: &mut EventChannel<InputEvent<AC>>
)
pub fn send_event(
&mut self,
event: &Event,
event_handler: &mut EventChannel<InputEvent<AC>>
)
Updates the input handler with a new engine event.
The Amethyst game engine will automatically call this if the InputHandler is attached to the world as a resource with id 0.
sourcepub fn send_controller_event(
&mut self,
event: &ControllerEvent,
event_handler: &mut EventChannel<InputEvent<AC>>
)
pub fn send_controller_event(
&mut self,
event: &ControllerEvent,
event_handler: &mut EventChannel<InputEvent<AC>>
)
Updates the input handler with a new controller event.
Called internally from SdlEventsSystem when using sdl_controller feature. You should invoke it in your system if you provide your own controller input implementation.
sourcepub fn keys_that_are_down(&self) -> impl Iterator<Item = VirtualKeyCode> + '_
pub fn keys_that_are_down(&self) -> impl Iterator<Item = VirtualKeyCode> + '_
Returns an iterator over all keys that are down.
sourcepub fn key_is_down(&self, key: VirtualKeyCode) -> bool
pub fn key_is_down(&self, key: VirtualKeyCode) -> bool
Checks if a key is down.
Returns an iterator over all pressed mouse buttons
Checks if a mouse button is down.
sourcepub fn scan_codes_that_are_down(&self) -> impl Iterator<Item = u32> + '_
pub fn scan_codes_that_are_down(&self) -> impl Iterator<Item = u32> + '_
Returns an iterator over all pressed scan codes
sourcepub fn scan_code_is_down(&self, scan_code: u32) -> bool
pub fn scan_code_is_down(&self, scan_code: u32) -> bool
Checks if the key corresponding to a scan code is down.
Returns an iterator over all pressed controller buttons on all controllers.
Checks if a controller button is down on specific controller.
sourcepub fn connected_controllers(&self) -> impl Iterator<Item = u32> + '_
pub fn connected_controllers(&self) -> impl Iterator<Item = u32> + '_
List controller ids of all currently connected controllers. IDs are assigned sequentially in the order of connection starting from 0, always taking the lowest next free number.
sourcepub fn is_controller_connected(&self, controller_id: u32) -> bool
pub fn is_controller_connected(&self, controller_id: u32) -> bool
Returns true if a controller with the given id is connected.
sourcepub fn mouse_position(&self) -> Option<(f64, f64)>
pub fn mouse_position(&self) -> Option<(f64, f64)>
Gets the current mouse position.
this method can return None, either if no mouse is connected, or if no mouse events have been recorded
Returns an iterator over all buttons that are down.
Checks if a button is down.
Trait Implementations
Auto Trait Implementations
impl<AX, AC> RefUnwindSafe for InputHandler<AX, AC>where
AC: RefUnwindSafe,
AX: RefUnwindSafe,
impl<AX, AC> Send for InputHandler<AX, AC>where
AC: Send,
AX: Send,
impl<AX, AC> Sync for InputHandler<AX, AC>where
AC: Sync,
AX: Sync,
impl<AX, AC> Unpin for InputHandler<AX, AC>where
AC: Unpin,
AX: Unpin,
impl<AX, AC> UnwindSafe for InputHandler<AX, AC>where
AC: UnwindSafe,
AX: UnwindSafe,
Blanket Implementations
impl<T> Any for Twhere
T: Any,
impl<T> Any for Twhere
T: Any,
fn get_type_id(&self) -> TypeId
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moreimpl<T> Pointable for T
impl<T> Pointable for T
impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default
and panics on an error case.