Describes the current state of the Xbox 360 Controller.
This structure is used by the
The specific mapping of button to game function varies depending on the game type.
The constant XINPUT_GAMEPAD_TRIGGER_THRESHOLD may be used as the value which bLeftTrigger and bRightTrigger must be greater than to register as pressed. This is optional, but often desirable. Xbox 360 Controller buttons do not manifest crosstalk.
Bitmask of the device digital buttons, as follows. A set bit indicates that the corresponding button is pressed.
Device button | Bitmask |
---|---|
0x0001 | |
0x0002 | |
0x0004 | |
0x0008 | |
0x0010 | |
0x0020 | |
0x0040 | |
0x0080 | |
0x0100 | |
0x0200 | |
0x1000 | |
0x2000 | |
0x4000 | |
0x8000 |
?
Bits that are set but not defined above are reserved, and their state is undefined.
The current value of the left trigger analog control. The value is between 0 and 255.
The current value of the right trigger analog control. The value is between 0 and 255.
Left thumbstick x-axis value. Each of the thumbstick axis members is a signed value between -32768 and 32767 describing the position of the thumbstick. A value of 0 is centered. Negative values signify down or to the left. Positive values signify up or to the right. The constants
Left thumbstick y-axis value. The value is between -32768 and 32767.
Right thumbstick x-axis value. The value is between -32768 and 32767.
Right thumbstick y-axis value. The value is between -32768 and 32767.
Retrieves the battery type and charge status of a wireless controller.
Index of the signed-in gamer associated with the device. Can be a value in the range 0?XUSER_MAX_COUNT ? 1.
Specifies which device associated with this user index should be queried. Must be
Contains information on battery type and charge state.
The type of battery. BatteryType will be one of the following values.
Value | Description |
---|---|
The device is not connected.? | |
The device is a wired device and does not have a battery.? | |
The device has an alkaline battery.? | |
The device has a nickel metal hydride battery.? | |
The device has an unknown battery type.? |
?
The charge state of the battery. This value is only valid for wireless devices with a known battery type. BatteryLevel will be one of the following values.
Value |
---|
?
A table of controller subtypes available in XInput.
Describes the capabilities of a connected controller. The
The SubType member indicates the specific subtype of controller present. Games may detect the controller subtype and tune their handling of controller input or output based on subtypes that are well suited to their game genre. For example, a car racing game might check for the presence of a wheel controller to provide finer control of the car being driven. However, titles must not disable or ignore a device based on its subtype. Subtypes not recognized by the game or for which the game is not specifically tuned should be treated as a standard Xbox 360 Controller (
Older XUSB Windows drivers report incomplete capabilities information, particularly for wireless devices. The latest XUSB Windows driver provides full support for wired and wireless devices, and more complete and accurate capabilties flags.
Retrieves a gamepad input event.
Wireless controllers are not considered active upon system startup, and calls to any of the XInput functions before a wireless controller is made active return
[in] Index of the signed-in gamer associated with the device. Can be a value in the range 0?XUSER_MAX_COUNT ? 1, or
[in] Reserved
[out] Pointer to an
Retrieves the current state of the specified controller.
Index of the user's controller. Can be a value from 0 to 3. For information about how this value is determined and how the value maps to indicators on the controller, see Multiple Controllers.
Pointer to an
If the function succeeds, the return value is
If the controller is not connected, the return value is
If the function fails, the return value is an error code defined in Winerror.h. The function does not use SetLastError to set the calling thread's last-error code.
When
Sends data to a connected controller. This function is used to activate the vibration function of a controller.
Index of the user's controller. Can be a value from 0 to 3. For information about how this value is determined and how the value maps to indicators on the controller, see Multiple Controllers.
Pointer to an
If the function succeeds, the return value is
If the controller is not connected, the return value is
If the function fails, the return value is an error code defined in WinError.h. The function does not use SetLastError to set the calling thread's last-error code.
Retrieves the capabilities and features of a connected controller.
Index of the user's controller. Can be a value in the range 0?3. For information about how this value is determined and how the value maps to indicators on the controller, see Multiple Controllers.
Input flags that identify the controller type. If this value is 0, then the capabilities of all controllers connected to the system are returned. Currently, only one value is supported:
Value | Description |
---|---|
Limit query to devices of Xbox 360 Controller type. |
?
Any value of dwflags other than the above or 0 is illegal and will result in an error break when debugging.
Pointer to an
If the function succeeds, the return value is
If the controller is not connected, the return value is
If the function fails, the return value is an error code defined in WinError.h. The function does not use SetLastError to set the calling thread's last-error code.
Sets the reporting state of XInput.
If enable is
This function is meant to be called when an application gains or loses focus (such as via WM_ACTIVATEAPP). Using this function, you will not have to change the XInput query loop in your application as neutral data will always be reported if XInput is disabled.
In a controller that supports vibration effects:
Retrieves the sound rendering and sound capture audio device IDs that are associated with the headset connected to the specified controller.
Index of the gamer associated with the device.
Windows Core Audio device ID string for render (speakers).
Size, in wide-chars, of the render device ID string buffer.
Windows Core Audio device ID string for capture (microphone).
Size, in wide-chars, of capture device ID string buffer.
If the function successfully retrieves the device IDs for render and capture, the return code is
If there is no headset connected to the controller, the function will also retrieve
If the controller port device is not physically connected, the function will return
If the function fails, it will return a valid Win32 error code.
Callers must allocate the memory for the buffers passed to
Retrieves the battery type and charge status of a wireless controller.
Index of the signed-in gamer associated with the device. Can be a value in the range 0?XUSER_MAX_COUNT ? 1.
Specifies which device associated with this user index should be queried. Must be
Pointer to an
If the function succeeds, the return value is
Retrieves a gamepad input event.
[in] Index of the signed-in gamer associated with the device. Can be a value in the range 0?XUSER_MAX_COUNT ? 1, or
[in] Reserved
[out] Pointer to an
If the function succeeds, the return value is
If no new keys have been pressed, the return value is
If the controller is not connected or the user has not activated it, the return value is
If the function fails, the return value is an error code defined in Winerror.h. The function does not use SetLastError to set the calling thread's last-error code.
Wireless controllers are not considered active upon system startup, and calls to any of the XInput functions before a wireless controller is made active return
Contains information on battery type and charge state.
The type of battery. BatteryType will be one of the following values.
Value | Description |
---|---|
The device is not connected.? | |
The device is a wired device and does not have a battery.? | |
The device has an alkaline battery.? | |
The device has a nickel metal hydride battery.? | |
The device has an unknown battery type.? |
?
The charge state of the battery. This value is only valid for wireless devices with a known battery type. BatteryLevel will be one of the following values.
Value |
---|
?
Describes the capabilities of a connected controller. The
The SubType member indicates the specific subtype of controller present. Games may detect the controller subtype and tune their handling of controller input or output based on subtypes that are well suited to their game genre. For example, a car racing game might check for the presence of a wheel controller to provide finer control of the car being driven. However, titles must not disable or ignore a device based on its subtype. Subtypes not recognized by the game or for which the game is not specifically tuned should be treated as a standard Xbox 360 Controller (
Older XUSB Windows drivers report incomplete capabilities information, particularly for wireless devices. The latest XUSB Windows driver provides full support for wired and wireless devices, and more complete and accurate capabilties flags.
Specifies keystroke data returned by
Future devices may return HID codes and virtual key values that are not supported on current devices, and are currently undefined. Applications should ignore these unexpected values.
A virtual-key code is a byte value that represents a particular physical key on the keyboard, not the character or characters (possibly none) that the key can be mapped to based on keyboard state. The keyboard state at the time a virtual key is pressed modifies the character reported. For example, VK_4 might represent a "4" or a "$", depending on the state of the SHIFT key.
A reported keyboard event includes the virtual key that caused the event, whether the key was pressed or released (or is repeating), and the state of the keyboard at the time of the event. The keyboard state includes information about whether any CTRL, ALT, or SHIFT keys are down.
If the keyboard event represents an Unicode character (for example, pressing the "A" key), the Unicode member will contain that character. Otherwise, Unicode will contain the value zero.
The valid virtual-key (VK_xxx) codes are defined in XInput.h. In addition to codes that indicate key presses, the following codes indicate controller input.
Value | Description |
---|---|
A button? | |
B button? | |
X button? | |
Y button? | |
Right shoulder button? | |
Left shoulder button? | |
Left trigger? | |
Right trigger? | |
Directional pad up? | |
Directional pad down? | |
Directional pad left? | |
Directional pad right? | |
START button? | |
BACK button? | |
Left thumbstick click? | |
Right thumbstick click? | |
Left thumbstick up? | |
Left thumbstick down? | |
Left thumbstick right? | |
Left thumbstick left? | |
Left thumbstick up and left? | |
Left thumbstick up and right? | |
Left thumbstick down and right? | |
Left thumbstick down and left? | |
Right thumbstick up? | |
Right thumbstick down? | |
Right thumbstick right? | |
Right thumbstick left? | |
Right thumbstick up and left? | |
Right thumbstick up and right? | |
Right thumbstick down and right? | |
Right thumbstick down and left? |
?
Represents the state of a controller.
The dwPacketNumber member is incremented only if the status of the controller has changed since the controller was last polled.
State packet number. The packet number indicates whether there have been any changes in the state of the controller. If the dwPacketNumber member is the same in sequentially returned
Specifies motor speed levels for the vibration function of a controller.
The left motor is the low-frequency rumble motor. The right motor is the high-frequency rumble motor. The two motors are not the same, and they create different vibration effects.
Speed of the left motor. Valid values are in the range 0 to 65,535. Zero signifies no motor use; 65,535 signifies 100 percent motor use.
Speed of the right motor. Valid values are in the range 0 to 65,535. Zero signifies no motor use; 65,535 signifies 100 percent motor use.