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
impl GamepadData
fn new( id: GamepadId, tx: Sender<Message>, gamepad: &Gamepad, db: &MappingDb, ) -> Self
Sourcepub fn map_name(&self) -> Option<&str>
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().
Sourcepub fn is_pressed(&self, btn: Button) -> bool
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.
Sourcepub fn value(&self, axis: Axis) -> f32
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.
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.
Sourcepub fn axis_data(&self, axis: Axis) -> Option<&AxisData>
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.
Sourcepub fn axis_or_btn_name(&self, ec: Code) -> Option<AxisOrBtn>
pub fn axis_or_btn_name(&self, ec: Code) -> Option<AxisOrBtn>
Returns AxisOrBtn mapped to Code.
Returns Code associated with btn.