Skip to main content

Input

Struct Input 

Source
pub struct Input;
Expand description

Provides access to controller, keyboard, and touchscreen input.

Implementations§

Source§

impl Input

Source

pub fn is_button_down(button: Button) -> bool

Returns true if button is currently held down.

Source

pub fn is_button_pressed(button: Button) -> bool

Returns true if button was pressed this frame.

Source

pub fn is_button_released(button: Button) -> bool

Returns true if button was released this frame.

Source

pub fn get_stick_l() -> (f32, f32)

Returns the left analog stick position as (x, y) in the range [-1.0, 1.0].

Source

pub fn get_stick_r() -> (f32, f32)

Returns the right analog stick position as (x, y) in the range [-1.0, 1.0].

Source

pub fn is_connected() -> bool

Returns true if a controller is connected.

Source

pub fn get_touch() -> Option<(f32, f32)>

Returns the current touch position as Some((x, y)), or None if the screen is not touched.

Source

pub fn is_key_down(key: Key) -> bool

Returns true if key is currently held down.

Source

pub fn is_key_pressed(key: Key) -> bool

Returns true if key was pressed this frame.

Source

pub fn is_key_released(key: Key) -> bool

Returns true if key was released this frame.

Source

pub fn is_shift_down() -> bool

Returns true if either Shift key is held down.

Source

pub fn is_ctrl_down() -> bool

Returns true if either Ctrl key is held down.

Source

pub fn is_alt_down() -> bool

Returns true if either Alt key is held down.

Auto Trait Implementations§

§

impl Freeze for Input

§

impl RefUnwindSafe for Input

§

impl Send for Input

§

impl Sync for Input

§

impl Unpin for Input

§

impl UnsafeUnpin for Input

§

impl UnwindSafe for Input

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.