Skip to content

feat: 新增 EasyCon.WinInput 项目,支持手柄/键盘输入绑定#41

Merged
ca1e merged 3 commits into
devfrom
feature/wininput-gamepad
Apr 25, 2026
Merged

feat: 新增 EasyCon.WinInput 项目,支持手柄/键盘输入绑定#41
ca1e merged 3 commits into
devfrom
feature/wininput-gamepad

Conversation

@ca1e

@ca1e ca1e commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 新建 EasyCon.WinInput 类库(net10.0-windows),包含 GamepadInputBinder、KeyboardInputBinder、GamepadMapper 等组件
  • EasyCon.Core 新增 IInputBinder 接口,定义输入绑定的统一契约
  • 将 KeyBinder 和 LowLevelKeyboard 从 EasyCon2.Avalonia.Core/VPad 迁移至 EasyCon.WinInput
  • VPadService 通过 IInputBinder 策略模式切换输入源
  • EasyConForm 集成游戏手柄输入绑定功能
  • 新增 GamepadApiDemo 工具项目

Test plan

  • 编译通过:dotnet build EasyCon2.slnx
  • WinForms 主界面可正常启动,虚拟手柄面板可用
  • 手柄输入绑定可启用/禁用
  • 键盘输入绑定功能不受迁移影响
  • Avalonia 版本编译不受影响

- 新建 EasyCon.WinInput 类库,包含 GamepadInputBinder、KeyboardInputBinder、GamepadMapper 等组件
- 将 KeyBinder 和 LowLevelKeyboard 从 Avalonia.Core 迁移至 WinInput
- 新增 IInputBinder 接口到 EasyCon.Core
- 更新 VPadService、JCPainter 适配新结构
- EasyConForm 集成游戏手柄输入绑定
- 新增 GamepadApiDemo 工具项目
@ca1e

ca1e commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

Code Review

严重问题

1. .gitignore**.md 规则过于激进

.gitignore 第 10 行 **.md 会忽略所有 Markdown 文件,包括 README.mdCHANGELOG.md 等有价值的文档。应改为只忽略特定文件。

2. PLAN.md 不应提交

这个文件包含任务规划的临时内容,不属于代码库。

3. GamepadInputBinder._enabled 线程安全问题

GamepadInputBinder.cs 第 201 行 — _enabledOnStateChanged(GamepadApi 回调线程)中读取,在 SetEnabled(UI 线程)中写入,无同步保护。应标记为 volatile

中等问题

4. RegisterEscapeHook 可能重复注册

EasyConForm.cs 第 582-594 行 — 每次点击"连接"按钮都调用 RegisterEscapeHookLowLevelKeyboard.RegisterKeyEvent 如果不内部去重,会注册多个 ESC 回调。

轻微问题

5. comboInputMode_SelectedIndexChanged 有注释掉的代码

EasyConForm.cs 第 511 行 — 应移除或说明意图。

6. GamepadMapper 缺少单元测试

Map 是纯函数,输入 GamepadState 输出 SwitchReport,非常适合单元测试,建议补充。

ca1e added 2 commits April 25, 2026 22:06
- IInputBinder 新增 RegisterEscapeKey,通过 VPadService 暴露 ESC 注册
- LowLevelKeyboard 改为 internal,EasyConForm 不再直接引用
- GamepadInputBinder._enabled 加 volatile 修复线程安全
- .gitignore 替换 **.md 为具体文件名
- 删除 EasyConForm 中注释代码
- 新增 EasyCon.WinInput.Tests 项目,GamepadMapper 11 项单元测试
@ca1e ca1e merged commit d0689d2 into dev Apr 25, 2026
3 checks passed
@ca1e ca1e deleted the feature/wininput-gamepad branch April 25, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant