SharpDX.XInput The assembly provides managed XInput API. hh405053 XInput XInput A XInput controller. Initializes a new instance of the class. Index of the user. Gets the battery information. Type of the battery device. unsigned int XInputGetBatteryInformation([In] XUSER_INDEX dwUserIndex,[In] BATTERY_DEVTYPE devType,[Out] XINPUT_BATTERY_INFORMATION* pBatteryInformation) Gets the capabilities. Type of the device query. unsigned int XInputGetCapabilities([In] XUSER_INDEX dwUserIndex,[In] XINPUT_DEVQUERYTYPE dwFlags,[Out] XINPUT_CAPABILITIES* pCapabilities) Gets the keystroke. The flag. The keystroke. unsigned int XInputGetKeystroke([In] XUSER_INDEX dwUserIndex,[In] unsigned int dwReserved,[Out] XINPUT_KEYSTROKE* pKeystroke) Gets the state. Sets the reporting. if set to true [enable reporting]. Sets the vibration. The vibration. Gets a value indicating whether this instance is connected. true if this instance is connected; otherwise, false. Gets the sound render GUID. Gets the sound capture GUID. Describes the current state of the Xbox 360 Controller.

This structure is used by the structure when polling for changes in the state of the controller.

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.

microsoft.directx_sdk.reference.xinput_gamepad XINPUT_GAMEPAD XINPUT_GAMEPAD
Constant TriggerThreshold. XINPUT_GAMEPAD_TRIGGER_THRESHOLD Constant LeftThumbDeadZone. XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE Constant RightThumbDeadZone. XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE
Bitmask of the device digital buttons, as follows. A set bit indicates that the corresponding button is pressed.
#define           0x00000001	
            #define         0x00000002	
            #define         0x00000004	
            #define        0x00000008	
            #define             0x00000010	
            #define              0x00000020	
            #define        0x00000040	
            #define       0x00000080	
            #define     0x0100	
            #define    0x0200	
            #define                 0x1000	
            #define                 0x2000	
            #define                 0x4000	
            #define                 0x8000

Bits that are set but not defined above are reserved, and their state is undefined.

