pub struct Gamepads { /* private fields */ }
Expand description
Context for obtaining gamepad information.
Construct an instance using Gamepads::new.
On each tick, update gamepads state using Gamepads::poll().
Then use Gamepads::all() to list all connected gamepads, or Gamepads::get(gamepad_id) to get a gamepad by id.
Implementations§
source§impl Gamepads
impl Gamepads
sourcepub fn get(&self, gamepad_id: GamepadId) -> Option<Gamepad>
pub fn get(&self, gamepad_id: GamepadId) -> Option<Gamepad>
Get a gamepad by id, returning None
if it is no longer connected.
The gamepad state obtained here will reflect the state the last time Gamepads::poll() was called.
sourcepub fn all(&self) -> impl Iterator<Item = Gamepad>
pub fn all(&self) -> impl Iterator<Item = Gamepad>
Retrieve information about all connected gamepads.
The gamepad state obtained here will reflect the state the last time Gamepads::poll() was called.
sourcepub fn rumble(
&mut self,
gamepad_id: GamepadId,
duration_ms: u32,
start_delay_ms: u32,
strong_magnitude: f32,
weak_magnitude: f32
)
pub fn rumble( &mut self, gamepad_id: GamepadId, duration_ms: u32, start_delay_ms: u32, strong_magnitude: f32, weak_magnitude: f32 )
Provide haptic feedback by rumbling the gamepad (if supported).
This is a “dual rumble”, where an eccentric rotating mass (ERM) vibration motor in each handle of the gamepad. Either motor is capable of vibrating the whole gamepad. The vibration effects created by each motor are unequal so that the effects of each can be combined to create more complex haptic effects.
Arguments
gamepad_id
- ID of the gamepad to rumbleduration_ms
- Duration of the rumble in millisecondsstart_delay_ms
- Delay of the rumble in millisecondsstrong_magnitude
- The vibration magnitude for the low frequency rumble in the range[0.0, 1.0]
weak_magnitude
- The vibration magnitude for the high frequency rumble in the range[0.0, 1.0]