Struct amethyst_input::InputHandler [] [src]

pub struct InputHandler {
    pub bindings: Bindings,
    // 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. Usage requires pumping input events through this struct, using the following code in the handle_events method of State.

fn handle_events(&mut self,
                 events: &[WindowEvent],
                 _: &mut World,
                 _: &mut AssetManager,
                 _: &mut Pipeline)
                 -> Trans {
    // ...
    let mut input_handler = world.write_resource::<InputHandler>();
    input_handler.update(events);
    // ...
}

Fields

Maps inputs to actions and axes.

Methods

impl InputHandler
[src]

Creates a new input handler.

Signals that a frame has begun.

The Amethyst game engine will automatically call this if the InputHandler is attached to the world as a resource with id 0.

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.

Returns a string representation of all text entered this frame.

Intended for use with text entry fields, insert this string at the cursor position every frame.

Returns an iterator over all keys in the given state, does not support Released(Currently).

Checks if a key matches the description given by state.

Checks if the all the given keys are down and at least one was pressed on this frame.

Returns an iterator over all mouse buttons in the given state, does not support Released(Currently).

Checks if a mouse button matches the description given by state.

Checks if the all the given mouse buttons are down and at least one was pressed this frame.

Gets the current mouse position.

this method can return None, either if no mouse is connected, or if no mouse events have been recorded

Gets the change in position since the last frame.

Returns an iterator over all buttons in the given state, does not support Released(Currently).

Checks if a button matches the description given by state.

Checks if the all given buttons are being pressed and at least one was pressed this frame.

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

Returns true if any of the action is in the given state. Returns None if an invalid action was provided.

Checks if the all given actions are being pressed and at least one was pressed this frame.

If any action in this list is invalid this will return the id of it in Err.

Trait Implementations

impl Default for InputHandler
[src]

Returns the "default value" for a type. Read more