Crate rusty_xinput
source ·Expand description
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
- Specify how much battery is charged for devices with battery.
- Defines type of battery used in device, if any.
- Capabilities info from the undocumented
XInputGetCapabilitiesEx
fn. - Holds information about device’s battery.
- A handle to a loaded XInput DLL.
- This wraps an
XINPUT_STATE
value and provides a more rusty (read-only) interface to the data it contains.
Enums
- The ways that a dynamic load of XInput can fail.
- Error that can be returned by functions that are not guaranteed to be present in earlier XInput versions.
- These are all the sorts of problems that can come up when you’re using the xinput system.
Constants
- GetStateEx can get this in wButton
Functions
- dynamic_load_xinputDeprecatedAttempts to dynamically load an XInput DLL and get the function pointers.
- xinput_get_gamepad_battery_informationDeprecatedSee
InputHandle::get_gamepad_battery_information
- xinput_get_headset_battery_informationDeprecatedSee
InputHandle::get_headset_battery_information
- xinput_get_stateDeprecatedSee
XInputHandle::get_state
- xinput_set_stateDeprecatedSee
XInputHandle::set_state