Struct dmc::game_input_device::GameInputDevice [] [src]

pub struct GameInputDevice<'dev> {
    pub mappings: Vec<Mapping>,
    // some fields omitted
}

A Gamepad, joystick, steering wheel, or whatever device that's reported as a game input device by the backend.

See this module's root documentation for learning how to get and properly use one.

You should drop it when it receives the Disconnected event.

Fields

The vector of mappings applied to this device.

A device has a vector of Mapping objects, each acting as a "conversion pass" for events, applied from first to last.
You are free to mutate this vector freely. Note that this vector can be initially empty, in which case no memory is allocated.

This is provided because a non-negligible number of devices/drivers are quirky and require mappings to "fix" their behaviour (this is the reason why SDL2 provides SDL_GameControllerAddMapping(), and also implicitly adds mappings based on its own little database (SDL_GameControllerDB)).

Incidentally, this might be useful to you if you want to allow your users to remap buttons and axes for your game.

Methods

impl<'dev> GameInputDevice<'dev>
[src]

Queries whether the device is still connected or not.
If it's not, you may drop this object.

You're not required to do this before every query to the device. The queries themselves return a Disconnected error when appropriate.

The returned value is not cached: every call to this function involves a roundtrip to the backend.

Query the device's current state (buttons and axes values).

This queries the whole state every time, for these reasons:

  • This is how some backends implement it;
  • Providing one method for every possible button or axis would clutter this API.

The returned state is not cached: every call to this function involves a roundtrip to the backend.

Query the device's current battery state, if relevant.

Some backends or drivers don't support this, in which case the fields are simply set to Unknown.

Get an immutable reference to the device's Info data.

This method is cheap because the data is retrieved and stored once at device initialization time (hence the get prefix).

Mutation is not allowed because it doesn't make sense for most of Info's members. Some backends partially implement this, but I don't see a proper use case for this yet, and it could be abstracted by your application.

Uploads an haptic (force feedback) effect.

Quickly plays a rumble effect.

This shortcut is provided because the RumbleEffect is the most commonly implemented and used one. Also, on some backends (eg. Microsoft's XInput), it is implemented most efficiently this way.

There's no way to query the current vibration values - you have to cache them yourself if you so wish.

Stops early the simple rumble effect played with rumble().

Returns a polling iterator over this device's event queue.

Returns a waiting iterator over this device's event queue.

Trait Implementations

impl<'dev> Debug for GameInputDevice<'dev>
[src]

Formats the value using the given formatter.

impl<'dev> Eq for GameInputDevice<'dev>
[src]

impl<'dev> PartialEq for GameInputDevice<'dev>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'dev> Drop for GameInputDevice<'dev>
[src]

A method called when the value goes out of scope. Read more