microsoft.directx_sdk.reference.xinput_gamepad XINPUT_GAMEPAD_BUTTON_FLAGS wButtons XINPUT_GAMEPAD_BUTTON_FLAGS wButtons
The current value of the left trigger analog control. The value is between 0 and 255.
microsoft.directx_sdk.reference.xinput_gamepad unsigned char bLeftTrigger unsigned char bLeftTrigger
The current value of the right trigger analog control. The value is between 0 and 255.
microsoft.directx_sdk.reference.xinput_gamepad unsigned char bRightTrigger unsigned char bRightTrigger
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 or can be used as a positive and negative value to filter a thumbstick input.
microsoft.directx_sdk.reference.xinput_gamepad short sThumbLX short sThumbLX
Left thumbstick y-axis value. The value is between -32768 and 32767.
microsoft.directx_sdk.reference.xinput_gamepad short sThumbLY short sThumbLY
Right thumbstick x-axis value. The value is between -32768 and 32767.
microsoft.directx_sdk.reference.xinput_gamepad short sThumbRX short sThumbRX
Right thumbstick y-axis value. The value is between -32768 and 32767.
microsoft.directx_sdk.reference.xinput_gamepad short sThumbRY short sThumbRY
No documentation. BATTERY_DEVTYPE BATTERY_DEVTYPE No documentation. BATTERY_DEVTYPE_GAMEPAD BATTERY_DEVTYPE_GAMEPAD No documentation. BATTERY_DEVTYPE_HEADSET BATTERY_DEVTYPE_HEADSET No documentation. ff561360 BATTERY_LEVEL BATTERY_LEVEL No documentation. BATTERY_LEVEL_EMPTY BATTERY_LEVEL_EMPTY No documentation. BATTERY_LEVEL_LOW BATTERY_LEVEL_LOW No documentation. BATTERY_LEVEL_MEDIUM BATTERY_LEVEL_MEDIUM No documentation. BATTERY_LEVEL_FULL BATTERY_LEVEL_FULL No documentation. BATTERY_TYPE BATTERY_TYPE No documentation. BATTERY_TYPE_DISCONNECTED BATTERY_TYPE_DISCONNECTED No documentation. BATTERY_TYPE_WIRED BATTERY_TYPE_WIRED No documentation. BATTERY_TYPE_ALKALINE BATTERY_TYPE_ALKALINE No documentation. BATTERY_TYPE_NIMH BATTERY_TYPE_NIMH No documentation. BATTERY_TYPE_UNKNOWN BATTERY_TYPE_UNKNOWN No documentation. XINPUT_CAPS_FLAGS XINPUT_CAPS_FLAGS No documentation. XINPUT_CAPS_VOICE_SUPPORTED XINPUT_CAPS_VOICE_SUPPORTED None. None None No documentation. XINPUT_DEVQUERYTYPE XINPUT_DEVQUERYTYPE No documentation. XINPUT_FLAG_GAMEPAD XINPUT_FLAG_GAMEPAD No documentation. XINPUT_FLAG_ANY XINPUT_FLAG_ANY No documentation. XINPUT_DEVSUBTYPE XINPUT_DEVSUBTYPE No documentation. XINPUT_DEVSUBTYPE_GAMEPAD XINPUT_DEVSUBTYPE_GAMEPAD No documentation. XINPUT_DEVSUBTYPE_WHEEL XINPUT_DEVSUBTYPE_WHEEL No documentation. XINPUT_DEVSUBTYPE_ARCADE_STICK XINPUT_DEVSUBTYPE_ARCADE_STICK No documentation. XINPUT_DEVSUBTYPE_FLIGHT_SICK XINPUT_DEVSUBTYPE_FLIGHT_SICK No documentation. XINPUT_DEVSUBTYPE_DANCE_PAD XINPUT_DEVSUBTYPE_DANCE_PAD No documentation. XINPUT_DEVSUBTYPE_GUITAR XINPUT_DEVSUBTYPE_GUITAR No documentation. XINPUT_DEVSUBTYPE_DRUM_KIT XINPUT_DEVSUBTYPE_DRUM_KIT No documentation. XINPUT_DEVTYPE XINPUT_DEVTYPE No documentation. XINPUT_DEVTYPE_GAMEPAD XINPUT_DEVTYPE_GAMEPAD No documentation. XINPUT_GAMEPAD_BUTTON_FLAGS XINPUT_GAMEPAD_BUTTON_FLAGS No documentation. XINPUT_GAMEPAD_DPAD_UP XINPUT_GAMEPAD_DPAD_UP No documentation. XINPUT_GAMEPAD_DPAD_DOWN XINPUT_GAMEPAD_DPAD_DOWN No documentation. XINPUT_GAMEPAD_DPAD_LEFT XINPUT_GAMEPAD_DPAD_LEFT No documentation. XINPUT_GAMEPAD_DPAD_RIGHT XINPUT_GAMEPAD_DPAD_RIGHT No documentation. XINPUT_GAMEPAD_START XINPUT_GAMEPAD_START No documentation. XINPUT_GAMEPAD_BACK XINPUT_GAMEPAD_BACK No documentation. XINPUT_GAMEPAD_LEFT_THUMB XINPUT_GAMEPAD_LEFT_THUMB No documentation. XINPUT_GAMEPAD_RIGHT_THUMB XINPUT_GAMEPAD_RIGHT_THUMB No documentation. XINPUT_GAMEPAD_LEFT_SHOULDER XINPUT_GAMEPAD_LEFT_SHOULDER No documentation. XINPUT_GAMEPAD_RIGHT_SHOULDER XINPUT_GAMEPAD_RIGHT_SHOULDER No documentation. XINPUT_GAMEPAD_A XINPUT_GAMEPAD_A No documentation. XINPUT_GAMEPAD_B XINPUT_GAMEPAD_B No documentation. XINPUT_GAMEPAD_X XINPUT_GAMEPAD_X No documentation. XINPUT_GAMEPAD_Y XINPUT_GAMEPAD_Y None. None None No documentation. XINPUT_GAMEPAD_KEY_CODE XINPUT_GAMEPAD_KEY_CODE No documentation. VK_PAD_A VK_PAD_A No documentation. VK_PAD_B VK_PAD_B No documentation. VK_PAD_X VK_PAD_X No documentation. VK_PAD_Y VK_PAD_Y No documentation. VK_PAD_RSHOULDER VK_PAD_RSHOULDER No documentation. VK_PAD_LSHOULDER VK_PAD_LSHOULDER No documentation. VK_PAD_LTRIGGER VK_PAD_LTRIGGER No documentation. VK_PAD_RTRIGGER VK_PAD_RTRIGGER No documentation. VK_PAD_DPAD_UP VK_PAD_DPAD_UP No documentation. VK_PAD_DPAD_DOWN VK_PAD_DPAD_DOWN No documentation. VK_PAD_DPAD_LEFT VK_PAD_DPAD_LEFT No documentation. VK_PAD_DPAD_RIGHT VK_PAD_DPAD_RIGHT No documentation. VK_PAD_START VK_PAD_START No documentation. VK_PAD_BACK VK_PAD_BACK No documentation. VK_PAD_LTHUMB_PRESS VK_PAD_LTHUMB_PRESS No documentation. VK_PAD_RTHUMB_PRESS VK_PAD_RTHUMB_PRESS No documentation. VK_PAD_LTHUMB_UP VK_PAD_LTHUMB_UP No documentation. VK_PAD_LTHUMB_DOWN VK_PAD_LTHUMB_DOWN No documentation. VK_PAD_LTHUMB_RIGHT VK_PAD_LTHUMB_RIGHT No documentation. VK_PAD_LTHUMB_LEFT VK_PAD_LTHUMB_LEFT No documentation. VK_PAD_LTHUMB_UPLEFT VK_PAD_LTHUMB_UPLEFT No documentation. VK_PAD_LTHUMB_UPRIGHT VK_PAD_LTHUMB_UPRIGHT No documentation. VK_PAD_LTHUMB_DOWNRIGHT VK_PAD_LTHUMB_DOWNRIGHT No documentation. VK_PAD_LTHUMB_DOWNLEFT VK_PAD_LTHUMB_DOWNLEFT No documentation. VK_PAD_RTHUMB_UP VK_PAD_RTHUMB_UP No documentation. VK_PAD_RTHUMB_DOWN VK_PAD_RTHUMB_DOWN No documentation. VK_PAD_RTHUMB_RIGHT VK_PAD_RTHUMB_RIGHT No documentation. VK_PAD_RTHUMB_LEFT VK_PAD_RTHUMB_LEFT No documentation. VK_PAD_RTHUMB_UPLEFT VK_PAD_RTHUMB_UPLEFT No documentation. VK_PAD_RTHUMB_UPRIGHT VK_PAD_RTHUMB_UPRIGHT No documentation. VK_PAD_RTHUMB_DOWNRIGHT VK_PAD_RTHUMB_DOWNRIGHT No documentation. VK_PAD_RTHUMB_DOWNLEFT VK_PAD_RTHUMB_DOWNLEFT None. None None No documentation. XINPUT_KEYSTROKE_FLAGS XINPUT_KEYSTROKE_FLAGS No documentation. XINPUT_KEYSTROKE_KEYDOWN XINPUT_KEYSTROKE_KEYDOWN No documentation. XINPUT_KEYSTROKE_KEYUP XINPUT_KEYSTROKE_KEYUP No documentation. XINPUT_KEYSTROKE_REPEAT XINPUT_KEYSTROKE_REPEAT None. None None No documentation. XUSER_INDEX XUSER_INDEX No documentation. XUSER_INDEX_ANY XUSER_INDEX_ANY No documentation. XUSER_INDEX_ONE XUSER_INDEX_ONE No documentation. XUSER_INDEX_TWO XUSER_INDEX_TWO No documentation. XUSER_INDEX_THREE XUSER_INDEX_THREE No documentation. XUSER_INDEX_FOUR XUSER_INDEX_FOUR Functions 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 to fetch the next available input event from any user.
[in] Input flags that identify the device type.
ValueDescription
Limit input event fetch to the gamepad.?
[out] Pointer to an structure that receives an input event.

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 . (See Remarks.)

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 . Game titles must examine the return code and be prepared to handle this condition. Wired controllers are automatically activated when they are inserted. Wireless controllers are activated when the user presses the START or Xbox Guide button to power on the controller.

