[][src]Struct amethyst_input::InputHandler

pub struct InputHandler<AX, AC> where
    AX: Hash + Eq,
    AC: Hash + Eq
{ pub bindings: Bindings<AX, AC>, // 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<AX, AC>

Maps inputs to actions and axes.

Methods

impl<AX, AC> InputHandler<AX, AC> where
    AX: Hash + Eq,
    AC: Hash + Eq
[src]

pub fn new() -> Self[src]

Creates a new input handler.

impl<AX, AC> InputHandler<AX, AC> where
    AX: Hash + Eq + Clone + Send + Sync + 'static,
    AC: Hash + Eq + Clone + Send + Sync + 'static, 
[src]

pub fn send_event(
    &mut self,
    event: &Event,
    event_handler: &mut EventChannel<InputEvent<AC>>,
    hidpi: f64
)
[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 with id 0.

pub fn send_controller_event(
    &mut self,
    event: &ControllerEvent,
    event_handler: &mut EventChannel<InputEvent<AC>>
)
[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 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 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<(f64, f64)>[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<'a>(&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<T: Hash + Eq + ?Sized>(&self, id: &T) -> Option<f64> where
    AX: Borrow<T>, 
[src]

Returns the value of an axis by the string id, if the id doesn't exist this returns None.

pub fn action_is_down<T: Hash + Eq + ?Sized>(&self, action: &T) -> Option<bool> where
    AC: Borrow<T>, 
[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<AX, AC> Default for InputHandler<AX, AC> where
    AX: Hash + Eq,
    AC: Hash + Eq
[src]

Auto Trait Implementations

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

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

impl<T, U> TryInto 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> Same for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf for SP where
    SS: SubsetOf<SP>, 

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

impl<T> TryDefault for T where
    T: Default

fn unwrap_default() -> Self

Calls try_default and panics on an error case.

impl<T> Any for T where
    T: Any

impl<T> Event for T where
    T: Send + Sync + 'static, 

impl<T> Erased for T

impl<T> Erased for T

impl<T> SetParameter for T

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

Sets value as a parameter of self.