fix(gamepad): release GCK slots correctly#52
Conversation
|
Warning Review limit reached
More reviews will be available in 46 minutes and 13 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthrough本次改动统一了 2313 兼容键在设置页、类型定义和本地常量中的命名与说明,并调整了 GamepadManager 对 2313 KeyEvent 的处理路径,以及 GC 设备离线时的槽位释放逻辑。 Changes2313 兼容键命名与处理
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Pull request overview
This PR improves Game Controller Kit (GCK) gamepad robustness by fixing slot-release behavior during disconnects (especially with multi-HID interfaces) and clarifying the semantics/UX text around vendor/GCK “menu” keys (2311/2312) and the InputKit compatibility key (2313).
Changes:
- Fix GCK disconnect flow to release the correct slot even if
deviceId -> slotmappings are cleaned before releasing. - Add a guard for unknown GCK OFFLINE events to avoid accidentally freeing slot 0.
- Update comments, mappings, and settings UI copy to describe 2311/2312 as GCK ButtonHome/ButtonMenu and 2313 as a Guide/Mode/Home compatibility key.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| nativelib/src/main/cpp/game_controller_native.h | Clarifies 2311/2312 keycode comments to match GCK naming + observed behavior. |
| entry/src/main/ets/service/input/GamepadTypes.ets | Updates 2311/2312/2313 mapping comments and explains 2313 compatibility semantics. |
| entry/src/main/ets/service/input/GamepadManager.ets | Adjusts GCK disconnect slot release order/logic; adds unknown-OFFLINE guard; updates 2313 commentary in KeyEvent handling. |
| entry/src/main/ets/service/input/GameControllerService.ets | Updates button code documentation to distinguish GCK codes vs 2313 InputKit compatibility key. |
| entry/src/main/ets/pages/SettingsPageV2.ets | Updates settings UI copy to reflect Guide/Mode compatibility wording for 2313 behavior. |
Comments suppressed due to low confidence (1)
entry/src/main/ets/service/input/GamepadManager.ets:1330
- 断开流程里无条件删除 gcPhysicalAddressToDeviceId 中指向该 deviceId 的物理地址映射,但当该 deviceId 是“主设备ID”且仍有其他 HID 接口 deviceId 共享同一 slot 在线时,会导致后续同 physAddr 的新接口无法命中去重(可能被当作新手柄分配新槽位)。建议在存在同 slot 的其他 deviceId 时,把 physAddr 映射迁移到仍在线的 deviceId,而不是直接 delete。
// 清理物理地址映射
const addrEntries = Array.from(this.gcPhysicalAddressToDeviceId.entries());
for (let i = 0; i < addrEntries.length; i++) {
const addr = addrEntries[i][0];
const id = addrEntries[i][1];
if (id === deviceId) {
this.gcPhysicalAddressToDeviceId.delete(addr);
break;
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
改了啥呀
为啥要改
验证
git diff --checknode hvigorw.js assembleHap --no-daemon --no-incremental -p buildMode=debug未通过:本机环境报Invalid value of DEVECO_SDK_HOME,没有进入代码编译阶段。Summary by CodeRabbit
新功能
Bug 修复
文档