#[repr(C)]pub struct GamepadState {
pub id: GamepadId,
pub connected: bool,
pub buttons: u32,
pub left_stick_x: f32,
pub left_stick_y: f32,
pub right_stick_x: f32,
pub right_stick_y: f32,
pub left_z: f32,
pub right_z: f32,
}Expand description
Snapshot of one gamepad’s state. Buttons are a bitset (bit n = the
GamepadButton with discriminant n); axes are explicit fields. All
POD / Copy, so it crosses the FFI by value.
Fields§
§id: GamepadIdWhich pad this snapshot is for.
connected: boolfalse once the pad disconnects (the manager keeps the last slot so
a callback can observe the disconnect).
Pressed-button bitset — bit n set ⇔ the GamepadButton with
discriminant n is held. Read via GamepadState::is_pressed.
left_stick_x: f32Left stick X in [-1, 1].
left_stick_y: f32Left stick Y in [-1, 1].
right_stick_x: f32Right stick X in [-1, 1].
right_stick_y: f32Right stick Y in [-1, 1].
left_z: f32Left trigger pressure in [0, 1].
right_z: f32Right trigger pressure in [0, 1].
Implementations§
Source§impl GamepadState
impl GamepadState
Sourcepub const fn empty(id: GamepadId) -> GamepadState
pub const fn empty(id: GamepadId) -> GamepadState
An empty (disconnected) state for id — all buttons up, axes zero.
Sourcepub const fn is_pressed(&self, button: GamepadButton) -> bool
pub const fn is_pressed(&self, button: GamepadButton) -> bool
Whether button is currently held.
Sourcepub const fn axis(&self, axis: GamepadAxis) -> f32
pub const fn axis(&self, axis: GamepadAxis) -> f32
The current value of axis (sticks [-1, 1], triggers [0, 1]).
Trait Implementations§
Source§impl Clone for GamepadState
impl Clone for GamepadState
Source§fn clone(&self) -> GamepadState
fn clone(&self) -> GamepadState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for GamepadState
Source§impl Debug for GamepadState
impl Debug for GamepadState
Source§impl PartialEq for GamepadState
impl PartialEq for GamepadState
impl StructuralPartialEq for GamepadState
Auto Trait Implementations§
impl Freeze for GamepadState
impl RefUnwindSafe for GamepadState
impl Send for GamepadState
impl Sync for GamepadState
impl Unpin for GamepadState
impl UnsafeUnpin for GamepadState
impl UnwindSafe for GamepadState
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more