Struct gilrs::Gamepad[][src]

pub struct Gamepad<'a> { /* fields omitted */ }
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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.