InputState
Allows querying of input state, e.g. checking if a key was pressed.
This interface supports querying keys by position relative to a standard QWERTY setup with the position_
methods.
This allows for implementing traditional position-based control schemes, e.g. WASD, across keyboard layouts.
For example, if we check position_held(Key.W)
, this would return true
on an AZERTY keyboard if Z were currently held.
struct InputState {
// from native code
}
Fields
Methods
position_axis
fn position_axis(self, neg: Key, pos: Key) -> f32
Create an axis from a negative and positive key.
Useful for paired key inputs, e.g. a side-scrolling platformer could use position_axis(Key.A, Key.D)
to implement left/right movement.
position_held
fn position_held(self, key: Key) -> bool
Check if a key is currenty held down, by position.
position_pressed
fn position_pressed(self, key: Key) -> bool
Check if a key was pressed this frame, by position.
position_released
fn position_released(self, key: Key) -> bool
Check if a key was released this frame, by position.
mouse_button_held
fn mouse_button_held(self, button: MouseButton) -> bool
Check if a particular mouse button is currently held down.
mouse_button_pressed
fn mouse_button_pressed(self, button: MouseButton) -> bool
Check if a particular mouse button was pressed this frame.
mouse_button_released
fn mouse_button_released(self, button: MouseButton) -> bool
Check if a particular mouse button was released this frame.
mouse_position
fn mouse_position(self) -> Vec2
Get the current mouse position, in screen space.
mouse_position_delta
fn mouse_position_delta(self) -> Vec2
Get the most recent mouse delta, in screen space.
touchpad_delta
fn touchpad_delta(self) -> Vec2
Get the most recent touchpad delta, in screen space.
scroll_delta
fn scroll_delta(self) -> f32
Get the most recent scroll-wheel delta, in screen space.