pub struct InputState {Show 18 fields
pub keys_pressed: HashSet<Key>,
pub keys_just_pressed: HashSet<Key>,
pub keys_just_released: HashSet<Key>,
pub mouse_x: f32,
pub mouse_y: f32,
pub mouse_delta: Vec2,
pub mouse_ndc: Vec2,
pub mouse_left: bool,
pub mouse_left_just_pressed: bool,
pub mouse_left_just_released: bool,
pub mouse_right: bool,
pub mouse_right_just_pressed: bool,
pub mouse_right_just_released: bool,
pub mouse_middle: bool,
pub mouse_middle_just_pressed: bool,
pub scroll_delta: f32,
pub window_resized: Option<(u32, u32)>,
pub quit_requested: bool,
}Expand description
Complete snapshot of all input this frame.
Created and updated by the Pipeline each frame. Game code receives a
&mut ProofEngine whose .input field holds this value.
Fields§
§keys_pressed: HashSet<Key>All keys currently held down.
keys_just_pressed: HashSet<Key>Keys that transitioned to pressed this frame.
keys_just_released: HashSet<Key>Keys that transitioned to released this frame.
mouse_x: f32Cursor X in window pixels (top-left origin).
mouse_y: f32Cursor Y in window pixels (top-left origin).
mouse_delta: Vec2Mouse movement since last frame, in pixels.
mouse_ndc: Vec2Cursor in normalized device coordinates ([-1, 1], Y-up).
mouse_left: bool§mouse_left_just_pressed: bool§mouse_left_just_released: bool§mouse_right: bool§mouse_right_just_pressed: bool§mouse_right_just_released: bool§mouse_middle: bool§mouse_middle_just_pressed: bool§scroll_delta: f32Vertical scroll delta this frame (positive = scroll up / zoom in).
window_resized: Option<(u32, u32)>Set if the window was resized this frame. Contains (width, height).
quit_requested: boolSet if the user requested a quit (Alt+F4, OS close button).
Implementations§
Source§impl InputState
impl InputState
pub fn new() -> Self
Sourcepub fn is_pressed(&self, key: Key) -> bool
pub fn is_pressed(&self, key: Key) -> bool
Returns true while the key is held down.
Sourcepub fn just_pressed(&self, key: Key) -> bool
pub fn just_pressed(&self, key: Key) -> bool
Returns true on the frame the key was first pressed.
Sourcepub fn just_released(&self, key: Key) -> bool
pub fn just_released(&self, key: Key) -> bool
Returns true on the frame the key was released.
Sourcepub fn any_pressed(&self, keys: &[Key]) -> bool
pub fn any_pressed(&self, keys: &[Key]) -> bool
Returns true if any of the given keys are held.
Sourcepub fn all_pressed(&self, keys: &[Key]) -> bool
pub fn all_pressed(&self, keys: &[Key]) -> bool
Returns true if all of the given keys are held simultaneously.
pub fn ctrl(&self) -> bool
pub fn alt(&self) -> bool
Sourcepub fn mouse_left_down(&self) -> bool
pub fn mouse_left_down(&self) -> bool
Returns true while the left mouse button is held.
Sourcepub fn mouse_left_click(&self) -> bool
pub fn mouse_left_click(&self) -> bool
Returns true on the frame the left button was first pressed.
Sourcepub fn mouse_right_down(&self) -> bool
pub fn mouse_right_down(&self) -> bool
Returns true while the right mouse button is held.
Sourcepub fn mouse_right_click(&self) -> bool
pub fn mouse_right_click(&self) -> bool
Returns true on the frame the right button was first pressed.
Sourcepub fn mouse_drag(&self) -> bool
pub fn mouse_drag(&self) -> bool
Returns true if the mouse is being dragged with the left button held.
Sourcepub fn mouse_delta_ndc(&self, window_width: u32, window_height: u32) -> Vec2
pub fn mouse_delta_ndc(&self, window_width: u32, window_height: u32) -> Vec2
Returns the mouse delta scaled to NDC space (suitable for camera control).
Sourcepub fn wasd(&self) -> Vec2
pub fn wasd(&self) -> Vec2
Returns a movement vector from WASD keys: (right, up) in [-1, 1].
W/S → Y axis, A/D → X axis.
Sourcepub fn clear_frame(&mut self)
pub fn clear_frame(&mut self)
Clear all per-frame transient state. Called by the pipeline before processing events.
Trait Implementations§
Source§impl Clone for InputState
impl Clone for InputState
Source§fn clone(&self) -> InputState
fn clone(&self) -> InputState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for InputState
impl Default for InputState
Source§fn default() -> InputState
fn default() -> InputState
Auto Trait Implementations§
impl Freeze for InputState
impl RefUnwindSafe for InputState
impl Send for InputState
impl Sync for InputState
impl Unpin for InputState
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.