Skip to content

feat: add perf hud controller hotkey#1189

Open
xXJSONDeruloXx wants to merge 1 commit intoutkarshdalal:masterfrom
xXJSONDeruloXx:feat/perf-hud-hotkey
Open

feat: add perf hud controller hotkey#1189
xXJSONDeruloXx wants to merge 1 commit intoutkarshdalal:masterfrom
xXJSONDeruloXx:feat/perf-hud-hotkey

Conversation

@xXJSONDeruloXx
Copy link
Copy Markdown
Contributor

@xXJSONDeruloXx xXJSONDeruloXx commented Apr 12, 2026

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

  • [] If I have access to #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.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in 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.

  • New Features
    • Detects Start + Select + L1 + R1 combo in the physical controller handler and toggles the HUD. Consumes the combo when triggered.
    • Adds a new pref performance_hud_hotkey_enabled (default off) in PrefManager.
    • Adds a toggle in the Performance HUD Quick Menu tab to enable/disable the hotkey, with labels and help text.
    • Wires the hotkey to update HUD visibility and showFps in XServerScreen.

Written for commit 0876048. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Added controller hotkey support (Start + Select + L + R) to quickly toggle the Performance HUD display
    • Added a Quick Menu toggle to enable/disable the Performance HUD hotkey (disabled by default)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Preferences & Configuration
app/src/main/java/app/gamenative/PrefManager.kt, app/src/main/res/values/strings.xml
Added persisted boolean preference performanceHudHotkeyEnabled (default false) and corresponding string resources for the hotkey label and combo description (Start + Select + L + R).
UI Components
app/src/main/java/app/gamenative/ui/component/QuickMenu.kt
Extended QuickMenu composable with isPerformanceHudHotkeyEnabled and onPerformanceHudHotkeyToggled parameters; added toggle UI row in HUD tab.
Controller Input Handling
app/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.kt
Introduced combo detection via heldButtons set and COMBO_KEYCODES for four-button press sequence; onKeyEvent now intercepts the combo when repeatCount == 0 and invokes onTogglePerformanceHud callback if hotkey is enabled.
Screen Integration
app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
Wired PhysicalControllerHandler with onTogglePerformanceHud callback (toggles HUD and persists state) and isPerformanceHudHotkeyEnabled flag; passed hotkey state and toggle callback to QuickMenu.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • phobos665

Poem

🐰 Four buttons dance—Start, Select, then L and R align,
A rabbit's secret hotkey shines so bright and fine,
The HUD springs forth with glee and speed,
A twitchy toggle trick indeed! 🎮✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a controller hotkey feature for the performance HUD.
Description check ✅ Passed The description covers the feature rationale, implementation details, and includes a recording and completed checklist items, though one checkbox is technically incomplete.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@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

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 277cc9c and 0876048.

📒 Files selected for processing (5)
  • app/src/main/java/app/gamenative/PrefManager.kt
  • app/src/main/java/app/gamenative/ui/component/QuickMenu.kt
  • app/src/main/java/app/gamenative/ui/screen/xserver/PhysicalControllerHandler.kt
  • app/src/main/java/app/gamenative/ui/screen/xserver/XServerScreen.kt
  • app/src/main/res/values/strings.xml

Comment on lines +25 to +27
private val onOpenNavigationMenu: (() -> Unit)? = null,
private val onTogglePerformanceHud: (() -> Unit)? = null,
private val isPerformanceHudHotkeyEnabled: () -> Boolean = { false },
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.

⚠️ Potential issue | 🟠 Major

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.

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