pub struct Gamepad { /* private fields */ }
Expand description
Wrapper around the SDL_Gamepad
object
Implementations§
Source§impl Gamepad
impl Gamepad
pub fn subsystem(&self) -> &GamepadSubsystem
Sourcepub fn name(&self) -> Option<String>
pub fn name(&self) -> Option<String>
Return the name of the controller or an empty string if no name is found.
Sourcepub fn path(&self) -> Option<String>
pub fn path(&self) -> Option<String>
Return the implementation-dependant path for an opened gamepad.
Sourcepub fn type(&self) -> GamepadType
pub fn type(&self) -> GamepadType
Return the type of an opened gamepad.
Sourcepub fn real_type(&self) -> GamepadType
pub fn real_type(&self) -> GamepadType
Return the type of an opened gamepad, ignoring any mapping override.
Sourcepub fn player_index(&self) -> Option<u16>
pub fn player_index(&self) -> Option<u16>
Return the player index of an opened gamepad.
Sourcepub fn set_player_index(&self, player_index: u16) -> Result<(), Error>
pub fn set_player_index(&self, player_index: u16) -> Result<(), Error>
Set the player index of an opened gamepad.
Sourcepub fn unset_player_index(&self) -> Result<(), Error>
pub fn unset_player_index(&self) -> Result<(), Error>
Unset the player index of an opened gamepad.
Sourcepub fn vendor_id(&self) -> Option<u16>
pub fn vendor_id(&self) -> Option<u16>
Return the USB vendor ID of an opened gamepad, if available.
Sourcepub fn product_id(&self) -> Option<u16>
pub fn product_id(&self) -> Option<u16>
Return the USB product ID of an opened gamepad, if available.
Sourcepub fn product_version(&self) -> Option<u16>
pub fn product_version(&self) -> Option<u16>
Return the product version of an opened gamepad, if available.
Sourcepub fn firmware_version(&self) -> Option<u16>
pub fn firmware_version(&self) -> Option<u16>
Return the firmware version of an opened gamepad, if available.
Sourcepub fn serial_number(&self) -> Option<String>
pub fn serial_number(&self) -> Option<String>
Return the serial number of an opened gamepad, if available.
Sourcepub fn connection_state(&self) -> Result<ConnectionState, Error>
pub fn connection_state(&self) -> Result<ConnectionState, Error>
Return the connection state of a gamepad
Sourcepub fn power_info(&self) -> PowerInfo
pub fn power_info(&self) -> PowerInfo
Return the battery state of a gamepad
Sourcepub fn mapping(&self) -> Option<String>
pub fn mapping(&self) -> Option<String>
Return a String describing the controller’s button and axis mappings
pub fn set_mapping(&mut self, mapping: &str) -> Result<(), AddMappingError>
Sourcepub fn connected(&self) -> bool
pub fn connected(&self) -> bool
Return true if the controller has been opened and currently connected.
Sourcepub fn id(&self) -> Result<JoystickId, Error>
pub fn id(&self) -> Result<JoystickId, Error>
Return the joystick id of an opened gamepad.
Return whether the gamepad has a given button.
Returns true
if button
is pressed.
Return the label of a button on this gamepad
Sourcepub fn touchpads_count(&self) -> u16
pub fn touchpads_count(&self) -> u16
Return the number of touchpads on this gamepad
Sourcepub fn supported_touchpad_fingers(&self, touchpad: u16) -> u16
pub fn supported_touchpad_fingers(&self, touchpad: u16) -> u16
Return the number of supported simultaneous fingers on a touchpad on this gamepad
Sourcepub fn set_rumble(
&mut self,
low_frequency_rumble: u16,
high_frequency_rumble: u16,
duration_ms: u32,
) -> Result<(), IntegerOrSdlError>
pub fn set_rumble( &mut self, low_frequency_rumble: u16, high_frequency_rumble: u16, duration_ms: u32, ) -> Result<(), IntegerOrSdlError>
Set the rumble motors to their specified intensities, if supported.
Automatically resets back to zero after duration_ms
milliseconds have passed.
§Notes
The value range for the intensities is 0 to 0xFFFF.
Do not use std::u32::MAX
or similar for duration_ms
if you want
the rumble effect to keep playing for a long time, as this results in
the effect ending immediately after starting due to an overflow.
Use some smaller, “huge enough” number instead.
Sourcepub fn set_rumble_triggers(
&mut self,
left_rumble: u16,
right_rumble: u16,
duration_ms: u32,
) -> Result<(), IntegerOrSdlError>
pub fn set_rumble_triggers( &mut self, left_rumble: u16, right_rumble: u16, duration_ms: u32, ) -> Result<(), IntegerOrSdlError>
Start a rumble effect in the game controller’s triggers.
Sourcepub unsafe fn has_rumble(&self) -> bool
pub unsafe fn has_rumble(&self) -> bool
Query whether a game controller has rumble support.
Sourcepub unsafe fn has_rumble_triggers(&self) -> bool
pub unsafe fn has_rumble_triggers(&self) -> bool
Query whether a game controller has rumble support on triggers.