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

# XInputGetCapabilities

> XInputGetCapabilities

# XInputGetCapabilities

检索已连接控制器的功能和特性。

## 语法

```cpp theme={null}
DWORD XInputGetCapabilities(  
         DWORD dwUserIndex,  
         DWORD dwFlags,  
         XINPUT_CAPABILITIES * pCapabilities  
)  
```

### 参数

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

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

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

用于标识控制器类型的输入标志。如果此值为 0，则返回连接到系统的所有控制器的功能。目前仅支持 `XINPUT_FLAG_GAMEPAD`。

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

指向 [XINPUT\_CAPABILITIES](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/structs/xinput_capabilities.md) 对象的指针，用于接收控制器功能。

### 返回值

类型：DWORD

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

如果未连接控制器，返回值为 `ERROR_DEVICE_NOT_CONNECTED`。

如果函数失败，返回值为 WinError.h 中定义的错误代码。该函数不使用 `SetLastError` 来设置调用线程的上一个错误代码。

## 备注

> [!NOTE]
>
> 旧版 XINPUT 9.1.0（包含在 Windows Vista 及更高版本中）无论连接的设备是什么，始终返回一组固定的功能。

有关报告功能的详细信息，请参阅 [XINPUT\_CAPABILITIES](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/structs/xinput_capabilities.md)。

有关详细信息，请参阅 [XInputOnGameInput 包装器](https://docs.xbox.com/zh-CN/build/core-features/common/input/porting/input-porting-xinput.md#xinputWrapperSection)。

## 要求

**头文件：** 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_CAPABILITIES](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/structs/xinput_capabilities.md)
- [XInputOnGameInput（API 内容）](https://docs.xbox.com/zh-CN/reference/input/xinputongameinput/xinputongameinput_members.md)
- [GameInputDeviceCapabilities（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/enums/gameinputdevicecapabilities.md)
- [GetDeviceInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md)
- [GameInput 动态延迟输入](https://docs.xbox.com/zh-CN/build/core-features/common/input/advanced/input-synchronization.md)
