Skip to content

feat(PlayCover): 适配 PlayTools 多指触控协议 - #1471

Merged
MistEO merged 2 commits into
mainfrom
feat/playcover-multitouch
Sep 4, 2026
Merged

feat(PlayCover): 适配 PlayTools 多指触控协议#1471
MistEO merged 2 commits into
mainfrom
feat/playcover-multitouch

Conversation

@Lemon-miaow

@Lemon-miaow Lemon-miaow commented Sep 3, 2026

Copy link
Copy Markdown
Member

hguandl/PlayTools@56b0270

Sourcery 摘要

通过更新后的 PlayTools 触控协议支持多点触控输入。

新功能:

  • 在 PlayCover 输入处理中添加对 PlayTools 协议多点触控接触点的支持。

增强功能:

  • 独立跟踪每个活动触控接触点的最新坐标,并支持针对特定接触点的触控生命周期事件。
Original summary in English

Sourcery 摘要

使 PlayCover 触控处理适配 PlayTools 多点触控协议。

新功能:

  • 通过更新后的 PlayTools 触控协议支持多点触控输入,包括每个触点的开始、移动和结束事件。

增强功能:

  • 独立跟踪每个活动触点的最新坐标,并拒绝超出协议范围的触点标识符。
Original summary in English

Sourcery 总结

通过更新后的 PlayTools 触控协议启用 PlayCover 多点触控输入。

新功能:

  • 调整 PlayCover 输入处理,以适配更新后的 PlayTools 协议,支持多点触控接触点及其生命周期事件。

增强功能:

  • 独立跟踪每个活动触控接触点的最新坐标,并根据协议范围验证接触点标识符。

文档:

  • 更新 PlayCover 控制器文档,以反映多点触控支持。
Original summary in English

Summary by Sourcery

Enable PlayCover multi-touch input through the updated PlayTools touch protocol.

New Features:

  • Adapt PlayCover input handling to the updated PlayTools protocol to support multi-touch contacts and their lifecycle events.

Enhancements:

  • Track the latest coordinates independently for each active touch contact and validate contact identifiers against the protocol range.

Documentation:

  • Update the PlayCover controller documentation to reflect multi-touch support.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

您好——我发现了 1 个问题

给 AI Agent 的提示
请处理本次代码审查中的评论:

## 单独评论

### 评论 1
<location path="source/MaaPlayCoverControlUnit/Client/PlayToolsClient.cpp" line_range="240" />
<code_context>
     uint16_t nx = htons(static_cast<uint16_t>(x));
     uint16_t ny = htons(static_cast<uint16_t>(y));
-    uint8_t payload[5] = { static_cast<uint8_t>(phase), 0, 0, 0, 0 };
+    uint8_t payload[6] = { static_cast<uint8_t>(phase), 0, 0, 0, 0, static_cast<uint8_t>(contact) };
     std::memcpy(payload + 1, &nx, sizeof(nx));
     std::memcpy(payload + 3, &ny, sizeof(ny));
</code_context>
<issue_to_address>
**问题 (bug_risk):** 超出 0–255 范围的 contact ID 会通过 `static_cast<uint8_t>(contact)` 被静默缩窄为一个字节。因此,像 0 和 256 这样的 contact 会以相同的线路 ID 发送,但在 `last_touch_points_` 中仍作为不同的键存在;PlayTools 对端会收到发生冲突的触摸标识,从而可能结束错误的手指触摸或移动错误的手指。

**触发条件:** 调用方提供大于 255 或小于 0 的 contact ID 时。

**建议修复:** 在更新状态或发送数据包之前验证 contact 的取值范围,或者在 manager 和 client 的整个流程中使用协议实际限定范围内的 contact 类型。
</issue_to_address>

Sourcery 对开源项目免费——如果您喜欢我们的审查结果,请考虑分享它们 ✨
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用反馈来改进审查结果。
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="source/MaaPlayCoverControlUnit/Client/PlayToolsClient.cpp" line_range="240" />
<code_context>
     uint16_t nx = htons(static_cast<uint16_t>(x));
     uint16_t ny = htons(static_cast<uint16_t>(y));
-    uint8_t payload[5] = { static_cast<uint8_t>(phase), 0, 0, 0, 0 };
+    uint8_t payload[6] = { static_cast<uint8_t>(phase), 0, 0, 0, 0, static_cast<uint8_t>(contact) };
     std::memcpy(payload + 1, &nx, sizeof(nx));
     std::memcpy(payload + 3, &ny, sizeof(ny));
</code_context>
<issue_to_address>
**issue (bug_risk):** Contact IDs outside the 0–255 range are silently narrowed to one byte by `static_cast<uint8_t>(contact)`, so contacts such as 0 and 256 are sent with the same wire ID while remaining distinct keys in `last_touch_points_`; the PlayTools peer receives colliding touch identities and can end or move the wrong finger.

**Triggers:** When a caller supplies a contact ID greater than 255 or a negative contact ID.

**Suggested fix:** Validate the contact range before updating state or sending the packet, or use the protocol's actual bounded contact type throughout the manager and client.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread source/MaaPlayCoverControlUnit/Client/PlayToolsClient.cpp
@Lemon-miaow
Lemon-miaow force-pushed the feat/playcover-multitouch branch from 0ead22d to f4da787 Compare September 3, 2026 11:55
@MistEO

MistEO commented Sep 4, 2026

Copy link
Copy Markdown
Member

文档要改吗?

@MistEO
MistEO merged commit 8e4e84e into main Sep 4, 2026
19 checks passed
@MistEO
MistEO deleted the feat/playcover-multitouch branch September 4, 2026 08:58
@Lemon-miaow

Copy link
Copy Markdown
Member Author

看了一下只有注释有相关的标注 文档没有不需要改

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.

2 participants