[−][src]Struct gilrs::Gamepad
Represents handle to game controller.
Using this struct you can access cached gamepad state, information about gamepad such as name or UUID and manage force feedback effects.
Methods
impl<'a> Gamepad<'a>
[src]
pub fn name(&self) -> &str
[src]
Returns the mapping name if it exists otherwise returns the os provided name.
pub fn map_name(&self) -> Option<&str>
[src]
if mapping_source()
is SdlMappings
returns the name of the mapping used by the gamepad.
Otherwise returns None
.
pub fn os_name(&self) -> &str
[src]
Returns the name of the gamepad supplied by the OS.
pub fn uuid(&self) -> [u8; 16]
[src]
Returns gamepad's UUID.
It is recommended to process with the UUID crate.
Use Uuid::from_bytes
method to create a Uuid
from the returned bytes.
pub fn state(&self) -> &GamepadState
[src]
Returns cached gamepad state.
pub fn is_connected(&self) -> bool
[src]
Returns true if gamepad is connected.
pub fn is_pressed(&self, btn: Button) -> bool
[src]
Examines cached gamepad state to check if given button is pressed. Panics if btn
is
Unknown
.
If you know Code
of the element that you want to examine, it's recommended to use methods
directly on State
, because this version have to check which Code
is mapped to element of
gamepad.
pub fn value(&self, axis: Axis) -> f32
[src]
Examines cached gamepad state to check axis's value. Panics if axis
is Unknown
.
If you know Code
of the element that you want to examine, it's recommended to use methods
directly on State
, because this version have to check which Code
is mapped to element of
gamepad.
pub fn button_data(&self, btn: Button) -> Option<&ButtonData>
[src]
Returns button state and when it changed.
If you know Code
of the element that you want to examine, it's recommended to use methods
directly on State
, because this version have to check which Code
is mapped to element of
gamepad.
pub fn axis_data(&self, axis: Axis) -> Option<&AxisData>
[src]
Returns axis state and when it changed.
If you know Code
of the element that you want to examine, it's recommended to use methods
directly on State
, because this version have to check which Code
is mapped to element of
gamepad.
pub fn power_info(&self) -> PowerInfo
[src]
Returns device's power supply state. See PowerInfo
for details.
pub fn mapping_source(&self) -> MappingSource
[src]
Returns source of gamepad mapping. Can be used to filter gamepads which do not provide unified controller layout.
use gilrs::MappingSource; for (_, gamepad) in gilrs.gamepads().filter( |gp| gp.1.mapping_source() != MappingSource::None) { println!("{} is ready to use!", gamepad.name()); }
pub fn is_ff_supported(&self) -> bool
[src]
Returns true if force feedback is supported by device.
pub fn set_listener_position<Vec3: Into<[f32; 3]>>(
&self,
position: Vec3
) -> Result<(), FfError>
[src]
&self,
position: Vec3
) -> Result<(), FfError>
Change gamepad position used by force feedback effects.
pub fn axis_or_btn_name(&self, ec: Code) -> Option<AxisOrBtn>
[src]
Returns AxisOrBtn
mapped to Code
.
pub fn button_code(&self, btn: Button) -> Option<Code>
[src]
Returns Code
associated with btn
.
pub fn axis_code(&self, axis: Axis) -> Option<Code>
[src]
Returns Code
associated with axis
.
pub fn deadzone(&self, axis: Code) -> Option<f32>
[src]
Returns area in which axis events should be ignored.
pub fn id(&self) -> GamepadId
[src]
Returns ID of gamepad.
Trait Implementations
impl<'a> Clone for Gamepad<'a>
[src]
fn clone(&self) -> Gamepad<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> Copy for Gamepad<'a>
[src]
impl<'a> Debug for Gamepad<'a>
[src]
Auto Trait Implementations
impl<'a> !Sync for Gamepad<'a>
impl<'a> !Send for Gamepad<'a>
impl<'a> Unpin for Gamepad<'a>
impl<'a> !RefUnwindSafe for Gamepad<'a>
impl<'a> !UnwindSafe for Gamepad<'a>
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,