> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XInputGetState

> XInputGetState

Retrieves the current state of the specified controller.

## Syntax

```cpp theme={null}
DWORD XInputGetState(  
         DWORD dwUserIndex,  
         XINPUT_STATE * pState  
)  
```

### Parameters

*dwUserIndex*   \_In\_\
Type: DWORD

Index of the gamer associated with the device; a value in the range of 0 to `XUSER_MAX_COUNT - 1`.

*pState*   \_Out\_\
Type: [XINPUT\_STATE](https://docs.xbox.com/reference/input/xinputongameinput/structs/xinput_state.md)\*

Pointer to an [XINPUT\_STATE](https://docs.xbox.com/reference/input/xinputongameinput/structs/xinput_state.md) object that receives the current state of the controller.

### Return value

Type: DWORD

If the function succeeds, it returns `ERROR_SUCCESS`.

If the controller is not connected, the function returns `ERROR_DEVICE_NOT_CONNECTED`.

If the function fails, it returns an error code defined in WinError.h.

## Remarks

This function reports the left and right triggers separately. In DirectInput, the two triggers shared the same axis.

The [XInputGetStateWithToken](https://docs.xbox.com/reference/input/xinputongameinput/functions/xinputgetstatewithtoken.md) function is similar but allows the caller to supply a D3DX frame pipeline token to associate a specific input reading with a graphics frame for later analysis in PIX.

For more information, see [The XInputOnGameInput wrapper](https://docs.xbox.com/build/core-features/common/input/porting/input-porting-xinput.md#xinputWrapperSection).

## Requirements

**Header:** XInputOnGameInput.h

**Library:** xgameruntime.lib

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

## See also

[Porting from XInput to GameInput](https://docs.xbox.com/build/core-features/common/input/porting/input-porting-xinput.md)\
[XInputOnGameInput](https://docs.xbox.com/reference/input/xinputongameinput/xinputongameinput_members.md)


## Related topics

- [XInputGetStateWithToken](https://docs.xbox.com/reference/input/xinputongameinput/functions/xinputgetstatewithtoken.md)
- [XINPUT_STATE](https://docs.xbox.com/reference/input/xinputongameinput/structs/xinput_state.md)
- [XInputEnable](https://docs.xbox.com/reference/input/xinputongameinput/functions/xinputenable.md)
- [Porting from XInput to GameInput](https://docs.xbox.com/build/core-features/common/input/porting/input-porting-xinput.md)
- [XInputOnGameInput (API contents)](https://docs.xbox.com/reference/input/xinputongameinput/xinputongameinput_members.md)
