[][src]Struct amethyst_input::InputHandler

pub struct InputHandler<T> where
    T: BindingTypes
{ pub bindings: Bindings<T>, // some fields omitted }

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]

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]

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]

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]

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]

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]

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]

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]

impl<T> Debug for InputHandler<T> where
    T: BindingTypes
[src]

Auto Trait Implementations

impl<T> Unpin for InputHandler<T> where
    <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

impl<T> Send for InputHandler<T> where
    <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

impl<T> RefUnwindSafe for InputHandler<T> where
    <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]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SetParameter for T[src]

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 
[src]

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]

impl<T> Resource for T where
    T: Any + Send + Sync
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> TryDefault for T where
    T: Default
[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]