> ## 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.

# XInputGetStateWithToken

> XInputGetStateWithToken

# XInputGetStateWithToken

检索指定控制器的当前状态，并将其与 D3DX 帧管线令牌相关联。

## 语法

```cpp theme={null}
DWORD XInputGetStateWithToken(  
         DWORD dwUserIndex,  
         UINT64 framePipelineToken,  
         XINPUT_STATE * pState  
)  
```

### 参数

*dwUserIndex*   \_In\_\
类型：DWORD

与设备关联的玩家索引；取值范围为 0 到 `XUSER_MAX_COUNT - 1`。

*framePipelineToken*   \_In\_\
类型：UINT64

D3DX 帧管线令牌。

*pState*   \_Out\_\
类型：[XINPUT\_STATE](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/structs/xinput_state.md)\*

指向 [XINPUT\_STATE](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/structs/xinput_state.md) 对象的指针，用于接收控制器的当前状态。

### 返回值

类型：DWORD

如果函数成功，则返回 `ERROR_SUCCESS`。

如果未连接控制器，函数将返回 `ERROR_DEVICE_NOT_CONNECTED`。

如果函数失败，将返回 WinError.h 中定义的错误代码。

## 备注

此函数与 [XInputGetState](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/functions/xinputgetstate.md) 类似，但它将特定的输入读数与图形帧相关联，以便后续进行分析。

> [!NOTE]
>
> 从 5 月预览版起，`XInputGetStateWithToken` 的行为与 `XInputGetState` 相同，因为其底层 GameInput 代码尚未完全实现。

通过提供帧管线令牌，你可以在 PIX 软件中将输入 API 调用与特定的图形帧相关联。

## 要求

**头文件：** XInputOnGameInput.h

**库：** xgameruntime.lib

**支持的平台：** XBOX One 系列主机和 XBOX Series 主机

## 另请参阅

[从 XInput 移植到 GameInput](https://docs.xbox.com/zh-CN/build/core-features/common/input/porting/input-porting-xinput.md)\
[XInputOnGameInput](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/xinputongameinput_members.md)


## Related topics

- [XINPUT_STATE](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/structs/xinput_state.md)
- [XInputGetState](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/functions/xinputgetstate.md)
- [从 XInput 移植到 GameInput](https://docs.xbox.com/zh-CN/build/core-features/common/input/porting/input-porting-xinput.md)
- [XInputOnGameInput（API 内容）](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/xinputongameinput_members.md)
- [GetKeyState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getkeystate.md)
