pub struct InputState { /* private fields */ }Expand description
Tracks the current state of all input devices (keyboard, mouse, touch) for a single game frame. The state should be updated by event handlers and cleared of per-frame data at the end of each frame.
Implementations§
Source§impl InputState
Implements input state management for InputState.
impl InputState
Implements input state management for InputState.
Sourcepub fn press_key(&mut self, key_code: String)
pub fn press_key(&mut self, key_code: String)
Records a key press event, adding to keys_pressed and keys_held.
§Arguments
String- The key code string (e.g.,"KeyA","Space").
Sourcepub fn release_key(&mut self, key_code: String)
pub fn release_key(&mut self, key_code: String)
Records a key release event, moving from keys_held to keys_released.
§Arguments
String- The key code string.
Sourcepub fn is_key_pressed(&self, key_code: &str) -> bool
pub fn is_key_pressed(&self, key_code: &str) -> bool
Sourcepub fn is_key_held(&self, key_code: &str) -> bool
pub fn is_key_held(&self, key_code: &str) -> bool
Sourcepub fn is_key_released(&self, key_code: &str) -> bool
pub fn is_key_released(&self, key_code: &str) -> bool
Records a mouse button press at the given position.
§Arguments
MouseButton- The button that was pressed.Vector2D- The mouse position.
Sourcepub fn update_mouse_position(&mut self, position: Vector2D)
pub fn update_mouse_position(&mut self, position: Vector2D)
Updates the mouse position and computes the delta from the previous position.
§Arguments
Vector2D- The new mouse position.
Sourcepub fn update_touch(&mut self, identifier: i32, position: Vector2D)
pub fn update_touch(&mut self, identifier: i32, position: Vector2D)
Adds or updates a touch point.
§Arguments
i32- The touch identifier.Vector2D- The touch position.
Sourcepub fn start_touch(&mut self, identifier: i32, position: Vector2D)
pub fn start_touch(&mut self, identifier: i32, position: Vector2D)
Records a new touch point that started this frame.
§Arguments
i32- The touch identifier.Vector2D- The touch position.
Source§impl InputState
impl InputState
pub fn get_keys_pressed(&self) -> &KeyStateSet
pub fn set_keys_pressed(&mut self, val: KeyStateSet) -> &mut Self
pub fn get_keys_held(&self) -> &KeyStateSet
pub fn set_keys_held(&mut self, val: KeyStateSet) -> &mut Self
pub fn get_keys_released(&self) -> &KeyStateSet
pub fn set_keys_released(&mut self, val: KeyStateSet) -> &mut Self
pub fn get_mouse_position(&self) -> Vector2D
pub fn set_mouse_position(&mut self, val: Vector2D) -> &mut Self
pub fn get_mouse_delta(&self) -> Vector2D
pub fn set_mouse_delta(&mut self, val: Vector2D) -> &mut Self
pub fn get_mouse_moved(&self) -> bool
pub fn set_mouse_moved(&mut self, val: bool) -> &mut Self
pub fn get_touch_points(&self) -> &TouchPointMap
pub fn set_touch_points(&mut self, val: TouchPointMap) -> &mut Self
pub fn get_touch_started(&self) -> &HashSet<i32>
pub fn set_touch_started(&mut self, val: HashSet<i32>) -> &mut Self
pub fn get_touch_ended(&self) -> &HashSet<i32>
pub fn set_touch_ended(&mut self, val: HashSet<i32>) -> &mut Self
Source§impl InputState
impl InputState
Trait Implementations§
Source§impl Clone for InputState
impl Clone for InputState
Source§fn clone(&self) -> InputState
fn clone(&self) -> InputState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InputState
impl Debug for InputState
Source§impl Default for InputState
Implements Default for InputState as a fresh empty state.
impl Default for InputState
Implements Default for InputState as a fresh empty state.
Source§fn default() -> InputState
fn default() -> InputState
Returns the “default value” for a type. Read more
Source§impl PartialEq for InputState
impl PartialEq for InputState
Source§fn eq(&self, other: &InputState) -> bool
fn eq(&self, other: &InputState) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for 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
Mutably borrows from an owned value. Read more