microsoft.directx_sdk.reference.xinputgetkeystroke unsigned int XInputGetKeystroke([In] unsigned int dwUserIndex,[In] unsigned int dwReserved,[Out] XINPUT_KEYSTROKE* pKeystroke) XInputGetKeystroke
Sends data to a connected controller. This function is used to activate the vibration function of a controller.
[in] 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.
[in, out] Pointer to an structure containing the vibration information to send to the controller.

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.

microsoft.directx_sdk.reference.xinputsetstate unsigned int XInputSetState([In] unsigned int dwUserIndex,[In] XINPUT_VIBRATION* pVibration) XInputSetState
Gets the sound rendering and sound capture device GUIDs that are associated with the headset connected to the specified controller.
[in] Index of the user's controller. It 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.
[out, optional] Pointer that receives the of the headset sound rendering device.
[out, optional] Pointer that receives the of the headset sound capture device.

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 also retrieves with GUID_NULL as the values for pDSoundRenderGuid and pDSoundCaptureGuid.

If the controller port device is not physically connected, the function returns .

If the function fails, it returns a valid Win32 error code.

Use of legacy DirectSound is not recommended, and DirectSound is not available for Modern applications.

microsoft.directx_sdk.reference.xinputgetdsoundaudiodeviceguids unsigned int XInputGetDSoundAudioDeviceGuids([In] unsigned int dwUserIndex,[Out] GUID* pDSoundRenderGuid,[Out] GUID* pDSoundCaptureGuid) XInputGetDSoundAudioDeviceGuids
Retrieves the current state of the specified controller.
[in] 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.
[out] Pointer to an structure that receives the current state of the controller.

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 is used to retrieve controller data, the left and right triggers are each reported separately. For legacy reasons, when DirectInput retrieves controller data, the two triggers share the same axis. The legacy behavior is noticeable in the current Game Device Control Panel, which uses DirectInput for controller state.

