> ## 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-TW/reference/input/xinputongameinput/structs/xinput_capabilities.md)\*

指向接收控制器功能之 [XINPUT\_CAPABILITIES](https://docs.xbox.com/zh-TW/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-TW/reference/input/xinputongameinput/structs/xinput_capabilities.md)。

如需詳細資訊，請參閱 [XInputOnGameInput 包裝函式](https://docs.xbox.com/zh-TW/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-TW/build/core-features/common/input/porting/input-porting-xinput.md)\
[XInputOnGameInput](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/xinputongameinput_members.md)


## Related topics

- [XINPUT_CAPABILITIES](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/structs/xinput_capabilities.md)
- [XInputOnGameInput (API 內容)](https://docs.xbox.com/zh-TW/reference/input/xinputongameinput/xinputongameinput_members.md)
- [GameInputDeviceCapabilities (已淘汰)](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/enums/gameinputdevicecapabilities.md)
- [GameInputDeviceInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/structs/gameinputdeviceinfo.md)
- [GetDeviceInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md)
