Skip to content

fix(hid): add CH9329 macOS drag compatibility - #304

Open
drgnchan wants to merge 2 commits into
mofeng-git:devfrom
drgnchan:fix/ch9329-macos-drag
Open

fix(hid): add CH9329 macOS drag compatibility#304
drgnchan wants to merge 2 commits into
mofeng-git:devfrom
drgnchan:fix/ch9329-macos-drag

Conversation

@drgnchan

Copy link
Copy Markdown

Closes #303

改动摘要

  • 新增默认关闭的 ch9329_macos_drag 运行兼容选项;
  • 在设置页新增“macOS 拖拽兼容模式”开关及中英文说明;
  • 兼容模式下:
    • 未按键时继续使用 CH9329 绝对鼠标报告;
    • Button Down / Button Up 使用绝对 report ID 2;
    • 按住期间把连续绝对坐标差值按当前画面分辨率换算为相对位移,通过 report ID 1 发送;
  • 非零微小位移至少保留为 ±1,大位移限制在 CH9329 i8 范围;
  • 保持默认模式及现有 ch9329_hybrid_mouse Linux 兼容模式行为不变;若两个兼容选项同时打开,macOS 按钮边沿策略优先。

根因与实机证据

真实设备环境:

  • CH9329 V3.0
  • WCH UART TO KB-MS_V2.0,VID/PID 1A86:E12A
  • 9600 baud
  • macOS 26.5.2 / Apple Silicon
  • RustDesk 1.4.9 与 Web Console 均可复现

目标 macOS 上通过 IOHIDManager 捕获原始 USB Report:失败拖拽期间连续 107 个 report ID 2 均保持 buttons=0x01,约 6.36 秒后用户实际松手才出现 buttons=0x00。因此 One-KVM 状态机、串口命令及 CH9329 USB 输出均未提前松键。

macOS 对该 CH9329 设备表现为:绝对集合可点击但持续绝对移动会破坏拖拽;相对集合可移动但按钮无效。现有 Linux 混合模式因此无法解决。采用“绝对按钮边沿 + 按住期间相对移动”后,已在真实 macOS 目标机验证窗口、文件及文本拖拽正常。

测试

  • cargo test --target x86_64-unknown-linux-gnu 'hid::ch9329::tests' --lib
    • 18 passed
  • cargo check --target x86_64-unknown-linux-gnu --bin one-kvm
  • cd web && npm run build

新增端到端队列级单元测试,固定以下 CH9329 命令顺序:

  1. 绝对 hover;
  2. 绝对 button down;
  3. 相对 drag move;
  4. 绝对 button up。

@liaokaiaizxl liaokaiaizxl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在Mac OS系统下的确存在这个情况,我分别换了苹果13,15,26都存在这个温问题,要请及时完成审核以便修复此问题

@liaokaiaizxl

Copy link
Copy Markdown

确实存在这个问题,请及时给与修复

@mofeng-git
mofeng-git changed the base branch from main to dev September 6, 2026 03:24
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.

fix(hid): CH9329 在 macOS 下无法持续拖拽

2 participants