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

# GetControllerAxisState

> IGameInputReading::GetControllerAxisState

# IGameInputReading::GetControllerAxisState

从游戏控制器检索轴状态信息。

## 语法

```cpp theme={null}
uint32_t GetControllerAxisState(
    uint32_t stateArrayCount,
    float* stateArray
);
```

### 参数

*stateArrayCount*   \_In\_\
类型:uint32\_t

用于捕获游戏控制器上各轴状态的预期状态数组数量。
可以通过 [IGameInputReading::GetControllerAxisCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxiscount.md) 获取该数量。

*stateArray*   \_Out\_writes\_(stateArrayCount)
类型:float\*

指向存放轴状态数据的数组的指针。

### 返回值

类型:uint32\_t

返回有效缓冲区条目的数量。

## 注解

游戏控制器上的大多数模拟控件（摇杆、扳机、滑块、拨盘等）都作为轴呈现，其值为线性归一化到 \[0.0, 1.0] 范围的浮点数。大多数数字输入作为按钮呈现，其值为简单的布尔值。方向开关（Hat switch）作为开关值呈现，其位置由 [GameInputSwitchPosition](https://docs.xbox.com/zh-CN/reference/input/gameinput/enums/gameinputswitchposition.md) 枚举值之一表示。

## 要求

**头文件:** GameInput.h

[Input API 概述](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputReading](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/igameinputreading.md)

## 版本历史

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


## Related topics

- [GetControllerAxisCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrolleraxiscount.md)
- [GetControllerButtonState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttonstate.md)
- [GetControllerSwitchState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md)
- [GameInputControllerAxisInfo（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/structs/gameinputcontrolleraxisinfo.md)
- [Axis](https://docs.xbox.com/zh-CN/reference/system/touchadaptationkit/types/game-streaming-touch-axis.md)
