pub struct GameController { /* private fields */ }
Expand description

Wrapper around the SDL_GameController object

Implementations§

source§

impl GameController

source

pub fn subsystem(&self) -> &GameControllerSubsystem

source

pub fn name(&self) -> String

Return the name of the controller or an empty string if no name is found.

source

pub fn mapping(&self) -> String

Return a String describing the controller’s button and axis mappings

source

pub fn attached(&self) -> bool

Return true if the controller has been opened and currently connected.

source

pub fn instance_id(&self) -> u32

Return the joystick instance id of this controller

source

pub fn axis(&self, axis: Axis) -> i16

Get the position of the given axis

source

pub fn button(&self, button: Button) -> bool

Returns true if button is pressed.

source

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.

source

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.

source

pub fn has_led(&self) -> bool

Query whether a game controller has an LED.

source

pub fn has_rumble(&self) -> bool

Query whether a game controller has rumble support.

source

pub fn has_rumble_triggers(&self) -> bool

Query whether a game controller has rumble support on triggers.

source

pub fn set_led( &mut self, red: u8, green: u8, blue: u8 ) -> Result<(), IntegerOrSdlError>

Update a game controller’s LED color.

source

pub fn send_effect(&mut self, data: &[u8]) -> Result<(), String>

Send a controller specific effect packet.

Trait Implementations§

source§

impl Drop for GameController

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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>,

§

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>,

§

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.