pub struct InputState {
pub mouse_x: i32,
pub mouse_y: i32,
pub last_key_down: Option<VmKey>,
pub last_mouse_down: Option<VmMouseButton>,
/* private fields */
}Fields§
§mouse_x: i32§mouse_y: i32§last_key_down: Option<VmKey>Last key-down event since start.
last_mouse_down: Option<VmMouseButton>Last mouse-down event since start.
Implementations§
Source§impl InputState
impl InputState
Sourcepub fn vk_is_down(&self, vk: u8) -> bool
pub fn vk_is_down(&self, vk: u8) -> bool
Returns true if the given virtual-key is currently held down.
Sourcepub fn vk_down_stock(&self, vk: u8) -> bool
pub fn vk_down_stock(&self, vk: u8) -> bool
Returns true if the key transitioned to down since the last next_frame.
Sourcepub fn vk_up_stock(&self, vk: u8) -> bool
pub fn vk_up_stock(&self, vk: u8) -> bool
Returns true if the key transitioned to up since the last next_frame.
Sourcepub fn vk_down_up_stock(&self, vk: u8) -> bool
pub fn vk_down_up_stock(&self, vk: u8) -> bool
Returns true if a down+up pair happened since the last next_frame.
Sourcepub fn vk_flick_stock(&self, vk: u8) -> bool
pub fn vk_flick_stock(&self, vk: u8) -> bool
Returns true if a flick was detected since the last next_frame.
Sourcepub fn vk_flick_angle(&self, vk: u8) -> f32
pub fn vk_flick_angle(&self, vk: u8) -> f32
Returns flick angle (radians) for the last flick on this key.
Sourcepub fn vk_flick_pixel(&self, vk: u8) -> f32
pub fn vk_flick_pixel(&self, vk: u8) -> f32
Returns flick distance in pixels for the last flick on this key.
Sourcepub fn vk_flick_mm(&self, vk: u8) -> f32
pub fn vk_flick_mm(&self, vk: u8) -> f32
Returns flick distance in millimeters for the last flick on this key.
pub fn has_mouse_position(&self) -> bool
Sourcepub fn clear_keyboard(&mut self)
pub fn clear_keyboard(&mut self)
Clears only keyboard-visible state and leaves mouse state intact.
Sourcepub fn clear_mouse(&mut self)
pub fn clear_mouse(&mut self)
Clears only mouse-visible state and leaves keyboard state intact.
Sourcepub fn use_current(&mut self)
pub fn use_current(&mut self)
Consumes current input edges while preserving held-down state.
Mirrors tona3 C_input_state::use(): clear down/up/down_up/flick stocks for mouse and keyboard plus wheel, but do not release held keys.
Sourcepub fn next_frame(&mut self)
pub fn next_frame(&mut self)
Advances to the next frame: clears edge stocks but keeps held-down state.
Sourcepub fn next_keyboard_frame(&mut self)
pub fn next_keyboard_frame(&mut self)
Advances only keyboard state to the next frame.
Sourcepub fn next_mouse_frame(&mut self)
pub fn next_mouse_frame(&mut self)
Advances only mouse state to the next frame.
pub fn on_mouse_wheel(&mut self, delta_y: i32)
Sourcepub fn take_wheel_delta(&mut self) -> i32
pub fn take_wheel_delta(&mut self) -> i32
Reads and clears the accumulated wheel delta.
pub fn is_key_down(&self, k: VmKey) -> bool
pub fn is_mouse_down(&self, b: VmMouseButton) -> bool
pub fn on_key_down(&mut self, k: VmKey)
pub fn on_key_up(&mut self, k: VmKey)
pub fn on_mouse_down(&mut self, b: VmMouseButton)
pub fn on_mouse_up(&mut self, b: VmMouseButton)
pub fn on_mouse_move(&mut self, x: i32, y: i32)
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 Debug for InputState
impl Debug 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.