Crate rusty_xinput

source ·
Expand description

This module lets you load an XInput DLL and use it.

How To Use This

  1. Call dynamic_load_xinput(). This will attempt to load in a DLL that supports XInput. Note that the user might not have XInput installed, so be prepared to fall back to a keyboard/mouse if that happens.
  2. Call xinput_get_state(controller) to get your data. Usually you do this once at the start of each frame of the game. You can poll for controllers 0, 1, 2, or 3. If a controller is connected you’ll get Ok(data). Otherwise you’ll get some sort of Err info.
  3. Call xinput_set_state(controller, left_speed, right_speed) to set a rumble effect on the controller. As with xinput_get_state, you can select slots 0, 1, 2 or 3, and missing controllers or out of bounds selections will give an Err of some kind. Devices other than literal XBox 360 controllers have XInput drivers, but not all of them actually have rumble support, so this should be an extra not an essential.

If xinput isn’t fully loaded, a call to get_state or set_state is still entirely safe to perform, you’ll just get an Err.

Note that there are theoretically other XInput extras you might care about, but they’re only available in Windows 8+ and I use Windows 7, so oh well.

Structs

Enums

Constants

Functions