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

# XInputGetStateWithToken

> XInputGetStateWithToken

# XInputGetStateWithToken

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

<a id="syntaxSection" />

## 语法

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

<a id="parametersSection" />

### 参数

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

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

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

D3DX 帧管线令牌。

*pState*   \_Out\_\
类型：[XINPUT\_STATE](/reference/input/xinputongameinput/structs/xinput_state)\*

指向 [XINPUT\_STATE](/reference/input/xinputongameinput/structs/xinput_state) 对象的指针，用于接收控制器的当前状态。

<a id="retvalSection" />

### 返回值

类型：DWORD

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

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

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

<a id="remarksSection" />

## 备注

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

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

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

<a id="requirementsSection" />

## 要求

**头文件：** XInputOnGameInput.h

**库：** xgameruntime.lib

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

<a id="seealsoSection" />

## 另请参阅

[从 XInput 移植到 GameInput](/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

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