Files
XCEngine/docs/api/XCEngine/Input/InputAxis/InputAxis.md

49 lines
1.7 KiB
Markdown
Raw Normal View History

2026-03-26 16:45:24 +08:00
# InputAxis
**命名空间**: `XCEngine::Input`
**类型**: `class`
**头文件**: `XCEngine/Input/InputAxis.h`
2026-03-26 17:39:53 +08:00
**描述**: 描述一个具名逻辑轴及其正负方向按键映射。
2026-03-26 16:45:24 +08:00
## 概述
2026-03-26 17:39:53 +08:00
`InputAxis``InputManager` 的配置对象,而不是完整的运行时输入通道。它保存三类信息:
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
- 轴名
- 正方向按键
- 负方向按键
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
此外它还有一个独立的 `m_value` 字段,但要特别注意:当前 `InputManager::GetAxis``GetAxisRaw` 都不会读取这个值,而是每次根据按键状态重新计算结果。
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
## 当前实现中的角色
2026-03-26 16:45:24 +08:00
2026-03-26 17:39:53 +08:00
-`InputManager::Initialize` 时,用它注册默认的 `Horizontal``Vertical``Mouse X``Mouse Y` 逻辑轴。
- 在运行时,可通过 [RegisterAxis](../InputManager/RegisterAxis.md) 注册自定义具名轴。
- 当前只支持“两键一轴”模型,不支持平滑曲线、死区、灵敏度或设备组合。
## 生命周期
- [Constructor](Constructor.md) 支持默认构造和具名按键构造。
- `InputAxis` 是值类型,通常按值传给 `InputManager`
## 公开方法
| 方法 | 说明 |
2026-03-26 16:45:24 +08:00
|------|------|
2026-03-26 17:39:53 +08:00
| [Constructor](Constructor.md) | 构造一个轴配置对象。 |
| [GetName](GetName.md) | 读取轴名。 |
| [GetPositiveKey](GetPositiveKey.md) | 读取正方向按键。 |
| [GetNegativeKey](GetNegativeKey.md) | 读取负方向按键。 |
| [SetKeys](SetKeys.md) | 修改正负方向按键。 |
| [GetValue](GetValue.md) | 读取对象自身保存的值。 |
| [SetValue](SetValue.md) | 写入对象自身保存的值。 |
2026-03-26 16:45:24 +08:00
## 相关文档
2026-03-26 17:39:53 +08:00
- [当前模块](../Input.md)
- [InputManager](../InputManager/InputManager.md)
- [Input Flow And Frame Semantics](../../../_guides/Input/Input-Flow-and-Frame-Semantics.md)