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

# XInputGetCapabilities

> XInputGetCapabilities

# XInputGetCapabilities

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

<a id="syntaxSection" />

## 语法

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

<a id="parametersSection" />

### 参数

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

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

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

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

*pCapabilities*   \_Out\_\
类型：[XINPUT\_CAPABILITIES](/reference/input/xinputongameinput/structs/xinput_capabilities)\*

指向 [XINPUT\_CAPABILITIES](/reference/input/xinputongameinput/structs/xinput_capabilities) 对象的指针，用于接收控制器功能。

<a id="retvalSection" />

### 返回值

类型：DWORD

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

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

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

<a id="remarksSection" />

## 备注

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

有关报告功能的详细信息，请参阅 [XINPUT\_CAPABILITIES](/reference/input/xinputongameinput/structs/xinput_capabilities)。

有关详细信息，请参阅 [XInputOnGameInput 包装器](/build/core-features/common/input/porting/input-porting-xinput#xinputWrapperSection)。

<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_CAPABILITIES](/zh-CN/reference/input/xinputongameinput/structs/xinput_capabilities.md)
- [XInputOnGameInput](/zh-CN/reference/input/xinputongameinput/xinputongameinput_members.md)
- [GameInputDeviceCapabilities](/zh-CN/reference/input/gameinput/deprecated/enums/gameinputdevicecapabilities.md)
- [GetDeviceInfo](/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md)
- [GameInput](/zh-CN/reference/input/gameinput/gameinput_members.md)
