pub struct GameControllerSubsystem { /* private fields */ }
Implementations§
Source§impl GameControllerSubsystem
impl GameControllerSubsystem
Sourcepub fn num_joysticks(&self) -> Result<u32, String>
pub fn num_joysticks(&self) -> Result<u32, String>
Retrieve the total number of attached joysticks and controllers identified by SDL.
Sourcepub fn is_game_controller(&self, joystick_index: u32) -> bool
pub fn is_game_controller(&self, joystick_index: u32) -> bool
Return true if the joystick at index joystick_index
is a game controller.
Sourcepub fn open(
&self,
joystick_index: u32,
) -> Result<GameController, IntegerOrSdlError>
pub fn open( &self, joystick_index: u32, ) -> Result<GameController, IntegerOrSdlError>
Attempt to open the controller at index joystick_index
and return it.
Controller IDs are the same as joystick IDs and the maximum number can
be retrieved using the SDL_NumJoysticks
function.
Sourcepub fn name_for_index(
&self,
joystick_index: u32,
) -> Result<String, IntegerOrSdlError>
pub fn name_for_index( &self, joystick_index: u32, ) -> Result<String, IntegerOrSdlError>
Return the name of the controller at index joystick_index
.
Sourcepub fn instance_id_for_player_index(
&self,
player_index: u32,
) -> Result<Option<u32>, IntegerOrSdlError>
pub fn instance_id_for_player_index( &self, player_index: u32, ) -> Result<Option<u32>, IntegerOrSdlError>
Return the instance ID of the controller with player index player_index
.
Sourcepub fn set_event_state(&self, state: bool)
pub fn set_event_state(&self, state: bool)
If state is true
controller events are processed, otherwise
they’re ignored.
Sourcepub fn event_state(&self) -> bool
pub fn event_state(&self) -> bool
Return true
if controller events are processed.
Sourcepub fn add_mapping(
&self,
mapping: &str,
) -> Result<MappingStatus, AddMappingError>
pub fn add_mapping( &self, mapping: &str, ) -> Result<MappingStatus, AddMappingError>
Add a new controller input mapping from a mapping string.
Sourcepub fn load_mappings<P: AsRef<Path>>(
&self,
path: P,
) -> Result<i32, AddMappingError>
pub fn load_mappings<P: AsRef<Path>>( &self, path: P, ) -> Result<i32, AddMappingError>
Load controller input mappings from a file.
Sourcepub fn load_mappings_from_read<R: Read>(
&self,
read: &mut R,
) -> Result<i32, AddMappingError>
pub fn load_mappings_from_read<R: Read>( &self, read: &mut R, ) -> Result<i32, AddMappingError>
Load controller input mappings from a Read
object.
Sourcepub fn load_mappings_from_rw(
&self,
rw: RWops<'_>,
) -> Result<i32, AddMappingError>
pub fn load_mappings_from_rw( &self, rw: RWops<'_>, ) -> Result<i32, AddMappingError>
Load controller input mappings from an SDL RWops
object.
pub fn mapping_for_guid(&self, guid: Guid) -> Result<String, String>
Trait Implementations§
Source§impl Clone for GameControllerSubsystem
impl Clone for GameControllerSubsystem
Source§fn clone(&self) -> GameControllerSubsystem
fn clone(&self) -> GameControllerSubsystem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more