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
bindings: Bindings
Maps inputs to actions and axes.
Methods
impl InputHandler
[src]
fn new() -> InputHandler
Creates a new input handler.
fn advance_frame(&mut self)
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.
fn send_event(&mut self, event: &WindowEvent)
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.
fn text_entered(&self) -> &str
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.
fn keys_that_are(&self, state: ButtonState) -> KeyCodes
Returns an iterator over all keys in the given state, does not support Released(Currently).
fn key_is(&self, key: VirtualKeyCode, state: ButtonState) -> bool
Checks if a key matches the description given by state.
fn keys_down(&self, keys: &[VirtualKeyCode]) -> bool
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.
fn mouse_position(&self) -> Option<(f64, f64)>
Gets the current mouse position.
this method can return None, either if no mouse is connected, or if no mouse events have been recorded
fn mouse_position_change(&self) -> (f64, f64)
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.
fn axis_value<T: AsRef<str>>(&self, id: T) -> Option<f64>
Returns the value of an axis by the string id, if the id doesn't exist this returns None.
fn action_is<T: AsRef<str>>(
&self,
action: T,
state: ButtonState
) -> Option<bool>
&self,
action: T,
state: ButtonState
) -> Option<bool>
Returns true if any of the action is in the given state. Returns None if an invalid action was provided.
fn actions_down<T: AsRef<str>>(
&self,
actions: &[T]
) -> Result<bool, Vec<String>>
&self,
actions: &[T]
) -> Result<bool, Vec<String>>
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]
fn default() -> InputHandler
Returns the "default value" for a type. Read more