Struct riddle_input::InputSystem [−][src]
The Riddle input system core state, along with InputMainThreadState.
This stores the thread safe input state which can be queried to inspect the
status of input devices. It is updated by InputMainThreadState::process_input.
Implementations
impl InputSystem[src]
pub fn mouse_pos(&self, window: WindowId) -> LogicalPosition[src]
Query the cursor position with respect to a given window.
If no mouse position infomation is available for the given window, the position will be (0,0)
Example
// The initial mouse position is (0,0) assert_eq!(LogicalPosition{ x: 0, y: 0}, input_system.mouse_pos(window)); // The platform system emits cursor move events // [..] // The reported mouse position has changed assert_ne!(LogicalPosition{ x: 0, y: 0}, input_system.mouse_pos(window));
pub fn is_mouse_button_down(
&self,
window: WindowId,
button: MouseButton
) -> bool[src]
&self,
window: WindowId,
button: MouseButton
) -> bool
Check if the specified mouse button is down with respect to a given window.
If there is no state recorded for the mouse for the given window the result will be false
Example
// The initial mouse position is (0,0) assert_eq!(false, input_system.is_mouse_button_down(window, MouseButton::Left)); // The platform system emits cursor move events // [..] // The reported mouse position has changed assert_eq!(true, input_system.is_mouse_button_down(window, MouseButton::Left));
pub fn is_key_down(&self, window: WindowId, scancode: Scancode) -> bool[src]
Query the keyboard scancode state with respect to a given window. See
Scancode for details on what a scancode represents.
If no keyboard infomation is available for the given window, the button will be considered to not be down.
Example
// The initial key state is that the button is unpressed assert_eq!(false, input_system.is_key_down(window, Scancode::Escape)); // The platform system emits key press event // [..] // The reported key state has changed assert_eq!(true, input_system.is_key_down(window, Scancode::Escape));
pub fn is_vkey_down(&self, window: WindowId, vkey: VirtualKey) -> bool[src]
Query the keyboard virtual key state with respect to a given window. See
VirtualKey for details on what a virtual key represents.
If no keyboard infomation is available for the given window, the button will be considered to not be down.
Example
// The initial key state is that the button is unpressed assert_eq!(false, input_system.is_vkey_down(window, VirtualKey::Escape)); // The platform system emits key press event // [..] // The reported key state has changed assert_eq!(true, input_system.is_vkey_down(window, VirtualKey::Escape));
pub fn keyboard_modifiers(&self, window: WindowId) -> KeyboardModifiers[src]
The current state of keyboard modifiers with respect to a given window.
If no state has been set all modifiers are considered unset.
Example
// The initial mouse position is (0,0) assert_eq!(false, input_system.keyboard_modifiers(window).ctrl); // The platform system emits key down event for Ctrl key // [..] // The reported mouse position has changed assert_eq!(true, input_system.keyboard_modifiers(window).ctrl);
pub fn last_active_gamepad(&self) -> Option<GamePadId>[src]
Get the GamePadId of the last gamepad which issued any event.
Can be used a very simple way to pick a gamepad to consider the “active”
gamepad. Handling InputEvent::GamePadConnected and similar events
allows for more fine grained control.
Example
// The initial gamepad is None assert_eq!(None, input_system.last_active_gamepad()); // Controller button press events are processed // [..] // The reported active controller has changed assert_ne!(None, input_system.last_active_gamepad());
pub fn is_gamepad_button_down(
&self,
gamepad: GamePadId,
button: GamePadButton
) -> bool[src]
&self,
gamepad: GamePadId,
button: GamePadButton
) -> bool
Check if a specific button is pressed for a given gamepad.
If no state has been set all buttons are considered not to be down.
// The initial button state is false assert_eq!(false, input_system.is_gamepad_button_down(gamepad, GamePadButton::North)); // Controller button press events are processed // [..] // The reported button state has changed assert_eq!(true, input_system.is_gamepad_button_down(gamepad, GamePadButton::North));
pub fn gamepad_axis_value(&self, gamepad: GamePadId, axis: GamePadAxis) -> f32[src]
Get the value of a specific axis for a specific gamepad
If no state has been set all axes are considered to have value 0.0.
// The initial button state is false assert_eq!(0.0, input_system.gamepad_axis_value(gamepad, GamePadAxis::LeftStickX)); // Controller axis events are processed // [..] // The reported axis value has changed assert_ne!(0.0, input_system.gamepad_axis_value(gamepad, GamePadAxis::LeftStickX));
Trait Implementations
impl CloneHandle for InputSystem[src]
type Handle = InputSystemHandle
The type which represents a strong reference, and which may be dereferenced as Self. Read more
type WeakHandle = InputSystemWeak
The type which represents a weak reference.
fn clone_handle(&self) -> InputSystemHandle[src]
fn clone_weak_handle(&self) -> InputSystemWeak[src]
impl InputSystemExt for InputSystem[src]
fn new_shared(
sys_events: &EventPub<PlatformEvent>
) -> Result<(InputSystemHandle, InputMainThreadState), InputError>[src]
sys_events: &EventPub<PlatformEvent>
) -> Result<(InputSystemHandle, InputMainThreadState), InputError>
fn take_input_events(&self) -> Vec<InputEvent>[src]
Auto Trait Implementations
impl RefUnwindSafe for InputSystem
impl Send for InputSystem
impl Sync for InputSystem
impl Unpin for InputSystem
impl UnwindSafe for InputSystem
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,