feat: add support for stylus barrel roll - #1120
TrueZhuangJia wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (9)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📜 Recent review details🧰 Additional context used📓 Path-based instructions (3)平台抽象层代码(Windows/Linux/macOS)。确保各平台实现一致, 注意 Windows API 调用的错误处理和资源释放。⚙️ CodeRabbit configuration file Files:
Sunshine 核心 C++ 源码,自托管游戏串流服务器。审查要点:内存安全、 线程安全、RAII 资源管理、安全漏洞。注意预处理宏控制的平台相关代码。⚙️ CodeRabbit configuration file Files:
测试文件。验证测试覆盖率、边界情况和断言正确性。⚙️ CodeRabbit configuration file Files:
🔇 Additional comments (11)
Summary by CodeRabbit
Walkthrough新增笔身滚转扩展包的解析、状态探测和转发。输入会话重置时清空队列,并在平台上下文存在时取消全部笔事件。Windows 端使用 Changes笔身滚转输入
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant InputQueue
participant roll_probe_t
participant passthrough
participant pen_update
InputQueue->>roll_probe_t: select(roll, azimuth)
InputQueue->>passthrough: 传递笔数据和所选滚转值
passthrough->>pen_update: 传递平台笔输入
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable issue remains identified for the pen barrel-roll change; it is ready for normal merge checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The extension uses the existing input permissions, validates its fixed-size payload, and preserves legacy pen behavior. No introduced security issue was established. End-to-end identity enforcement and deployed disconnect behavior were not independently verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 24.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 8 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 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 |
qiin2333
left a comment
There was a problem hiding this comment.
整体过了一遍(核心路径核对 + 布局断言实测编译 + magic 全量冲突检查),设计是稳的:
- 魔数
0x5500000B与现有 SS magic(0x55000001–0A)无冲突; - 尺寸不符的扩展包会被 activity tracker 判为
nullopt,在队头(passthrough_next_message直接 return)和批处理循环(erase)两处被丢弃,dispatch/print 不会越界读; - probe 在入队锁内先于 hover 批处理观察每个样本,未激活前注入 azimuth,与改动前行为一致;probe 边界(首包 unknown、legacy 包 reset、变化闩锁)有测试覆盖;
input_t每会话新建,reset仅在join()调用一次,input_stopped终态化无复用路径;Windows cancel 分支先取消 repeat 任务,设备销毁后可经既有 create-if-null 逻辑自然重建;- 端序自洽:header.size = 36(不含 size 字段的 BE)、rotation/barrelRoll 按 LE 编解码,与现有
util::endian::little(packet->rotation)一致; - 主目标
CXX_STANDARD 23满足std::byteswap;pen_barrel_roll.h+ 单测在本仓库 moonlight-common-c 头 + clang-std=c++23下编译和 static_assert 全部通过。
风险按严重度列一下:
中(集成可观测性)
pen_wire::magic尺寸/size 字段不符的包会被静默丢弃,全程无日志。若 voidlink-c 对 header.size 约定或 barrelRoll 端序与主机端不一致,表现将是整场会话笔输入全哑且无任何线索。建议在 evaluate 或入队处对 "magic 命中但 valid_size 失败" 加一条 debug/warning 日志。
低
2. reset() 里的 pen cancel 没有平台门控,所有平台都会执行:
- Linux legacy_input.cpp:会在会话结束时创建可能从未用过的 uinput 笔设备;且全零
pen_input_t(tilt=0、rotation=0 都非 UNKNOWN)会写出一份 tilt(0,0) 的伪报告; - Linux inputtino_pen.cpp:若会话分配过笔设备,cancel 会
place_tool到 (0,0),宿主端笔/光标跳左上角; - macOS 为空实现,无害。
建议#ifdef _WIN32门控(与 SDP 属性一致),或给非 Windows 平台的 pen_update 加 CANCEL_ALL 早退。
static_assert只防了两个 touchpad 魔数,建议对全部现有 SS_* magic 逐一断言,防止未来新增包类型时撞号。- 收到 legacy
SS_PEN包即 reset probe:若客户端协商后混发 legacy/extended 包,probe 永远不会激活。若客户端保证协商后只发 extended 可忽略,请确认 voidlink-c 端行为。 - batch 中
dest_pen->reserved = src_pen->reserved拷贝了客户端可控的保留字段,当前无人读取;建议保持 0 或不拷,防未来误用。 - 新 SDP 属性建议补说明:含义、客户端预期(rotation 字段继续维护 azimuth)、对应 voidlink-c 哪个提交。
需作者确认
7. barrelRoll 按 LE、header.size=36 是主机端假设,和 voidlink-c 的实现对过吗?建议在 PR 描述贴出客户端对应代码引用,方便以后两边对照。
另外目前 checks 只有 CodeRabbit,没看到编译/单测结果;本 PR 动了 Windows 注入路径,合并前建议至少跑一轮 Windows 构建 + 新增的 pen_barrel_roll_unit_tests / input_activity_unit_tests。
补充 c-module 对应 commit: |
Added support for stylus barrel roll negotiation & communication