pub struct InputHandler<T>where
T: BindingTypes,{
pub bindings: Bindings<T>,
/* 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<T>Maps inputs to actions and axes.
Implementations§
Source§impl<T> InputHandler<T>where
T: BindingTypes,
impl<T> InputHandler<T>where
T: BindingTypes,
Sourcepub fn send_event(
&mut self,
event: &Event,
event_handler: &mut EventChannel<InputEvent<T>>,
hidpi: f32,
)
pub fn send_event( &mut self, event: &Event, event_handler: &mut EventChannel<InputEvent<T>>, hidpi: f32, )
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.
Sourcepub fn send_controller_event(
&mut self,
event: &ControllerEvent,
event_handler: &mut EventChannel<InputEvent<T>>,
)
pub fn send_controller_event( &mut self, event: &ControllerEvent, event_handler: &mut EventChannel<InputEvent<T>>, )
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 send_frame_begin(&mut self)
pub fn send_frame_begin(&mut self)
This function is to be called whenever a frame begins. It resets some input values.
The InputSystem will call this automatically. If you’re using that system, you
don’t need to call this function.
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 mouse_wheel_value(&self, horizontal: bool) -> f32
pub fn mouse_wheel_value(&self, horizontal: bool) -> f32
If the mouse wheel was scrolled this frame this function will return the direction it was scrolled.
If “horizontal” is true this will return the horizontal mouse value. You almost always want the vertical mouse value.
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<(f32, f32)>
pub fn mouse_position(&self) -> Option<(f32, f32)>
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.
Sourcepub fn axis_value<A>(&self, id: &A) -> Option<f32>
pub fn axis_value<A>(&self, id: &A) -> Option<f32>
Returns the value of an axis by the id, if the id doesn’t exist this returns None.
Trait Implementations§
Source§impl<T> Debug for InputHandler<T>where
T: BindingTypes,
impl<T> Debug for InputHandler<T>where
T: BindingTypes,
Source§impl<T> Default for InputHandler<T>where
T: BindingTypes,
impl<T> Default for InputHandler<T>where
T: BindingTypes,
Auto Trait Implementations§
impl<T> Freeze for InputHandler<T>
impl<T> RefUnwindSafe for InputHandler<T>
impl<T> Send for InputHandler<T>
impl<T> Sync for InputHandler<T>
impl<T> Unpin for InputHandler<T>
impl<T> UnsafeUnpin for InputHandler<T>
impl<T> UnwindSafe for InputHandler<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SetParameter for T
impl<T> SetParameter for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
Source§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Source§fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default and panics on an error case.