fix(windows): preserve large virtual mouse scroll input - #855
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
WalkthroughWindows 虚拟鼠标的垂直和水平滚轮处理改为按 ChangesWindows 滚轮累积量处理
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/platform/windows/input.cpp`:
- Around line 712-723: Update the virtual mouse scroll handling around scroll(),
hscroll(), and set_mouse_mode(...) so pending vmouse_*scroll_accum values are
not lost when virtual scrolling fails, SendInput fallback occurs, or vmouse_dev
is destroyed. Forward pending deltas through SendInput where appropriate or
explicitly reset them, and add a regression test covering recovery after
virtual-device failure or mode switching.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9bfa8380-c3ab-40fe-b8bd-21a72beaf2d6
📒 Files selected for processing (1)
src/platform/windows/input.cpp
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Windows
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{cpp,c,h}
⚙️ CodeRabbit configuration file
src/**/*.{cpp,c,h}: Sunshine 核心 C++ 源码,自托管游戏串流服务器。审查要点:内存安全、 线程安全、RAII 资源管理、安全漏洞。注意预处理宏控制的平台相关代码。
Files:
src/platform/windows/input.cpp
src/platform/**
⚙️ CodeRabbit configuration file
src/platform/**: 平台抽象层代码(Windows/Linux/macOS)。确保各平台实现一致, 注意 Windows API 调用的错误处理和资源释放。
Files:
src/platform/windows/input.cpp
🔇 Additional comments (2)
src/platform/windows/input.cpp (2)
712-723: 🩺 Stability & Availability请确认累计量更新与发送已被串行化。
vmouse_vscroll_accum和vmouse_hscroll_accum是共享的普通int;新循环把读取、设备发送和扣除拆成了多步。若多个输入回调并发执行,同一轴可能丢失或重复滚轮量。请确认上层调度保证这些函数串行调用;否则应使用互斥量保护整个累计/发送序列。依据路径指令,本文件需要重点检查线程安全。
Also applies to: 743-754
Source: Path instructions
712-723: 🩺 Stability & Availability为异常大的累计量设置处理上限。
当前
while会同步耗尽整个int累计量;极端输入最多可能触发约 14 万次设备调用,长时间阻塞输入线程。设备持续发送失败时,累计值还可能在+= distance处发生有符号整数溢出。请确认上游限制了distance和累计量;否则应限制单次调用的批次数,并保留余量异步续发。Also applies to: 743-754
说明
修复 Zako 虚拟鼠标在大幅垂直或水平滚动时丢失输入的问题。
原实现会从累计值中扣除全部滚轮格数,但 HID 实际发送值会被限制到
[-127, 127],导致超出单次报告范围的滚动量被永久丢弃。Fixes #849
修改
WHEEL_DELTA的高精度滚动余量。