Struct sdl2::joystick::Joystick
[−]
[src]
pub struct Joystick { // some fields omitted }
Wrapper around the SDL_Joystick object
Methods
impl Joystick
[src]
fn open(id: i32) -> SdlResult<Joystick>
Attempt to open the joystick at number id
and return it.
fn name(&self) -> String
Return the name of the joystick or an empty string if no name is found.
fn get_attached(&self) -> bool
Return true if the joystick has been opened and currently connected.
fn get_instance_id(&self) -> i32
fn get_guid(&self) -> Guid
Retreive the joystick's GUID
fn get_num_axes(&self) -> u32
Retreive the number of axes for this joystick
fn get_axis(&self, axis: u32) -> SdlResult<i16>
Gets the position of the given axis
.
The function will fail if the joystick doesn't have the provided axis.
fn get_num_buttons(&self) -> u32
Retreive the number of buttons for this joystick
fn get_button(&self, button: u32) -> SdlResult<bool>
Return Ok(true)
if button
is pressed.
The function will fail if the joystick doesn't have the provided button.
fn get_num_balls(&self) -> u32
Retreive the number of balls for this joystick
fn get_ball(&self, ball: u32) -> SdlResult<(i32, i32)>
Return a pair (dx, dy)
containing the difference in axis
position since the last poll
fn get_num_hats(&self) -> u32
Retreive the number of balls for this joystick
fn get_hat(&self, hat: u32) -> SdlResult<HatState>
Return the position of hat
for this joystick