XInputGetState

Retrieves the current state of the specified controller.

DWORD XInputGetState(
  DWORD dwUserIndex,
  XINPUT_STATE* pState
);

Parameters

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 XINPUT_STATE structure that receives the current state of the controller.

Return Values

If the function succeeds, the return value is ERROR_SUCCESS.

If the controller is not connected, the return value is ERROR_DEVICE_NOT_CONNECTED.

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.

Requirements

Header: Declared in XInput.h.

Import Library: Use Xinput.lib.

See Also

XInput Functions | XInputSetState, XINPUT_STATE, XINPUT_GAMEPAD