[−][src]Struct riddle_input::InputSystemHandle
Implementations
impl InputSystemHandle
[src]
pub fn downgrade(this: &InputSystemHandle) -> InputSystemWeak
[src]
Downgrade this handle to a weak handle
pub fn eq(a: &InputSystemHandle, b: &InputSystemHandle) -> bool
[src]
Test whether two handles point to the same location in memory
Methods from Deref<Target = InputSystem>
pub fn take_input_events(&self) -> Vec<InputEvent>
[src]
Collect any buffered InputEvent
s emitted by the input system.
This clears the system's buffer, so should only be called from a single location.
Do not call this if you are using riddle
. riddle
manages taking these
events and passing them to the main application closure.
Example
let platform_events: EventPub<PlatformEvent> = EventPub::new(); let (input_system, mut main_thread_state) = InputSystem::new(&platform_events)?; // Platform dispatches an event, and input processes it platform_events.dispatch(PlatformEvent::MouseButtonDown{ window: WindowId::new(0), button: MouseButton::Left}); main_thread_state.process_input(); // Having processed the incoming platform event, there is now an InputEvent available let input_events: Vec<InputEvent> = input_system.take_input_events(); assert_eq!(vec![InputEvent::MouseButtonDown{ window: WindowId::new(0), button: MouseButton::Left }], input_events);
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_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 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));
Trait Implementations
impl Clone for InputSystemHandle
[src]
fn clone(&self) -> InputSystemHandle
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Deref for InputSystemHandle
[src]
type Target = InputSystem
The resulting type after dereferencing.
fn deref(&self) -> &InputSystem
[src]
Auto Trait Implementations
impl RefUnwindSafe for InputSystemHandle
impl Send for InputSystemHandle
impl Sync for InputSystemHandle
impl Unpin for InputSystemHandle
impl UnwindSafe for InputSystemHandle
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,
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,