pub struct InputState {
pub mouse_position: Vec2,
pub mouse_delta: Vec2,
pub mouse_buttons: [ButtonState; 5],
pub touches: Vec<TouchEvent>,
pub gamepads: [GamepadState; 4],
/* private fields */
}Expand description
Unified input state manager
Fields§
§mouse_position: Vec2Mouse position
mouse_delta: Vec2Mouse delta
Mouse button states
touches: Vec<TouchEvent>Active touches
gamepads: [GamepadState; 4]Gamepad states (up to 4)
Implementations§
Source§impl InputState
impl InputState
Gets mouse button state
Sourcepub fn key(&self, key: KeyCode) -> ButtonState
pub fn key(&self, key: KeyCode) -> ButtonState
Gets key state
Sourcepub fn set_key(&mut self, key: KeyCode, state: ButtonState)
pub fn set_key(&mut self, key: KeyCode, state: ButtonState)
Sets key state
Sourcepub fn primary_pointer(&self) -> Option<Vec2>
pub fn primary_pointer(&self) -> Option<Vec2>
Gets primary touch (or mouse as touch)
Sourcepub fn advance_frame(&mut self)
pub fn advance_frame(&mut self)
Advances button states after a frame
Sourcepub fn clear_touches(&mut self)
pub fn clear_touches(&mut self)
Clears all touches
Sourcepub fn is_key_pressed(&self, key: KeyCode) -> bool
pub fn is_key_pressed(&self, key: KeyCode) -> bool
Checks if a key is currently pressed (down)
Sourcepub fn set_key_pressed(&mut self, key: KeyCode, pressed: bool)
pub fn set_key_pressed(&mut self, key: KeyCode, pressed: bool)
Sets a key as pressed or released
Sourcepub fn clear_events(&mut self)
pub fn clear_events(&mut self)
Clears transient input events (advances frame states, clears touches with ended/cancelled phase)
Trait Implementations§
Source§impl Debug for InputState
impl Debug for InputState
Source§impl Default for InputState
impl Default for InputState
Source§fn default() -> InputState
fn default() -> InputState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InputState
impl RefUnwindSafe for InputState
impl Send for InputState
impl Sync for InputState
impl Unpin for InputState
impl UnwindSafe for InputState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more