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

> 获取设备上通用控制器轴的数量。

获取设备上通用控制器轴的数量。

## 语法

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

### 参数

此方法没有参数。

### 返回值

类型：uint32\_t

设备上控制器轴的数量；如果设备没有控制器轴，则为 0。

## 备注

控制器轴是设备上未映射的原始轴。当 [GetSupportedInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md) 返回的值包含 `GameInputKindControllerAxis` 时，设备具有控制器轴。来自该设备且包含 `GameInputKindControllerAxis` 的读数会通过 [IGameInputReading::GetControllerAxisCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxiscount.md) 报告相同数量的轴。

使用返回的值来确定传递给 [GetControllerAxisLabels](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxislabels.md) 或 [IGameInputReading::GetControllerAxisState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxisstate.md) 的数组大小。在设备保持连接期间，轴的数量不会更改。

在 GameInput v3 及更早版本中，此信息可从 [GameInputControllerInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md) 结构的 `controllerAxisCount` 成员中获取，该结构由 [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md) 返回的 [GameInputDeviceInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) 结构的 `controllerInfo` 成员引用。

## 要求

**头文件：** GameInput.h

**库：** gameinput.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 另请参阅

[GameInput 概述](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)\
[GetControllerAxisLabels](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxislabels.md)\
[IGameInputReading::GetControllerAxisCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxiscount.md)\
[IGameInputReading::GetControllerAxisState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxisstate.md)\
[IGameInputDevice](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v4** | 引入。 |


## Related topics

- [GameInputControllerInfo（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md)
- [IGameInputDevice::GetControllerAxisLabels](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxislabels.md)
- [GetControllerAxisCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxiscount.md)
- [IGameInputDevice::GetControllerButtonCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttoncount.md)
- [IGameInputDevice::GetControllerSwitchCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md)