microsoft.directx_sdk.reference.xinputgetstate unsigned int XInputGetState([In] unsigned int dwUserIndex,[Out] XINPUT_STATE* pState) XInputGetState
Retrieves the capabilities and features of a connected controller.
[in] 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.
[in] 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:
ValueDescription
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.

[out] Pointer to an structure that receives the controller capabilities.

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.

microsoft.directx_sdk.reference.xinputgetcapabilities unsigned int XInputGetCapabilities([In] unsigned int dwUserIndex,[In] XINPUT_DEVQUERYTYPE dwFlags,[Out] XINPUT_CAPABILITIES* pCapabilities) XInputGetCapabilities
Retrieves the battery type and charge status of a wireless controller.
[in] Index of the signed-in gamer associated with the device. Can be a value in the range 0?XUSER_MAX_COUNT???1.
[in] Specifies which device associated with this user index should be queried. Must be or .
[out] Pointer to an structure that receives the battery information.

If the function succeeds, the return value is .

ff729733 unsigned int XInputGetBatteryInformation([In] unsigned int dwUserIndex,[In] BATTERY_DEVTYPE devType,[Out] XINPUT_BATTERY_INFORMATION* pBatteryInformation) XInputGetBatteryInformation
Sets the reporting state of XInput.
If enable is , XInput will only send neutral data in response to (all buttons up, axes centered, and triggers at 0). calls will be registered but not sent to the device. Sending any value other than will restore reading and writing functionality to normal.

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:

  • Passing will stop any vibration effects currently playing. In this state, calls to will be registered, but not passed to the device.

  • Passing TRUE will pass the last vibration request (even if it is 0) sent to to the device.

