[][src]Crate rusty_xinput

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

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 XINPUT_STATE value and provides a more rusty (read-only) interface to the data it contains.

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_xinputDeprecated

Attempts to dynamically load an XInput DLL and get the function pointers.

xinput_get_gamepad_battery_informationDeprecated

See InputHandle::get_gamepad_battery_information

xinput_get_headset_battery_informationDeprecated

See InputHandle::get_headset_battery_information

xinput_get_stateDeprecated

See XInputHandle::get_state

xinput_set_stateDeprecated

See XInputHandle::set_state