feat(PlayCover): 适配 PlayTools 多指触控协议 - #1471
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
您好——我发现了 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>帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用反馈来改进审查结果。
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Lemon-miaow
force-pushed
the
feat/playcover-multitouch
branch
from
September 3, 2026 11:55
0ead22d to
f4da787
Compare
Lemon-miaow
force-pushed
the
feat/playcover-multitouch
branch
from
September 3, 2026 12:07
f4da787 to
d45d1a3
Compare
4 tasks
Member
|
文档要改吗? |
Member
Author
|
看了一下只有注释有相关的标注 文档没有不需要改 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hguandl/PlayTools@56b0270
Sourcery 摘要
通过更新后的 PlayTools 触控协议支持多点触控输入。
新功能:
增强功能:
Original summary in English
Sourcery 摘要
使 PlayCover 触控处理适配 PlayTools 多点触控协议。
新功能:
增强功能:
Original summary in English
Sourcery 总结
通过更新后的 PlayTools 触控协议启用 PlayCover 多点触控输入。
新功能:
增强功能:
文档:
Original summary in English
Summary by Sourcery
Enable PlayCover multi-touch input through the updated PlayTools touch protocol.
New Features:
Enhancements:
Documentation: