Struct sdl2::GameControllerSubsystem
source · 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 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
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for GameControllerSubsystem
impl RefUnwindSafe for GameControllerSubsystem
impl !Send for GameControllerSubsystem
impl !Sync for GameControllerSubsystem
impl Unpin for GameControllerSubsystem
impl UnwindSafe for GameControllerSubsystem
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more