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

# IGameInputDevice::GetControllerButtonCount

> 取得裝置上一般控制器按鈕的數目。

取得裝置上一般控制器按鈕的數目。

## 語法

```cpp theme={null}
uint32_t GetControllerButtonCount();
```

### 參數

此方法沒有參數。

### 傳回值

類型：uint32\_t

裝置上的控制器按鈕數目；如果裝置沒有控制器按鈕，則為 0。

## 備註

控制器按鈕是裝置上未經對應的原始按鈕。當 [GetSupportedInput](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md) 傳回的值包含 `GameInputKindControllerButton` 時，裝置即具有控制器按鈕。來自該裝置且包含 `GameInputKindControllerButton` 的讀數，會透過 [IGameInputReading::GetControllerButtonCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttoncount.md) 回報相同數目的按鈕。

使用傳回的值來決定您傳遞給 [GetControllerButtonLabels](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttonlabels.md) 或 [IGameInputReading::GetControllerButtonState](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttonstate.md) 之陣列的大小。在裝置連線期間，按鈕數目不會變更。

在 GameInput v3 及更早版本中，此資訊可從 [GameInputControllerInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md) 結構的 `controllerButtonCount` 成員取得，該結構由 [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md) 所傳回 [GameInputDeviceInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) 結構的 `controllerInfo` 成員參考。

## 需求

**標頭：** GameInput.h

**程式庫：** gameinput.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[GameInput 概觀](https://docs.xbox.com/zh-TW/build/core-features/common/input/overviews/input-overview.md)\
[GetControllerButtonLabels](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttonlabels.md)\
[IGameInputReading::GetControllerButtonCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttoncount.md)\
[IGameInputReading::GetControllerButtonState](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttonstate.md)\
[IGameInputDevice](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本歷程記錄

| 版本 | 變更 |
| - | - |
| **v4** | 已推出。 |


## Related topics

- [IGameInputDevice::GetControllerButtonLabels](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttonlabels.md)
- [GetControllerButtonCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttoncount.md)
- [IGameInputDevice::GetControllerAxisCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxiscount.md)
- [IGameInputDevice::GetControllerSwitchCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md)
- [IGameInputDevice::GetControllerSwitchInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchinfo.md)
