public interface XInput
extends com.sun.jna.Library
Source: Microsoft Documentation
Modifier and Type | Method and Description |
---|---|
static XInput |
create()
Creates a new instance of XInput.
|
void |
XInputEnable(boolean enable)
Sets the reporting state of XInput.
|
int |
XInputGetAudioDeviceIds(int dwUserIndex,
char[] pRenderDeviceId,
com.sun.jna.ptr.LongByReference pRenderCount,
char[] pCaptureDeviceId,
com.sun.jna.ptr.LongByReference pCaptureCount)
Retrieves the sound rendering and sound capture audio device IDs that are associated with the headset connected to the specified controller.
|
int |
XInputGetBatteryInformation(int dwUserIndex,
int devType,
XInputBatteryInformation pBatteryInformation)
Retrieves the battery type and charge status of a wireless controller.
|
int |
XInputGetCapabilities(int dwUserIndex,
int dwFlags,
XInputCapabilities pCapabilities)
Retrieves the capabilities and features of a connected controller.
|
int |
XInputGetDSoundAudioDeviceGuids(int dwUserIndex,
char[] pDSoundRenderGuid,
char[] pdSoundCaptureGuid)
Deprecated.
XInputGetDSoundAudioDeviceGuids(int, char[], char[]) is deprecated because it isn't supported by Windows 8 (XInput 1.4). |
int |
XInputGetKeystroke(int dwUserIndex,
int dwReserved,
XInputKeystroke pKeystroke)
Retrieves a gamepad input event.
|
int |
XInputGetState(int dwUserIndex,
XInputState pState)
Retrieves the current state of the specified controller.
|
int |
XInputSetState(int dwUserIndex,
XInputVibration pVibration)
Sends data to a connected controller.
|
static final int ERROR_SUCCESS
static final int ERROR_EMPTY
static final int ERROR_DEVICE_NOT_CONNECTED
static final int XINPUT_KEYSTROKE_KEYDOWN
static final int XINPUT_KEYSTROKE_KEYUP
static final int XINPUT_KEYSTROKE_REPEAT
static final int XINPUT_DEVSUBTYPE_UNKNOWN
static final int XINPUT_DEVSUBTYPE_GAMEPAD
static final int XINPUT_DEVSUBTYPE_WHEEL
static final int XINPUT_DEVSUBTYPE_ARCADE_STICK
static final int XINPUT_DEVSUBTYPE_FLIGHT_STICK
static final int XINPUT_DEVSUBTYPE_DANCE_PAD
static final int XINPUT_DEVSUBTYPE_GUITAR
static final int XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE
static final int XINPUT_DEVSUBTYPE_DRUM_KIT
static final int XINPUT_DEVSUBTYPE_GUITAR_BASS
static final int XINPUT_DEVSUBTYPE_ARCADE_PAD
static final int VK_PAD_A
static final int VK_PAD_B
static final int VK_PAD_X
static final int VK_PAD_Y
static final int VK_PAD_RSHOULDER
static final int VK_PAD_LSHOULDER
static final int VK_PAD_LTRIGGER
static final int VK_PAD_RTRIGGER
static final int VK_PAD_DPAD_UP
static final int VK_PAD_DPAD_DOWN
static final int VK_PAD_DPAD_LEFT
static final int VK_PAD_DPAD_RIGHT
static final int VK_PAD_START
static final int VK_PAD_BACK
static final int VK_PAD_LTHUMB_PRESS
static final int VK_PAD_RTHUMB_PRESS
static final int VK_PAD_LTHUMB_UP
static final int VK_PAD_LTHUMB_DOWN
static final int VK_PAD_LTHUMB_RIGHT
static final int VK_PAD_LTHUMB_LEFT
static final int VK_PAD_LTHUMB_UPLEFT
static final int VK_PAD_LTHUMB_UPRIGHT
static final int VK_PAD_LTHUMB_DOWNRIGHT
static final int VK_PAD_LTHUMB_DOWNLEFT
static final int VK_PAD_RTHUMB_UP
static final int VK_PAD_RTHUMB_DOWN
static final int VK_PAD_RTHUMB_RIGHT
static final int VK_PAD_RTHUMB_LEFT
static final int VK_PAD_RTHUMB_UPLEFT
static final int VK_PAD_RTHUMB_UPRIGHT
static final int VK_PAD_RTHUMB_DOWNRIGHT
static final int VK_PAD_RTHUMB_DOWNLEFT
static final int XINPUT_DEVTYPE_GAMEPAD
static final int XINPUT_GAMEPAD_DPAD_UP
static final int XINPUT_GAMEPAD_DPAD_DOWN
static final int XINPUT_GAMEPAD_DPAD_LEFT
static final int XINPUT_GAMEPAD_DPAD_RIGHT
static final int XINPUT_GAMEPAD_START
static final int XINPUT_GAMEPAD_BACK
static final int XINPUT_GAMEPAD_LEFT_THUMB
static final int XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE
static final int XINPUT_GAMEPAD_RIGHT_THUMB
static final int XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE
static final int XINPUT_GAMEPAD_LEFT_SHOULDER
static final int XINPUT_GAMEPAD_RIGHT_SHOULDER
static final int XINPUT_GAMEPAD_A
static final int XINPUT_GAMEPAD_B
static final int XINPUT_GAMEPAD_X
static final int XINPUT_GAMEPAD_Y
static final int XINPUT_GAMEPAD_TRIGGER_THRESHOLD
static final int BATTERY_TYPE_DISCONNECTED
static final int BATTERY_TYPE_WIRED
static final int BATTERY_TYPE_ALKALINE
static final int BATTERY_TYPE_NIMH
static final int BATTERY_TYPE_UNKNOWN
static final int BATTERY_DEVTYPE_GAMEPAD
static final int BATTERY_DEVTYPE_HEADSET
static final int BATTERY_LEVEL_EMPTY
static final int BATTERY_LEVEL_LOW
static final int BATTERY_LEVEL_MEDIUM
static final int BATTERY_LEVEL_FULL
static final int XINPUT_CAPS_FFB_SUPPORTED
static final int XINPUT_CAPS_WIRELESS
static final int XINPUT_CAPS_VOICE_SUPPORTED
static final int XINPUT_CAPS_PMD_SUPPORTED
static final int XINPUT_CAPS_NO_NAVIGATION
static final int XINPUT_FLAG_GAMEPAD
static final int XUSER_INDEX_ANY
static final int XUSER_MAX_COUNT
static XInput create()
null
if the XInput API is not supportedvoid XInputEnable(boolean enable)
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:
false
will stop any vibration effects currently playing. In this state, calls to XInputSetState(int, XInputVibration)
will be registered, but not passed to the device.true
will pass the last vibration request (even if it is 0
) sent to XInputSetState(int, XInputVibration)
to the device.Windows 8 (XInput 1.4), DirectX SDK (XInput 1.3)
Header | XInput.h |
---|---|
Library | Xinput.lib |
DLL | Xinput1_4.dll |
Source: Microsoft Documentation
enable
- [in]
If enable is false
, XInput will only send neutral data in response to
XInputGetState(int, XInputState)
(all buttons up, axes centered, and triggers at 0
).
XInputSetState(int, XInputVibration)
calls will be registered but not sent to the device. Sending any value other
than false
will restore reading and writing functionality to normal.XInputGetState(int, XInputState)
,
XInputSetState(int, XInputVibration)
,
XInputState
,
XInputGamepad
int XInputGetCapabilities(int dwUserIndex, int dwFlags, XInputCapabilities pCapabilities)
Retrieves the capabilities and features of a connected controller.
The legacy XINPUT 9.1.0 version (included in Windows Vista and later) always returned a fixed set of capabilities regardless of attached device.
Windows 8 (XInput 1.4), DirectX SDK (XInput 1.3), Windows Vista (XInput 9.1.0)
Header | XInput.h |
---|---|
Library | Xinput.lib; Xinput9_1_0.lib |
DLL | Xinput1_4.dll; Xinput9_1_0.dll |
Source: Microsoft Documentation
dwUserIndex
- [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.dwFlags
- [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:
Value | Description |
---|---|
XINPUT_FLAG_GAMEPAD | Limit query to devices of Xbox 360 Controller type. |
dwFlags
other than the above or 0
is illegal and will result in an error break when debugging.pCapabilities
- [out]
Pointer to an XInputCapabilities structure that
receives the controller capabilities.ERROR_SUCCESS
.ERROR_DEVICE_NOT_CONNECTED
.SetLastError
to set the calling thread's last-error code.XInputGetState(int, XInputState)
,
XInputSetState(int, XInputVibration)
int XInputGetAudioDeviceIds(int dwUserIndex, char[] pRenderDeviceId, com.sun.jna.ptr.LongByReference pRenderCount, char[] pCaptureDeviceId, com.sun.jna.ptr.LongByReference pCaptureCount)
Callers must allocate the memory for the buffers passed to XInputGetAudioDeviceIds(int, char[], LongByReference, char[], LongByReference)
.
The resulting strings can be of arbitrary length.
Windows 8 (XInput 1.4)
Header | XInput.h |
---|---|
Library | Xinput.lib |
DLL | Xinput1_4.dll |
Source: Microsoft Documentation
dwUserIndex
- [in]
Index of the gamer associated with the device.pRenderDeviceId
- [out, optional]
Windows Core Audio device ID string for render (speakers).pRenderCount
- [in, out, optional]
Size, in wide-chars, of the render device ID string buffer.pCaptureDeviceId
- [out, optional]
Windows Core Audio device ID string for capture (microphone).pCaptureCount
- [in, out, optional]
Size, in wide-chars, of capture device ID string buffer.ERROR_SUCCESS
.
If there is no headset connected to the controller, the function will also retrieve ERROR_SUCCESS
with null
as the values for pRenderDeviceId
and pCaptureDeviceId
.
If the controller port device is not physically connected, the function will return ERROR_DEVICE_NOT_CONNECTED
.
If the function fails, it will return a valid Win32 error code.XInputGetDSoundAudioDeviceGuids(int, char[], char[])
int XInputGetBatteryInformation(int dwUserIndex, int devType, XInputBatteryInformation pBatteryInformation)
Windows 8 (XInput 1.4), DirectX SDK (XInput 1.3)
Header | XInput.h |
---|---|
Library | Xinput.lib |
DLL | Xinput1_4.dll |
Source: Microsoft Documentation
dwUserIndex
- [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.devType
- [in]
Specifies which device associated with this user index should be queried. Must be BATTERY_DEVTYPE_GAMEPAD
or BATTERY_DEVTYPE_HEADSET
.pBatteryInformation
- [out]
Pointer to an XInputBatteryInformation structure that receives the battery information.ERROR_SUCCESS
.@Deprecated int XInputGetDSoundAudioDeviceGuids(int dwUserIndex, char[] pDSoundRenderGuid, char[] pdSoundCaptureGuid)
XInputGetDSoundAudioDeviceGuids(int, char[], char[])
is deprecated because it isn't supported by Windows 8 (XInput 1.4).Use of legacy DirectSound is not recommended, and DirectSound is not available for Windows Store apps.
DirectX SDK (XInput 1.3), Windows Vista (XInput 9.1.0)
Header | XInput.h |
---|---|
Library | Xinput.lib; Xinput9_1_0.lib |
DLL | Xinput9_1_0.dll |
Source: Microsoft Documentation
dwUserIndex
- [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.pDSoundRenderGuid
- [out]
Pointer that receives the GUID of the headset sound rendering device.pdSoundCaptureGuid
- [out]
Pointer that receives the GUID of the headset sound capture device.ERROR_SUCCESS
.
If there is no headset connected to the controller, the function also retrieves ERROR_SUCCESS
with GUID_NULL
as the values for
pDSoundRenderGuid
and pDSoundCaptureGuid
.
If the controller port device is not physically connected, the function returns ERROR_DEVICE_NOT_CONNECTED
.
If the function fails, it returns a valid Win32 error code.XInputGetState(int, XInputState)
int XInputGetState(int dwUserIndex, XInputState pState)
XInputGetState(int, XInputState)
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.
Windows 8 (XInput 1.4), DirectX SDK (XInput 1.3), Windows Vista (XInput 9.1.0)
Header | XInput.h |
---|---|
Library | Xinput.lib; Xinput9_1_0.lib |
DLL | Xinput1_4.dll; Xinput9_1_0.dll; Xinputuap.dll |
Source: Microsoft Documentation
dwUserIndex
- [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.pState
- [out]
Pointer to an XInputState structure that receives the current state of the controller.ERROR_SUCCESS
.ERROR_DEVICE_NOT_CONNECTED
.SetLastError
to set the calling thread's last-error code.XInputSetState(int, XInputVibration)
,
XInputState
,
XInputGamepad
int XInputSetState(int dwUserIndex, XInputVibration pVibration)
Sends data to a connected controller. This function is used to activate the vibration function of a controller.
Windows 8 (XInput 1.4), DirectX SDK (XInput 1.3), Windows Vista (XInput 9.1.0)
Header | XInput.h |
---|---|
Library | Xinput.lib; Xinput9_1_0.lib |
DLL | Xinput1_4.dll; Xinput9_1_0.dll |
Source: Microsoft Documentation
dwUserIndex
- [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.pVibration
- [in, out]
Pointer to an XInputVibration structure containing the vibration information to send to the controller.ERROR_SUCCESS
.ERROR_DEVICE_NOT_CONNECTED
.SetLastError
to set the calling thread's last-error code.XInputGetState(int, XInputState)
,
XInputVibration
int XInputGetKeystroke(int dwUserIndex, int dwReserved, XInputKeystroke pKeystroke)
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 ERROR_DEVICE_NOT_CONNECTED
. 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.
Windows 8 (XInput 1.4), DirectX SDK (XInput 1.3)
Header | XInput.h |
---|---|
Library | Xinput.lib |
DLL | Xinput1_4.dll |
Source: Microsoft Documentation
dwUserIndex
- [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.dwReserved
- [in]
ReservedpKeystroke
- [out]
Pointer to an XInputKeystroke structure that receives an input event.ERROR_SUCCESS
.ERROR_DEVICE_NOT_CONNECTED
.SetLastError
to set the calling thread's last-error code.XInputKeystroke