[−][src]Struct sdl2::joystick::Joystick
Wrapper around the SDL_Joystick
object
Methods
impl Joystick
[src]
pub const fn subsystem(&self) -> &JoystickSubsystem
[src]
pub fn name(&self) -> String
[src]
Return the name of the joystick or an empty string if no name is found.
pub fn attached(&self) -> bool
[src]
Return true if the joystick has been opened and currently connected.
pub fn instance_id(&self) -> u32
[src]
pub fn guid(&self) -> Guid
[src]
Retrieve the joystick's GUID
pub fn power_level(&self) -> Result<PowerLevel, IntegerOrSdlError>
[src]
Retrieve the battery level of this joystick
pub fn num_axes(&self) -> u32
[src]
Retrieve the number of axes for this joystick
pub fn axis(&self, axis: u32) -> Result<i16, IntegerOrSdlError>
[src]
Gets the position of the given axis
.
The function will fail if the joystick doesn't have the provided axis.
pub fn num_buttons(&self) -> u32
[src]
Retrieve the number of buttons for this joystick
pub fn button(&self, button: u32) -> Result<bool, IntegerOrSdlError>
[src]
Return Ok(true)
if button
is pressed.
The function will fail if the joystick doesn't have the provided button.
pub fn num_balls(&self) -> u32
[src]
Retrieve the number of balls for this joystick
pub fn ball(&self, ball: u32) -> Result<(i32, i32), IntegerOrSdlError>
[src]
Return a pair (dx, dy)
containing the difference in axis
position since the last poll
pub fn num_hats(&self) -> u32
[src]
Retrieve the number of balls for this joystick
pub fn hat(&self, hat: u32) -> Result<HatState, IntegerOrSdlError>
[src]
Return the position of hat
for this joystick
pub fn set_rumble(
&mut self,
low_frequency_rumble: u16,
high_frequency_rumble: u16,
duration_ms: u32
) -> Result<(), IntegerOrSdlError>
[src]
&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.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Joystick
impl !Send for Joystick
impl !Sync for Joystick
impl Unpin for Joystick
impl !UnwindSafe for Joystick
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,