[−][src]Crate rusty_xinput
This module lets you load an XInput DLL and use it.
How To Use This
- 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. - 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 getOk(data)
. Otherwise you'll get some sort ofErr
info. - Call
xinput_set_state(controller, left_speed, right_speed)
to set a rumble effect on the controller. As withxinput_get_state
, you can select slots 0, 1, 2 or 3, and missing controllers or out of bounds selections will give anErr
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
BatteryLevel | Specify how much battery is charged for devices with battery. |
BatteryType | Defines type of battery used in device, if any. |
XInputBatteryInformation | Holds information about device's battery. |
XInputHandle | A handle to a loaded XInput DLL. |
XInputState | This wraps an |
Enums
XInputLoadingFailure | The ways that a dynamic load of XInput can fail. |
XInputOptionalFnUsageError | Error that can be returned by functions that are not guaranteed to be present in earlier XInput versions. |
XInputUsageError | These are all the sorts of problems that can come up when you're using the xinput system. |
Functions
dynamic_load_xinput | Deprecated Attempts to dynamically load an XInput DLL and get the function pointers. |
xinput_get_gamepad_battery_information | Deprecated See |
xinput_get_headset_battery_information | Deprecated See |
xinput_get_state | Deprecated See |
xinput_set_state | Deprecated See |