> ## 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::GetControllerSwitchCount

> 取得裝置上一般控制器切換開關 (例如苦力帽開關和方向鍵) 的數目。

取得裝置上一般控制器切換開關 (例如苦力帽開關和方向鍵) 的數目。

## 語法

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

### 參數

此方法沒有參數。

### 傳回值

類型：uint32\_t

裝置上的控制器切換開關數目；如果裝置沒有控制器切換開關，則為 0。

## 備註

控制器切換開關是裝置上未經對應的原始多位置切換開關，例如苦力帽開關和方向鍵。當 [GetSupportedInput](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md) 傳回的值包含 `GameInputKindControllerSwitch` 時，裝置即具有控制器切換開關。來自該裝置且包含 `GameInputKindControllerSwitch` 的讀數，會透過 [IGameInputReading::GetControllerSwitchCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchcount.md) 回報相同數目的切換開關。

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

在 GameInput v3 及更早版本中，此資訊可從 [GameInputControllerInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md) 結構的 `controllerSwitchCount` 成員取得，該結構由 [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)\
[GetControllerSwitchInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchinfo.md)\
[IGameInputReading::GetControllerSwitchCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchcount.md)\
[IGameInputReading::GetControllerSwitchState](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md)\
[IGameInputDevice](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本歷程記錄

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


## Related topics

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