pub struct InputState { /* private fields */ }
Expand description
Input abstraction that collects input state from events.
Unlike Key::is_pressed(), events only trigger if the window is focused
Implementations§
Source§impl InputState
impl InputState
Sourcepub fn start_frame(&mut self)
pub fn start_frame(&mut self)
Call at start of frame to clear “pressed” state
Sourcepub fn update_from_event(&mut self, event: &Event)
pub fn update_from_event(&mut self, event: &Event)
Update from an Event
. Use this in your event polling loop.
Sourcepub fn mouse_down(&self, button: Button) -> bool
pub fn mouse_down(&self, button: Button) -> bool
Returns whether button
is being held down
Sourcepub fn mouse_pressed(&self, button: Button) -> bool
pub fn mouse_pressed(&self, button: Button) -> bool
Returns whether button
was pressed this frame
Trait Implementations§
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