Struct gilrs::gamepad::GamepadData

source ·
pub(crate) struct GamepadData {
    state: GamepadState,
    mapping: Mapping,
    tx: Sender<Message>,
    id: GamepadId,
    pub(crate) have_sent_nonzero_for_axis: [bool; 6],
}

Fields§

§state: GamepadState§mapping: Mapping§tx: Sender<Message>§id: GamepadId§have_sent_nonzero_for_axis: [bool; 6]

Implementations§

source§

impl GamepadData

source

fn new( id: GamepadId, tx: Sender<Message>, gamepad: &Gamepad, db: &MappingDb, ) -> Self

source

pub fn map_name(&self) -> Option<&str>

if mapping_source() is SdlMappings returns the name of the mapping used by the gamepad. Otherwise returns None.

Warning: Mappings are set after event Connected is processed therefore this function will always return None before first calls to Gilrs::next_event().

source

pub fn is_pressed(&self, btn: Button) -> bool

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.

source

pub fn value(&self, axis: Axis) -> f32

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.

source

pub fn button_data(&self, btn: Button) -> Option<&ButtonData>

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.

source

pub fn axis_data(&self, axis: Axis) -> Option<&AxisData>

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.

source

pub fn axis_or_btn_name(&self, ec: Code) -> Option<AxisOrBtn>

Returns AxisOrBtn mapped to Code.

source

pub fn button_code(&self, btn: Button) -> Option<Code>

Returns Code associated with btn.

source

pub fn axis_code(&self, axis: Axis) -> Option<Code>

Returns Code associated with axis.

Trait Implementations§

source§

impl Debug for GamepadData

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.