Struct sdl2::joystick::Joystick
[−]
[src]
pub struct Joystick { /* fields omitted */ }
Wrapper around the SDL_Joystick object
Methods
impl Joystick
[src]
fn subsystem(&self) -> &JoystickSubsystem
fn name(&self) -> String
Return the name of the joystick or an empty string if no name is found.
fn attached(&self) -> bool
Return true if the joystick has been opened and currently connected.
fn instance_id(&self) -> i32
fn guid(&self) -> Guid
Retreive the joystick's GUID
fn num_axes(&self) -> u32
Retreive the number of axes for this joystick
fn axis(&self, axis: u32) -> Result<i16, IntegerOrSdlError>
Gets the position of the given axis
.
The function will fail if the joystick doesn't have the provided axis.
Retreive the number of buttons for this joystick
Return Ok(true)
if button
is pressed.
The function will fail if the joystick doesn't have the provided button.
fn num_balls(&self) -> u32
Retreive the number of balls for this joystick
fn ball(&self, ball: u32) -> Result<(i32, i32), IntegerOrSdlError>
Return a pair (dx, dy)
containing the difference in axis
position since the last poll
fn num_hats(&self) -> u32
Retreive the number of balls for this joystick
fn hat(&self, hat: u32) -> Result<HatState, IntegerOrSdlError>
Return the position of hat
for this joystick