feat: add perf hud controller hotkey#1189
feat: add perf hud controller hotkey#1189xXJSONDeruloXx wants to merge 1 commit intoutkarshdalal:masterfrom
Conversation
📝 WalkthroughWalkthroughThis pull request introduces a controller hotkey feature that allows users to toggle the Performance HUD by pressing a four-button combo (Start + Select + L + R). A new preference is added to persist the hotkey-enabled state, UI controls are added to the QuickMenu for enabling/disabling the feature, and the controller handler is updated to detect and intercept the button combo to trigger the toggle. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Handler as PhysicalControllerHandler
participant Screen as XServerScreen
participant Manager as PrefManager
participant HUD as Performance HUD
User->>Handler: Press Start button (repeatCount=0)
activate Handler
Handler->>Handler: Add Start to heldButtons
deactivate Handler
User->>Handler: Press Select button (repeatCount=0)
activate Handler
Handler->>Handler: Add Select to heldButtons
deactivate Handler
User->>Handler: Press L button (repeatCount=0)
activate Handler
Handler->>Handler: Add L to heldButtons
deactivate Handler
User->>Handler: Press R button (repeatCount=0)
activate Handler
Handler->>Handler: Add R to heldButtons<br/>(all combo keycodes held)
Handler->>Manager: Check isPerformanceHudHotkeyEnabled()
Manager-->>Handler: true
Handler->>Screen: onTogglePerformanceHud()
activate Screen
Screen->>Screen: Toggle isPerformanceHudEnabled
Screen->>Manager: setPref showFps
Screen->>HUD: updatePerformanceHud(enabled)
HUD-->>Screen: HUD updated
deactivate Screen
Handler->>Handler: Clear heldButtons
Handler->>Handler: Consume key event (return true)
deactivate Handler
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.kt">
<violation number="1" location="app/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.kt:88">
P2: HUD hotkey combo state is global across devices, allowing mixed button presses from multiple controllers to trigger the combo unintentionally.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
app/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt (1)
1737-1748: Centralize performance HUD toggling.This callback duplicates the existing menu path around Line 929, and the two paths have already drifted: the quick-menu branch emits
performance_hud_toggled, this one does not. A shared helper would keep state, persistence, and telemetry in sync.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt` around lines 1737 - 1748, The onTogglePerformanceHud lambda in the PhysicalControllerHandler duplicates logic elsewhere and omits emitting the telemetry event; replace the inline lambda with a call to a centralized helper (e.g., add a function togglePerformanceHud() used from XServerScreen and the quick-menu path) that flips isPerformanceHudEnabled, sets PrefManager.showFps, calls updatePerformanceHud(enabled), and emits the existing "performance_hud_toggled" telemetry/event; update the PhysicalControllerHandler instantiation to pass this helper and remove duplicated state/persistence/telemetry logic so both code paths stay in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.kt`:
- Around line 25-27: The chord handling currently only consumes the final
ACTION_DOWN and clears heldButtons, letting the initial ACTION_DOWNs and later
ACTION_UPs fall through; modify the logic that processes controller input (the
code paths using heldButtons, ACTION_DOWN, ACTION_UP) so that all press/release
events for a potential chord are buffered/suppressed until the chord resolves
(use a temporary buffer/list to collect events instead of forwarding
immediately), then when the chord is recognized call onTogglePerformanceHud() or
onOpenNavigationMenu() and either swallow the buffered events or replay them in
correct order (replaying paired DOWN/UP to avoid unmatched releases) based on
whether the chord should block game input; ensure
isPerformanceHudHotkeyEnabled() gating remains and remove the immediate
heldButtons.clear() forwarding behavior so no initial downs fall through.
---
Nitpick comments:
In `@app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt`:
- Around line 1737-1748: The onTogglePerformanceHud lambda in the
PhysicalControllerHandler duplicates logic elsewhere and omits emitting the
telemetry event; replace the inline lambda with a call to a centralized helper
(e.g., add a function togglePerformanceHud() used from XServerScreen and the
quick-menu path) that flips isPerformanceHudEnabled, sets PrefManager.showFps,
calls updatePerformanceHud(enabled), and emits the existing
"performance_hud_toggled" telemetry/event; update the PhysicalControllerHandler
instantiation to pass this helper and remove duplicated
state/persistence/telemetry logic so both code paths stay in sync.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6ffdb0c6-5f18-4d96-abe4-dd1929bf4b89
📒 Files selected for processing (5)
app/src/main/java/app/gamenative/PrefManager.ktapp/src/main/java/app/gamenative/ui/component/QuickMenu.ktapp/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.ktapp/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.ktapp/src/main/res/values/strings.xml
| private val onOpenNavigationMenu: (() -> Unit)? = null, | ||
| private val onTogglePerformanceHud: (() -> Unit)? = null, | ||
| private val isPerformanceHudHotkeyEnabled: () -> Boolean = { false }, |
There was a problem hiding this comment.
The controller chord still leaks into normal game input.
Only the final ACTION_DOWN is consumed. The first three button-downs still fall through to profile/game handling, and after heldButtons.clear() all four ACTION_UPs do too. That means the hotkey can still trip Binding.OPEN_NAVIGATION_MENU or any mapped game action before the HUD toggles, and the last button can emit an unmatched release. Buffer/suppress the whole chord until it resolves, then either swallow or replay the sequence.
Also applies to: 36-46, 86-96
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@app/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.kt`
around lines 25 - 27, The chord handling currently only consumes the final
ACTION_DOWN and clears heldButtons, letting the initial ACTION_DOWNs and later
ACTION_UPs fall through; modify the logic that processes controller input (the
code paths using heldButtons, ACTION_DOWN, ACTION_UP) so that all press/release
events for a potential chord are buffered/suppressed until the chord resolves
(use a temporary buffer/list to collect events instead of forwarding
immediately), then when the chord is recognized call onTogglePerformanceHud() or
onOpenNavigationMenu() and either swallow the buffered events or replay them in
correct order (replaying paired DOWN/UP to avoid unmatched releases) based on
whether the chord should block game input; ensure
isPerformanceHudHotkeyEnabled() gating remains and remove the immediate
heldButtons.clear() forwarding behavior so no initial downs fall through.
Description
adds optional button combo L + R + Start + Select to toggle perf hud on and off.
this is helpful to streamline pulling up hud to see bottlenecks or fix up settings, then can easily dismiss to focus on the game without having to go into quick menu and resume game.
also allowing the disabling of this in pref managed toggle in the off chance a game wants this exact combo and user doesn't want that to also touch hud.
chose this combo as really any handheld should have LRStartSel even the most basic ones
Recording
screen-20260412-123050-under10mb.mp4
Checklist
#code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.CONTRIBUTING.md.Summary by cubic
Add a controller hotkey to toggle the Performance HUD with Start + Select + L + R. This makes it fast to check performance and then hide the HUD without opening the Quick Menu.
performance_hud_hotkey_enabled(default off) inPrefManager.showFpsinXServerScreen.Written for commit 0876048. Summary will update on new commits.
Summary by CodeRabbit