pub struct InputState { /* private fields */ }Implementations§
Source§impl InputState
impl InputState
pub fn new() -> Self
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Call at the start of each frame to clear “just pressed/released” states
Sourcepub fn on_key_pressed(&mut self, key_code: KeyCode)
pub fn on_key_pressed(&mut self, key_code: KeyCode)
Handle key pressed event
Sourcepub fn on_key_released(&mut self, key_code: KeyCode)
pub fn on_key_released(&mut self, key_code: KeyCode)
Handle key released event
Handle mouse button pressed
Handle mouse button released
Sourcepub fn on_cursor_moved(&mut self, x: f32, y: f32)
pub fn on_cursor_moved(&mut self, x: f32, y: f32)
Handle mouse cursor moved
Sourcepub fn on_mouse_wheel(&mut self, delta_x: f32, delta_y: f32)
pub fn on_mouse_wheel(&mut self, delta_x: f32, delta_y: f32)
Handle mouse wheel/scroll
Sourcepub fn is_key_pressed(&self, key_code: KeyCode) -> bool
pub fn is_key_pressed(&self, key_code: KeyCode) -> bool
Check if a key is currently pressed
Sourcepub fn is_key_just_pressed(&self, key_code: KeyCode) -> bool
pub fn is_key_just_pressed(&self, key_code: KeyCode) -> bool
Check if a key was just pressed this frame
Sourcepub fn is_key_just_released(&self, key_code: KeyCode) -> bool
pub fn is_key_just_released(&self, key_code: KeyCode) -> bool
Check if a key was just released this frame
Sourcepub fn mouse_position(&self) -> (f32, f32)
pub fn mouse_position(&self) -> (f32, f32)
Get mouse position
Sourcepub fn mouse_delta(&self) -> (f32, f32)
pub fn mouse_delta(&self) -> (f32, f32)
Get mouse delta (change in position this frame)
Check if a mouse button is currently pressed
Check if a mouse button was just pressed this frame
Sourcepub fn mouse_scroll(&self) -> (f32, f32)
pub fn mouse_scroll(&self) -> (f32, f32)
Get mouse scroll delta for this frame
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more