79 lines
2.5 KiB
Markdown
79 lines
2.5 KiB
Markdown
# InputEvent
|
|
|
|
**命名空间**: `XCEngine::Input`
|
|
|
|
**类型**: `struct`
|
|
|
|
**头文件**: `XCEngine/Input/InputEvent.h`
|
|
|
|
**描述**: 定义 `InputManager` 向外分发的键盘、鼠标、文本和触摸事件数据结构。
|
|
|
|
## 概述
|
|
|
|
`InputEvent.h` 不是单一事件类,而是一组轻量结构体。它们由 `InputManager::Process*` 方法构造,并通过 `Core::Event` 同步广播给订阅者。
|
|
|
|
当前行为特点:
|
|
|
|
- 事件回调是同步触发的,发生在 `Process*` 调用线程中。
|
|
- 键盘和鼠标事件已有具体生成路径。
|
|
- `TouchState` 结构已存在,但当前实现中没有对应的平台填充逻辑。
|
|
|
|
## 结构体
|
|
|
|
### `KeyEvent`
|
|
|
|
| 字段 | 类型 | 说明 |
|
|
|------|------|------|
|
|
| `keyCode` | `KeyCode` | 键值。 |
|
|
| `alt` | `bool` | 事件发生时是否按下 Alt。 |
|
|
| `ctrl` | `bool` | 事件发生时是否按下 Ctrl。 |
|
|
| `shift` | `bool` | 事件发生时是否按下 Shift。 |
|
|
| `meta` | `bool` | 事件发生时是否按下 Meta。当前 Windows 路径始终为 `false`。 |
|
|
| `type` | `KeyEvent::Type` | `Down`、`Up` 或 `Repeat`。 |
|
|
|
|
### `MouseButtonEvent`
|
|
|
|
| 字段 | 类型 | 说明 |
|
|
|------|------|------|
|
|
| `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)
|
|
- [InputManager](../InputManager/InputManager.md)
|
|
- [Input Flow And Frame Semantics](../../../_guides/Input/Input-Flow-and-Frame-Semantics.md)
|