GFramework/GFramework.Godot/input/GodotInputBridge.cs
GwWuYou 028ece27db ```
refactor(input): 重构Godot输入模块为抽象基类并优化输入处理流程

将 `GodotInputModule` 重命名为 `AbstractGodotInputModule` 并改为抽象类,
以便支持更灵活的输入翻译器注册机制。引入 `GodotInputPhase` 枚举和
`GodotRawInput` 结构体以区分输入处理的不同阶段(捕获与冒泡)。
同时修改 `GodotInputTranslator` 仅在Bubble阶段生成游戏事件,提升输入处理精度。
```
2025-12-21 16:52:36 +08:00

42 lines
1018 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using GFramework.Game.input;
using Godot;
namespace GFramework.Godot.input;
/// <summary>
/// Godot输入桥接类用于将Godot的输入事件转换为游戏框架的输入事件
/// </summary>
public partial class GodotInputBridge : Node
{
private InputSystem _inputSystem = null!;
/// <summary>
/// 绑定输入系统
/// </summary>
/// <param name="inputSystem">要绑定的输入系统实例</param>
public void Bind(InputSystem inputSystem)
{
_inputSystem = inputSystem;
}
/// <summary>
/// 捕获阶段:最早
/// </summary>
public override void _Input(InputEvent @event)
{
_inputSystem.HandleRaw(
new GodotRawInput(@event, GodotInputPhase.Capture)
);
}
/// <summary>
/// 冒泡阶段UI 未处理
/// </summary>
public override void _UnhandledInput(InputEvent @event)
{
_inputSystem.HandleRaw(
new GodotRawInput(@event, GodotInputPhase.Bubble)
);
}
}