microsoft.directx_sdk.reference.xinputenable void XInputEnable([In] BOOL enable) XInputEnable
Contains information on battery type and charge state. ff729734 XINPUT_BATTERY_INFORMATION XINPUT_BATTERY_INFORMATION
The type of battery. BatteryType will be one of the following values.
ValueDescription
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.?
ff729734 BATTERY_TYPE BatteryType BATTERY_TYPE BatteryType
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
ff729734 BATTERY_LEVEL BatteryLevel BATTERY_LEVEL BatteryLevel
Describes the capabilities of a connected controller. TheXInputGetCapabilitiesfunction returnsXINPUT_CAPABILITIES.

returns to indicate the characteristics and available functionality of a specified controller.

sets the structure members to indicate which inputs the device supports. For binary state controls, such as digital buttons, the corresponding bit reflects whether or not the control is supported by the device. For proportional controls, such as thumbsticks, the value indicates the resolution for that control. Some number of the least significant bits may not be set, indicating that the control does not provide resolution to that level.

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.

microsoft.directx_sdk.reference.xinput_capabilities XINPUT_CAPABILITIES XINPUT_CAPABILITIES
No documentation. XINPUT_DEVTYPE Type XINPUT_DEVTYPE Type No documentation. XINPUT_DEVSUBTYPE SubType XINPUT_DEVSUBTYPE SubType No documentation. XINPUT_CAPS_FLAGS Flags XINPUT_CAPS_FLAGS Flags No documentation. XINPUT_GAMEPAD Gamepad XINPUT_GAMEPAD Gamepad No documentation. XINPUT_VIBRATION Vibration XINPUT_VIBRATION Vibration Specifies keystroke data returned byXInputGetKeystroke.

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.

ValueDescription
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?
microsoft.directx_sdk.reference.xinput_keystroke XINPUT_KEYSTROKE XINPUT_KEYSTROKE
No documentation. XINPUT_GAMEPAD_KEY_CODE VirtualKey XINPUT_GAMEPAD_KEY_CODE VirtualKey No documentation. wchar_t Unicode wchar_t Unicode No documentation. XINPUT_KEYSTROKE_FLAGS Flags XINPUT_KEYSTROKE_FLAGS Flags No documentation. XUSER_INDEX UserIndex XUSER_INDEX UserIndex No documentation. unsigned char HidCode unsigned char HidCode 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.

microsoft.directx_sdk.reference.xinput_state XINPUT_STATE XINPUT_STATE
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 structures, the controller state has not changed.
microsoft.directx_sdk.reference.xinput_state unsigned int dwPacketNumber unsigned int dwPacketNumber
structure containing the current state of an Xbox 360 Controller.
microsoft.directx_sdk.reference.xinput_state XINPUT_GAMEPAD Gamepad XINPUT_GAMEPAD Gamepad
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.

microsoft.directx_sdk.reference.xinput_vibration XINPUT_VIBRATION XINPUT_VIBRATION
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.
microsoft.directx_sdk.reference.xinput_vibration unsigned short wLeftMotorSpeed unsigned short wLeftMotorSpeed
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.
microsoft.directx_sdk.reference.xinput_vibration unsigned short wRightMotorSpeed unsigned short wRightMotorSpeed
The namespace provides a managed XInput API. hh405053 XInput XInput Common error code from XInput Device is not connected