Skip to content

fix(haptics): 恢复按键触感并统一机身振动 - #96

Merged
qiin2333 merged 3 commits into
masterfrom
codex/fix-key-haptics
Jul 30, 2026
Merged

fix(haptics): 恢复按键触感并统一机身振动#96
qiin2333 merged 3 commits into
masterfrom
codex/fix-key-haptics

Conversation

@qiin2333

@qiin2333 qiin2333 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

改了啥呀

  • 新增统一机身振动协调器,集中管理按键、游戏和音频对机身马达的写入
  • 将虚拟手柄、虚拟键盘、自定义按键和设置滑块接入协调器
  • 按键触感固定走本机默认马达,保留原来的 id 0 + usage: touch + time 语义和持续时间
  • 按键脉冲期间暂缓游戏/音频机身输出,结束后恢复最新有效状态
  • USB/手柄 rumble() 路径保持不变,不会被按键触感偷偷带跑呀

为啥要改

多个调用点各自直写同一机身马达时,连续游戏或音频振动可能覆盖短促的按键触感。现在把这只会吞触感的杂鱼竞态收进统一协调器,按键优先级和恢复时机都有明确边界。

验证

  • npm run check
  • node hvigorw.js default@CompileArkTS --mode module -p module=entry -p product=default -p buildMode=debug --no-daemon(API 24 SDK + JDK 17)
  • git diff --check
  • 确认业务代码中的 startVibration / stopVibration 只保留在协调器内

Summary by CodeRabbit

  • 新功能
    • 新增统一的设备振动协调机制:在触觉反馈期间独占并完成后恢复来源振动。
    • 根据设备能力自动判断并启用高清振动能力(按需降级)。
  • 体验优化
    • 按键、滑块、虚拟键盘与虚拟控制器的触觉反馈更一致稳定。
    • 触觉与游戏手柄振动的冲突显著减少,停止/恢复流程更可靠(含立即停止与全量停止)。

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@qiin2333, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 reviews.

How do review 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 refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2269eff3-1d52-4d5e-9dcf-e15c0600a7bc

📥 Commits

Reviewing files that changed from the base of the PR and between 82ae00a and 98f261f.

📒 Files selected for processing (1)
  • entry/src/main/ets/service/input/DeviceVibrationCoordinator.ets
📝 Walkthrough

Walkthrough

新增 DeviceVibrationCoordinator 统一处理触觉与来源振动,并将多个触觉组件及 GamepadVibrationService 的直接振动调用迁移至该协调器。

Changes

设备振动协调与调用迁移

Layer / File(s) Summary
协调器核心实现
entry/src/main/ets/service/input/DeviceVibrationCoordinator.ets
新增单例协调器,处理触觉独占、来源振动恢复、竞态控制、高清振动设备查询及停止降级。
触觉组件调用迁移
entry/src/main/ets/components/CustomKeyConstants.ets, entry/src/main/ets/components/SettingSlider.ets, entry/src/main/ets/components/virtual/*
按键、滑块、虚拟控制器和虚拟键盘改用 playTouchHaptic 触发触觉反馈。
游戏手柄振动服务接入
entry/src/main/ets/service/input/GamepadVibrationService.ets
游戏手柄振动服务改用协调器执行来源振动、停止操作、能力判断及触觉冲突恢复。

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-key-haptics

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.

@coderabbitai coderabbitai 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.

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/DeviceVibrationCoordinator.ets`:
- Around line 52-112: 将 DeviceVibrationCoordinator 的触感启动流程改为与来源振动请求共享的串行队列,确保旧的
startVibration 完成或失效后才执行新的 stop/start 操作,避免旧请求覆盖触感。围绕
playTouchHaptic、startSourceVibration 和 stopSourceVibration 统一排队 stop/start
请求,并在每个请求完成前复核 touchHapticEpoch/sourceEpoch;保留现有过期回调抑制和失败处理行为。
🪄 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 Plus

Run ID: 04fe53d6-2ca5-4fde-87e3-29370b8cba46

📥 Commits

Reviewing files that changed from the base of the PR and between 1290f84 and d385ca5.

📒 Files selected for processing (6)
  • entry/src/main/ets/components/CustomKeyConstants.ets
  • entry/src/main/ets/components/SettingSlider.ets
  • entry/src/main/ets/components/virtual/VirtualController.ets
  • entry/src/main/ets/components/virtual/VirtualKeyboard.ets
  • entry/src/main/ets/service/input/DeviceVibrationCoordinator.ets
  • entry/src/main/ets/service/input/GamepadVibrationService.ets

Comment thread entry/src/main/ets/service/input/DeviceVibrationCoordinator.ets

@coderabbitai coderabbitai 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.

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/DeviceVibrationCoordinator.ets`:
- Around line 105-196: 为 vibrationQueue 增加 native 调用超时兜底:在
executeTouchHaptic、executeSourceVibration 和 stopLocalVibration 使用的
vibrator.startVibration()/stopVibration() Promise 外层包装超时,使 native Promise 长时间未
settle 时主动 resolve 当前队列步骤并记录超时;保持现有 epoch、active 状态判断及失败回调逻辑不变,确保后续请求不会被永久阻塞。
🪄 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 Plus

Run ID: 771ffe0f-8f60-4ee5-8c55-7a10a8431878

📥 Commits

Reviewing files that changed from the base of the PR and between d385ca5 and 82ae00a.

📒 Files selected for processing (1)
  • entry/src/main/ets/service/input/DeviceVibrationCoordinator.ets

Comment thread entry/src/main/ets/service/input/DeviceVibrationCoordinator.ets
@qiin2333
qiin2333 merged commit 1afa53c into master Jul 30, 2026
2 checks passed
@qiin2333
qiin2333 deleted the codex/fix-key-haptics branch July 30, 2026 03:47
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