Skip to content

修复手柄连接提示重复和体感状态恢复#24

Merged
qiin2333 merged 1 commit into
masterfrom
fix/ddk-toast-gyro-state
May 11, 2026
Merged

修复手柄连接提示重复和体感状态恢复#24
qiin2333 merged 1 commit into
masterfrom
fix/ddk-toast-gyro-state

Conversation

@qiin2333
Copy link
Copy Markdown
Contributor

@qiin2333 qiin2333 commented May 7, 2026

摘要

  • 对手柄连接通知增加 listener 生命周期内去重,避免 DDK/USB 初始化即时上报与已连接设备补发造成重复 Toast
  • 断开时释放通知 Key,确保真实重连仍会再次提示
  • 修复体感助手退出串流后再次进入时 enabled 状态与传感器监听态不一致的问题
  • dispose() 完整重置体感运行态,避免下次进入需要手动关/开一次

验证

  • get_errors 检查 GamepadManager.etsGyroAssistService.ets:无错误
  • hvigorw assembleHap --mode module -p product=default --no-daemon:BUILD SUCCESSFUL

Summary by CodeRabbit

发布说明

  • 错误修复
    • 解决了游戏手柄连接/断开连接时重复通知的问题,提升连接稳定性
    • 优化陀螺仪辅助功能的性能,消除不必要的资源消耗

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Warning

Rate limit exceeded

@qiin2333 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes and 11 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eb707196-e7ba-4796-9af7-91bb31d011ba

📥 Commits

Reviewing files that changed from the base of the PR and between 85456fe and 4310d68.

📒 Files selected for processing (2)
  • entry/src/main/ets/service/input/GamepadManager.ets
  • entry/src/main/ets/service/input/GyroAssistService.ets
📝 Walkthrough

Walkthrough

本 PR 更新 GamepadManager 以去重连接/断开连接通知,防止初始化竞争和重连流程导致的重复监听器调用;同时改进 GyroAssistService,避免不必要的启停循环并完善状态清理。

Changes

GamepadManager 连接去重

Layer / File(s) Summary
数据结构
entry/src/main/ets/service/input/GamepadManager.ets (56-57)
引入 notifiedConnectionKeys Set,按通知键跟踪已上报的连接事件,防止重复通知。
助手方法
entry/src/main/ets/service/input/GamepadManager.ets (682-711)
新增 getConnectionNotificationKey()notifyGamepadConnectedOnce()notifyGamepadDisconnectedByKey() 私有方法实现去重逻辑。
GCK 初始化路径
entry/src/main/ets/service/input/GamepadManager.ets (358-360, 421-424, 1283-1287, 1335-1336, 1414-1418)
GC Kit 初始化、清理及设备连接事件转用去重通知接口,使用 gc_${deviceId} 作为通知键。
InputKit 设备路径
entry/src/main/ets/service/input/GamepadManager.ets (987-988, 1064-1065, 1678-1679)
传统/InputKit 设备的注册、移除及动态特殊键路径使用去重通知器。
USB 控制器路径
entry/src/main/ets/service/input/GamepadManager.ets (2274-2275, 2338-2339)
USB 控制器添加/移除使用 deviceKey 作为通知键的去重接口。
监听器生命周期管理
entry/src/main/ets/service/input/GamepadManager.ets (663-667, 749-760)
setListener() 检测监听器实例变化并清除去重键缓存;notifyListenerOfExistingDevices() 统一使用去重连接通知器。

GyroAssistService 优化

Layer / File(s) Summary
启停保护
entry/src/main/ets/service/input/GyroAssistService.ets (152-162)
setEnabled() 增加重复调用防护,避免无状态变化时的不必要启停循环。
配置加载
entry/src/main/ets/service/input/GyroAssistService.ets (220-224)
loadSettings() 从激活键重新计算 holdActive,不持有时重置陀螺衍生摇杆值为零。
状态清理
entry/src/main/ets/service/input/GyroAssistService.ets (453-456)
dispose() 完善释放逻辑,显式清零 _enabledholdActive 及陀螺摇杆值。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了两个主要变更:手柄连接提示去重和体感状态恢复,与代码改动内容完全一致。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ddk-toast-gyro-state

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@entry/src/main/ets/service/input/GamepadManager.ets`:
- Around line 662-667: resetSession currently preserves this.listener but
doesn't clear this.notifiedConnectionKeys, so when the same GamepadInputListener
instance is reused setListener(listener) sees no change and
notifiedConnectionKeys remains stale causing notifyGamepadConnectedOnce to
suppress connection toasts; update resetSession() to clear
this.notifiedConnectionKeys at the end of the method (same place the session
state is reset), ensuring notifyListenerOfExistingDevices /
notifyGamepadConnectedOnce will re-notify devices for the new session.
🪄 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

Run ID: 01f29d24-bb93-4c58-9b7f-5c94af61533b

📥 Commits

Reviewing files that changed from the base of the PR and between acf412a and 85456fe.

📒 Files selected for processing (2)
  • entry/src/main/ets/service/input/GamepadManager.ets
  • entry/src/main/ets/service/input/GyroAssistService.ets

Comment thread entry/src/main/ets/service/input/GamepadManager.ets
@qiin2333 qiin2333 force-pushed the fix/ddk-toast-gyro-state branch from 85456fe to 4310d68 Compare May 7, 2026 02:48
@qiin2333 qiin2333 merged commit 213d6d2 into master May 11, 2026
2 checks passed
qiin2333 added a commit that referenced this pull request May 12, 2026
补 v770 changelog 中遗漏的 PR #24 (手柄提示与体感) 和 PR #25 (战报退出
顺序) 优化,以及 PR #26 中自定义按键剪贴板权限门控的用户感知改动。
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.

1 participant