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§
- Battery
Level - Specify how much battery is charged for devices with battery.
- Battery
Type - Defines type of battery used in device, if any.
- XINPUT_
CAPABILITIES_ EX - Capabilities info from the undocumented
XInputGetCapabilitiesEx
fn. - XInput
Battery Information - Holds information about device’s battery.
- XInput
Handle - A handle to a loaded XInput DLL.
- XInput
State - This wraps an
XINPUT_STATE
value and provides a more rusty (read-only) interface to the data it contains.
Enums§
- XInput
Loading Failure - The ways that a dynamic load of XInput can fail.
- XInput
Optional FnUsage Error - Error that can be returned by functions that are not guaranteed to be present in earlier XInput versions.
- XInput
Usage Error - These are all the sorts of problems that can come up when you’re using the xinput system.
Constants§
- XINPUT_
GAMEPAD_ GUIDE - GetStateEx can get this in wButton
Functions§
- dynamic_
load_ xinput Deprecated - Attempts to dynamically load an XInput DLL and get the function pointers.
- xinput_
get_ gamepad_ battery_ information Deprecated - See
InputHandle::get_gamepad_battery_information
- xinput_
get_ headset_ battery_ information Deprecated - See
InputHandle::get_headset_battery_information
- xinput_
get_ state Deprecated - See
XInputHandle::get_state
- xinput_
set_ state Deprecated - See
XInputHandle::set_state