pub struct InputSystem { /* private fields */ }Expand description
An input system that wraps InputState and provides additional functionality.
Implementations§
Source§impl InputSystem
impl InputSystem
Sourcepub fn state(&self) -> &InputState
pub fn state(&self) -> &InputState
Get the input state.
Sourcepub fn state_mut(&mut self) -> &mut InputState
pub fn state_mut(&mut self) -> &mut InputState
Get mutable access to the input state.
Sourcepub fn handle_events(&mut self, events: &mut EventBatch)
pub fn handle_events(&mut self, events: &mut EventBatch)
Process events from the event batch.
Methods from Deref<Target = InputState>§
Sourcepub fn handle_events(&mut self, events: &mut EventBatch)
pub fn handle_events(&mut self, events: &mut EventBatch)
Process events from the event batch.
This should be called each frame before querying input state.
Sourcepub fn is_key_pressed(&self, key: KeyCode) -> bool
pub fn is_key_pressed(&self, key: KeyCode) -> bool
Check if a key is currently pressed (held down).
Sourcepub fn is_key_just_pressed(&self, key: KeyCode) -> bool
pub fn is_key_just_pressed(&self, key: KeyCode) -> bool
Check if a key was just pressed this frame.
Sourcepub fn is_key_just_released(&self, key: KeyCode) -> bool
pub fn is_key_just_released(&self, key: KeyCode) -> bool
Check if a key was just released this frame.
Sourcepub fn is_any_key_pressed(&self, keys: &[KeyCode]) -> bool
pub fn is_any_key_pressed(&self, keys: &[KeyCode]) -> bool
Check if any of the given keys are pressed.
Sourcepub fn are_all_keys_pressed(&self, keys: &[KeyCode]) -> bool
pub fn are_all_keys_pressed(&self, keys: &[KeyCode]) -> bool
Check if all of the given keys are pressed.
Sourcepub fn is_shift_pressed(&self) -> bool
pub fn is_shift_pressed(&self) -> bool
Check if Shift is held.
Sourcepub fn is_ctrl_pressed(&self) -> bool
pub fn is_ctrl_pressed(&self) -> bool
Check if Ctrl (or Cmd on macOS) is held.
Sourcepub fn is_alt_pressed(&self) -> bool
pub fn is_alt_pressed(&self) -> bool
Check if Alt (or Option on macOS) is held.
Sourcepub fn is_meta_pressed(&self) -> bool
pub fn is_meta_pressed(&self) -> bool
Check if Meta (Windows key or Cmd on macOS) is held.
Sourcepub fn text_input(&self) -> &str
pub fn text_input(&self) -> &str
Get text input received this frame.
Sourcepub fn pressed_keys(&self) -> impl Iterator<Item = &KeyCode>
pub fn pressed_keys(&self) -> impl Iterator<Item = &KeyCode>
Get all keys currently pressed.
Check if a mouse button is currently pressed.
Check if a mouse button was just pressed this frame.
Check if a mouse button was just released this frame.
Sourcepub fn is_left_mouse_pressed(&self) -> bool
pub fn is_left_mouse_pressed(&self) -> bool
Check if left mouse button is pressed.
Sourcepub fn is_left_mouse_just_pressed(&self) -> bool
pub fn is_left_mouse_just_pressed(&self) -> bool
Check if left mouse button was just pressed.
Sourcepub fn is_right_mouse_pressed(&self) -> bool
pub fn is_right_mouse_pressed(&self) -> bool
Check if right mouse button is pressed.
Sourcepub fn is_right_mouse_just_pressed(&self) -> bool
pub fn is_right_mouse_just_pressed(&self) -> bool
Check if right mouse button was just pressed.
Sourcepub fn is_middle_mouse_pressed(&self) -> bool
pub fn is_middle_mouse_pressed(&self) -> bool
Check if middle mouse button is pressed.
Sourcepub fn mouse_position(&self) -> Vec2
pub fn mouse_position(&self) -> Vec2
Get the current mouse position in window coordinates.
Sourcepub fn mouse_delta(&self) -> Vec2
pub fn mouse_delta(&self) -> Vec2
Get the mouse movement delta since last frame.
Sourcepub fn scroll_delta(&self) -> Vec2
pub fn scroll_delta(&self) -> Vec2
Get the scroll wheel delta since last frame.
Positive Y = scroll up, Negative Y = scroll down.
Sourcepub fn is_mouse_in_window(&self) -> bool
pub fn is_mouse_in_window(&self) -> bool
Check if the mouse cursor is inside the window.
Sourcepub fn horizontal_axis(&self) -> f32
pub fn horizontal_axis(&self) -> f32
Get horizontal input axis (-1, 0, or 1) from arrow keys or WASD.
Sourcepub fn vertical_axis(&self) -> f32
pub fn vertical_axis(&self) -> f32
Get vertical input axis (-1, 0, or 1) from arrow keys or WASD.
Sourcepub fn movement_direction(&self) -> Vec2
pub fn movement_direction(&self) -> Vec2
Get movement direction as a normalized vector.
Trait Implementations§
Source§impl Default for InputSystem
impl Default for InputSystem
Source§impl Deref for InputSystem
impl Deref for InputSystem
Auto Trait Implementations§
impl Freeze for InputSystem
impl RefUnwindSafe for InputSystem
impl Send for InputSystem
impl Sync for InputSystem
impl Unpin for InputSystem
impl UnsafeUnpin for InputSystem
impl UnwindSafe for InputSystem
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
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>
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>
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)
&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)
&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>
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>
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