pub struct Gamepad<'a> { /* private fields */ }
Expand description

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.

Implementations

Returns the mapping name if it exists otherwise returns the os provided name.

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

Returns the name of the gamepad supplied by the OS.

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.

Returns cached gamepad state.

Returns true if gamepad is connected.

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.

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.

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.

Returns device’s power supply state. See PowerInfo for details.

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());
}

Returns true if force feedback is supported by device.

Change gamepad position used by force feedback effects.

Returns AxisOrBtn mapped to Code.

Returns Code associated with btn.

Returns Code associated with axis.

Returns area in which axis events should be ignored.

Returns ID of gamepad.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Method to retrieve the context type.
Method to retrieve the context type as mutable.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.