docs: rebuild Input API content

This commit is contained in:
2026-03-26 17:39:53 +08:00
parent ec4edb2689
commit ce2eee32e3
54 changed files with 1108 additions and 941 deletions

View File

@@ -6,34 +6,73 @@
**头文件**: `XCEngine/Input/InputEvent.h`
**描述**: 定义 `XCEngine/Input` 子目录中的 `InputEvent` public API
**描述**: 定义 `InputManager` 向外分发的键盘、鼠标、文本和触摸事件数据结构
## 概述
`InputEvent.h` `XCEngine/Input` 子目录 下的 public header当前页面作为平行目录中的 canonical 总览,用于汇总该头文件暴露的主要声明
`InputEvent.h` 不是单一事件类,而是一组轻量结构体。它们由 `InputManager::Process*` 方法构造,并通过 `Core::Event` 同步广播给订阅者
## 声明概览
当前行为特点:
| 声明 | 类型 | 说明 |
- 事件回调是同步触发的,发生在 `Process*` 调用线程中。
- 键盘和鼠标事件已有具体生成路径。
- `TouchState` 结构已存在,但当前实现中没有对应的平台填充逻辑。
## 结构体
### `KeyEvent`
| 字段 | 类型 | 说明 |
|------|------|------|
| `KeyEvent` | `struct` | 头文件中的公开声明。 |
| `MouseButtonEvent` | `struct` | 头文件中的公开声明。 |
| `MouseMoveEvent` | `struct` | 头文件中的公开声明。 |
| `MouseWheelEvent` | `struct` | 头文件中的公开声明。 |
| `TextInputEvent` | `struct` | 头文件中的公开声明。 |
| `TouchState` | `struct` | 头文件中的公开声明。 |
| `keyCode` | `KeyCode` | 键值。 |
| `alt` | `bool` | 事件发生时是否按下 Alt。 |
| `ctrl` | `bool` | 事件发生时是否按下 Ctrl。 |
| `shift` | `bool` | 事件发生时是否按下 Shift。 |
| `meta` | `bool` | 事件发生时是否按下 Meta。当前 Windows 路径始终为 `false`。 |
| `type` | `KeyEvent::Type` | `Down``Up``Repeat`。 |
## 结构体成员
### `MouseButtonEvent`
| 成员 | 类型 | 描述 | 默认值 |
|------|------|------|--------|
| `keyCode` | `KeyCode` | 结构体公开字段。 | - |
| `alt` | `bool` | 结构体公开字段。 | - |
| `ctrl` | `bool` | 结构体公开字段。 | - |
| `shift` | `bool` | 结构体公开字段。 | - |
| `meta` | `bool` | 结构体公开字段。 | - |
| 字段 | 类型 | 说明 |
|------|------|------|
| `button` | `MouseButton` | 鼠标按键。 |
| `position` | `Math::Vector2` | 事件位置。 |
| `type` | `MouseButtonEvent::Type` | `Pressed``Released` |
### `MouseMoveEvent`
| 字段 | 类型 | 说明 |
|------|------|------|
| `position` | `Math::Vector2` | 当前鼠标位置。 |
| `delta` | `Math::Vector2` | 相对上一次输入事件的位移。 |
### `MouseWheelEvent`
| 字段 | 类型 | 说明 |
|------|------|------|
| `position` | `Math::Vector2` | 鼠标位置。 |
| `delta` | `float` | 滚轮增量。 |
### `TextInputEvent`
| 字段 | 类型 | 说明 |
|------|------|------|
| `character` | `char` | 输入的单字符。 |
| `text` | `Containers::String` | 当前实现中为长度 1 的字符串。 |
### `TouchState`
| 字段 | 类型 | 说明 |
|------|------|------|
| `touchId` | `int` | 触点 ID。 |
| `position` | `Math::Vector2` | 触点位置。 |
| `deltaPosition` | `Math::Vector2` | 位置变化量。 |
| `deltaTime` | `float` | 与前一状态的时间差。 |
| `tapCount` | `int` | 点击次数。 |
| `phase` | `TouchState::Phase` | `Began``Moved``Stationary``Ended``Canceled`。 |
## 相关文档
- [当前目录](../Input.md) - 返回 `Input` 平行目录
- [API 总索引](../../../main.md) - 返回顶层索引
- [当前模块](../Input.md)
- [InputManager](../InputManager/InputManager.md)
- [Input Flow And Frame Semantics](../../../_guides/Input/Input-Flow-and-Frame-Semantics.md)