Struct sdl2::GameControllerSubsystem
source · [−]pub struct GameControllerSubsystem { /* private fields */ }
Implementations
sourceimpl 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<'a>(
&self,
rw: RWops<'a>
) -> Result<i32, AddMappingError>
pub fn load_mappings_from_rw<'a>(
&self,
rw: RWops<'a>
) -> 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
sourceimpl Clone for GameControllerSubsystem
impl Clone for GameControllerSubsystem
sourcefn clone(&self) -> GameControllerSubsystem
fn clone(&self) -> GameControllerSubsystem
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for GameControllerSubsystem
impl !Send for GameControllerSubsystem
impl !Sync for GameControllerSubsystem
impl Unpin for GameControllerSubsystem
impl UnwindSafe for GameControllerSubsystem
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more