#[repr(C)]pub struct Gamepad { /* private fields */ }
Expand description
An individual gamepad allowing access to information about button presses, thumbstick positions and its gamepad id.
A gamepad can be obtained using either Gamepads::all() to loop through all connected gamepads, or Gamepads::get(gamepad_id) to get it by an id.
Implementations§
source§impl Gamepad
impl Gamepad
sourcepub const fn id(&self) -> GamepadId
pub const fn id(&self) -> GamepadId
An id unique for each gamepad currently connected to the system.
This can be used to distinguish multiple controllers; a gamepad that is disconnected and reconnected will retain the same id.
sourcepub const fn left_stick(&self) -> (f32, f32)
pub const fn left_stick(&self) -> (f32, f32)
The (x, y)
position of the left thumbstick.
Each component is in the range [-1.0, 1.0]
, with
negative values representing down or to the left.
sourcepub const fn left_stick_x(&self) -> f32
pub const fn left_stick_x(&self) -> f32
The x
position of the left thumbstick.
Values are in the range [-1.0, 1.0]
, with
negative values representing left.
sourcepub const fn left_stick_y(&self) -> f32
pub const fn left_stick_y(&self) -> f32
The y
position of the left thumbstick.
Values are in the range [-1.0, 1.0]
, with
negative values representing down.
sourcepub const fn right_stick(&self) -> (f32, f32)
pub const fn right_stick(&self) -> (f32, f32)
The (x, y)
position of the right thumbstick.
Each component is in the range [-1.0, 1.0]
, with
negative values representing down or to the left.
sourcepub const fn right_stick_x(&self) -> f32
pub const fn right_stick_x(&self) -> f32
The y
position of the right thumbstick.
Values are in the range [-1.0, 1.0]
, with
negative values representing left.
sourcepub const fn right_stick_y(&self) -> f32
pub const fn right_stick_y(&self) -> f32
The y
position of the right thumbstick.
Values are in the range [-1.0, 1.0]
, with
negative values representing down.
sourcepub fn all_currently_pressed(&self) -> impl Iterator<Item = Button> + '_
pub fn all_currently_pressed(&self) -> impl Iterator<Item = Button> + '_
An iterator over all currently pressed buttons.
sourcepub fn all_just_pressed(&self) -> impl Iterator<Item = Button> + '_
pub fn all_just_pressed(&self) -> impl Iterator<Item = Button> + '_
An iterator over all just pressed buttons.
sourcepub const fn is_just_pressed(&self, button: Button) -> bool
pub const fn is_just_pressed(&self, button: Button) -> bool
Check if a button has just been pressed.
sourcepub const fn is_currently_pressed(&self, button: Button) -> bool
pub const fn is_currently_pressed(&self, button: Button) -> bool
Check if a button is currently pressed.