[−][src]Struct amethyst_input::InputHandler
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.
Methods
impl<T> InputHandler<T> where
T: BindingTypes,
[src]
T: BindingTypes,
pub fn new() -> Self
[src]
Creates a new input handler.
pub fn send_event(
&mut self,
event: &Event,
event_handler: &mut EventChannel<InputEvent<T>>,
hidpi: f32
)
[src]
&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.
pub fn send_controller_event(
&mut self,
event: &ControllerEvent,
event_handler: &mut EventChannel<InputEvent<T>>
)
[src]
&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.
pub fn send_frame_begin(&mut self)
[src]
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.
pub fn keys_that_are_down(&self) -> impl Iterator<Item = VirtualKeyCode> + '_
[src]
Returns an iterator over all keys that are down.
pub fn key_is_down(&self, key: VirtualKeyCode) -> bool
[src]
Checks if a key is down.
pub fn mouse_buttons_that_are_down(&self) -> impl Iterator<Item = &MouseButton>
[src]
Returns an iterator over all pressed mouse buttons
pub fn mouse_button_is_down(&self, mouse_button: MouseButton) -> bool
[src]
Checks if a mouse button is down.
pub fn mouse_wheel_value(&self, horizontal: bool) -> f32
[src]
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.
pub fn scan_codes_that_are_down(&self) -> impl Iterator<Item = u32> + '_
[src]
Returns an iterator over all pressed scan codes
pub fn scan_code_is_down(&self, scan_code: u32) -> bool
[src]
Checks if the key corresponding to a scan code is down.
pub fn controller_buttons_that_are_down(
&self
) -> impl Iterator<Item = &(u32, ControllerButton)> + '_
[src]
&self
) -> impl Iterator<Item = &(u32, ControllerButton)> + '_
Returns an iterator over all pressed controller buttons on all controllers.
pub fn controller_button_is_down(
&self,
controller_id: u32,
controller_button: ControllerButton
) -> bool
[src]
&self,
controller_id: u32,
controller_button: ControllerButton
) -> bool
Checks if a controller button is down on specific controller.
pub fn connected_controllers(&self) -> impl Iterator<Item = u32> + '_
[src]
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.
pub fn is_controller_connected(&self, controller_id: u32) -> bool
[src]
Returns true if a controller with the given id is connected.
pub fn mouse_position(&self) -> Option<(f32, f32)>
[src]
Gets the current mouse position.
this method can return None, either if no mouse is connected, or if no mouse events have been recorded
pub fn buttons_that_are_down(&self) -> impl Iterator<Item = Button> + '_
[src]
Returns an iterator over all buttons that are down.
pub fn button_is_down(&self, button: Button) -> bool
[src]
Checks if a button is down.
pub fn axis_value<A: ?Sized>(&self, id: &A) -> Option<f32> where
T::Axis: Borrow<A>,
A: Hash + Eq,
[src]
T::Axis: Borrow<A>,
A: Hash + Eq,
Returns the value of an axis by the id, if the id doesn't exist this returns None.
pub fn action_is_down<A: ?Sized>(&self, action: &A) -> Option<bool> where
T::Action: Borrow<A>,
A: Hash + Eq,
[src]
T::Action: Borrow<A>,
A: Hash + Eq,
Returns true if any of the actions bindings is down.
If a binding represents a combination of buttons, all of them need to be down.
Trait Implementations
impl<T> Default for InputHandler<T> where
T: BindingTypes,
[src]
T: BindingTypes,
impl<T> Debug for InputHandler<T> where
T: BindingTypes,
[src]
T: BindingTypes,
Auto Trait Implementations
impl<T> Unpin for InputHandler<T> where
<T as BindingTypes>::Action: Unpin,
<T as BindingTypes>::Axis: Unpin,
<T as BindingTypes>::Action: Unpin,
<T as BindingTypes>::Axis: Unpin,
impl<T> Sync for InputHandler<T> where
<T as BindingTypes>::Action: Sync,
<T as BindingTypes>::Axis: Sync,
<T as BindingTypes>::Action: Sync,
<T as BindingTypes>::Axis: Sync,
impl<T> Send for InputHandler<T> where
<T as BindingTypes>::Action: Send,
<T as BindingTypes>::Axis: Send,
<T as BindingTypes>::Action: Send,
<T as BindingTypes>::Axis: Send,
impl<T> UnwindSafe for InputHandler<T> where
<T as BindingTypes>::Action: UnwindSafe,
<T as BindingTypes>::Axis: UnwindSafe,
<T as BindingTypes>::Action: UnwindSafe,
<T as BindingTypes>::Axis: UnwindSafe,
impl<T> RefUnwindSafe for InputHandler<T> where
<T as BindingTypes>::Action: RefUnwindSafe,
<T as BindingTypes>::Axis: RefUnwindSafe,
<T as BindingTypes>::Action: RefUnwindSafe,
<T as BindingTypes>::Axis: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> SetParameter for T
[src]
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
[src]
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
[src]
fn is_in_subset(&self) -> bool
[src]
unsafe fn to_subset_unchecked(&self) -> SS
[src]
fn from_subset(element: &SS) -> SP
[src]
impl<T> Resource for T where
T: Any + Send + Sync,
[src]
T: Any + Send + Sync,
impl<T> Any for T where
T: Any,
[src]
T: Any,
fn get_type_id(&self) -> TypeId
[src]
impl<T> TryDefault for T where
T: Default,
[src]
T: Default,
fn try_default() -> Result<T, String>
[src]
fn unwrap_default() -> Self
[src]
Calls try_default
and panics on an error case.
impl<T> Event for T where
T: Send + Sync + 'static,
[src]
T: Send + Sync + 'static,