WP-118: TV remote D-pad focus in the launcher and menus

Status: ✅ Done (2026-11-30). Built and checked on the TCL with adb’s D-pad: fork PR barefootbetters/scummvm#46 merged on 2026-11-30 (merge commit 5cdb64e880), private PR barefootbetters/scooby-engine-private#64 merged the same day (6c8e3eb655), versionCode 26041040 on the TV. The grid is the TV default again, and OK in it opens the tray (D5, 2026-11-30). Jeff’s 3 m check passed on 2026-11-30 (criterion 4). Closed on Jeff’s word (2026-11-30) with criteria 3, 5 and 6 partly checked, as noted under each: Help, a controller, and Windows beyond the launcher (§Result). Decisions D1–D6 answered by Jeff on 2026-11-29, all as recommended (§Decisions, DECISIONS.md). Pre-flighted 2026-11-29, READY. Phase: 5 (polish & distribution). Depends on:

Unblocks: WP-104 exit criterion 10 (the remote’s arrows), the grid as the TV default again (D7), and a remote-only first run. Companion EC: EC-018. Pre-flight: required. The packet changes the fork’s shared GUI code (gui/**) and the Android backend’s default bindings, outside engines/terraglyph/. Targets generation(s): none. The GUI is engine-independent; no Gen 1–3 claim is made. Estimated effort: three to five days, most of it the focus traversal and the device checks.


Goal

In ScummVM’s own screens on the TV (the launcher, its dialogs and the in-game menu), the remote’s D-pad moves a visible focus from control to control, OK activates the focused control, and BACK closes the dialog, instead of the D-pad driving the on-screen pointer. Something is focused whenever a dialog opens. The launcher’s grid view works the same way, so it can be the TV default again.

Background

Scope

In scope

  1. Focus traversal in GUI::Dialog. Up, Down, Left and Right move the focus to the nearest focusable widget in that direction, chosen by on-screen geometry (D3). Focusable: buttons (and drop-down and picture buttons), checkboxes, radio buttons, sliders, pop-ups, tabs, the list, the grid, edit fields. A focused widget that uses the arrow itself (the list moving its selection, a slider changing its value, a tab row moving between tabs) keeps it, and passes the press on at its edge (the list’s last row, the slider’s end).
  2. Activation. OK (JOY_CENTER, JOY_A, Enter) activates the focused widget as a click would: presses a button, toggles a checkbox, opens a pop-up or starts the selected game. BACK closes the dialog, as today.
  3. Initial focus. Every dialog opens with a control focused: the launcher on the game list’s selection (or its first game), other dialogs on their first focusable widget or a default the dialog names. In the grid, the search field is not the initial focus (the touch-keyboard pop-up).
  4. The focus is visible. The focused widget draws in a focus state (D4), in both the stock themes and the TV theme, readable at 3 m. Scroll containers (the options tabs) scroll to keep the focus in view.
  5. The grid. The grid takes focus (upstream fa8126a019 brought in), and the arrows move its selection by cell, scrolling as needed. OK started the game as first written; since 2026-11-30 it opens the entry’s tray (Play, Saves, Options), as a click does (Jeff’s call, after D5).
  6. The bindings. In the GUI keymap, the D-pad (JOY_UP…JOY_RIGHT, and JOY_HAT_* for game controllers) maps to Up, Down, Left and Right, which wins over the Global Virtual Mouse in GUI context. Where this applies is D2. The left stick keeps the Virtual Mouse, and every binding stays remappable in Global Options → Keymaps.
  7. The screens checked on the TCL 65Q77K with the stock remote: the launcher (list and grid, the buttons, search), Global Options (each tab), Game Options, About, the file browser (Add Game), message boxes (the testing warning), the in-game menu, save and load. Jeff checks at 3 m.

Out of scope

Decisions for Jeff

Jeff, 2026-11-29: “Yes, all six”. Every recommendation below is the decision.

# Question Options Recommendation (approved)
D1 How far the traversal reaches (a) generic, in GUI::Dialog, for every dialog; (b) the launcher only, first (a). A launcher-only version leaves the remote stuck the moment any dialog opens (Add Game, Options, a message box), which is the problem Jeff hit.
D2 Where the D-pad goes to focus (a) every Android build; (b) TV builds only (a leanback device, or the TV app’s packaged defaults); (c) a setting, default on for TV (b). Phones and tablets keep today’s pointer behaviour, and the TV app turns focus on with the tvapp.ini defaults WP-104 already reads.
D3 The direction rule (a) the Hotspot Magnet core’s rules, rewritten in gui/ (beam, then score, integer tie-break); (b) a simpler nearest-centre rule; (c) move WP-106’s navigate() to common/ and share it (a). Same behaviour players learn in games, no dependency between gui/ and engines/. (c) waits for WP-106 to exist and for maintainer feedback (plan H4).
D4 The focus state’s look (a) reuse the highlight (hover) state; (b) a new focus state with its own theme draw steps (a) first. No theme-format change, and WP-104’s theme already makes the highlight readable. (b) if Jeff’s 3 m check can’t tell focus from hover.
D5 The grid as TV default again (D7) (a) in this packet, after Jeff’s 3 m check passes in the grid; (b) a later change (a). D7 made the list a stopgap until D-pad navigation works; this packet is that condition.
D6 Upstream (a) write it upstream-ready and offer it to the ScummVM team after it ships here; (b) keep it fork-only (a). The Android comment above asks for exactly this. Upstream’s AI-GUIDELINES.md (recorded at WP-010) governs any submission, so Jeff decides how it’s sent.

Dependencies

Execution

  1. Fork worktree with tools/New-ForkWorktree.ps1; cherry-pick upstream fa8126a019.
  2. The traversal and activation in GUI::Dialog and the widgets (scope 1–3), then the focus state (scope 4) and the grid (scope 5).
  3. The Android bindings (scope 6), as D2 decides.
  4. Windows build: keyboard arrows move the focus in every scope-7 screen, the mouse behaves as before.
  5. TV build, versionCode above the TV’s, adb install -r (never uninstall or clear data); scope 7 on the TCL with screencaps, then Jeff at 3 m.
  6. D5, if (a): the TV default back to the grid, Jeff’s check in the grid.
  7. Fork PR into scooby-engine; docs close (this WP, WORK_INDEX, WP-104 criterion 10, D7’s note in DECISIONS.md).

Exit criteria

  1. On the TCL, in the launcher’s list view, the D-pad moves a visible focus between the game list and every button, and the list’s selection with Up and Down; OK starts the selected game (screencaps). Checked with adb’s D-pad, which reaches ScummVM as the remote does (JE_GAMEPAD, then JOY_*); the stock remote itself is criterion 4.
  2. Same in the grid view, by cell; the touch keyboard doesn’t open on launch (screencaps). OK opens the entry’s tray with Play focused, and the D-pad reaches Saves and Options in it (commit 7, §Result).
  3. Partly. Every dialog checked opens with a control focused, and its controls can be reached and activated with the D-pad and OK alone; BACK closes it (screencaps). Checked:
    • the launcher;
    • Global Options: the Graphics, Control, Keymaps and Volume tabs walked; the others reached on the tab row, not walked;
    • Game Options (its Game tab);
    • About;
    • Add Game’s file browser;
    • the testing-mode message box;
    • the in-game menu, Save and Load.

    Not checked: Help, and the remaining tabs control by control.

  4. Jeff at 3 m with the remote: the focus is visible and the launcher, Global Options, Add Game and the in-game menu are usable without the pointer (quoted).
    • Jeff, 2026-11-29, with the stock remote on build 26041036: “The remote worked well at the lowest speed setting.” He had set the global Pointer Speed to its lowest step (kbdmouse_speed=0), which is the in-game cursor’s speed. His speed question led to WP-123, the pointer speed per game.
    • Jeff, 2026-11-30, with the stock remote on build 26041040, after a walk-through of the grid, the tray, Game Options, Global Options, the list view, Showdown and its in-game menu: “Everything worked.” Add Game wasn’t in the walk-through; adb’s D-pad checked it (criterion 3).
    • One press, one step: the app’s log during his walk-through shows each remote press as one key-down and one key-up, so the doubled presses in the WP-085 notes don’t happen here.
  5. Partly. In a game, the D-pad still moves the game’s cursor at Showdown’s Sign In (screencaps). Not checked: a controller’s left stick, as no controller was at hand.
  6. Partly. On Windows the keyboard’s arrows move the focus in the launcher (Right from the list to Quit, Up to Global Options). Not checked: the other dialogs, the mouse, text-to-speech.
  7. The change builds under GCC (Windows, MSYS2 UCRT64) and clang (Android) with no warnings in gui/ or backends/platform/android/.
  8. D5’s outcome applied (2026-11-30, on Jeff’s word ahead of his check in the grid). The TV app’s packaged defaults set gui_launcher_chooser=grid (private PR #64). On the TCL as versionCode 26041039 (WP-118 and WP-123 together), with the stored gui_launcher_chooser=list taken out of scummvm.ini, the app opens on the grid with Showdown focused, and nothing is written back (171-d5-grid-start). A player’s own choice of view still wins.
  9. WP-104 criterion 10 updated with this packet’s result.

Deliverables

Notes

Result

Run on 2026-11-29 by the session that pre-flighted it. Fork branch wp-118-tv-dpad-gui-focus, seven commits on scooby-engine @ dc8a9b3a57, in fork PR barefootbetters/scummvm#46 (merged on 2026-11-30, 5cdb64e880):

  1. GUI: Make GridWidget accept focus: upstream fa8126a019, cherry-picked.
  2. GUI: Move the focus between a dialog's controls with the arrow keys
  3. GUI: Navigate the launcher grid with the arrow keys
  4. GUI: Open dialogs with a control focused when gui_dpad_focus is set
  5. GUI: Add a Select action for controllers with arrows and one button
  6. ANDROID: Map the D-pad to GUI focus navigation with gui_dpad_focus
  7. GUI: Open the launcher grid's tray with the Return key (2026-11-30, after D5): Return, or OK on the remote, opens the tray instead of starting the game; the tray’s Play starts it.

The private identity turns it on: tvapp.ini sets gui_dpad_focus=true (barefootbetters/scooby-engine-private#64). The TV runs versionCode 26041036 (2026.4.1-wp118.16), built in WSL with FreeType and that identity, and installed with adb install -r.

How it works

Checked on the TCL

All through adb (input keyevent 19–23, 4, 82). The full-size captures are in C:\pcloud\BB\DEV\wp-118-tv-captures\ (116 files, kept out of git as they show the app). SHA-256 prefixes are given for those cited:

Check Capture SHA-256
Launch: the list focused on the last game, no keyboard 01-launch 7D0EF781D05E
Right from the row to Load; Down walks the button column 02-right, 04-down4 873AB697471C, 0A824C0CDD4F
OK on the list’s row starts the game; the testing-mode box opens on OK 64-grid 5A21435EE56F
Down past the last row reaches the view toggles 82-list-down3 4E6F925DBEDD
Grid view: the grid focused (green title bar), Left and Right by entry 102-b13-grid, 84-grid-left EB51BF3A5259, A9AB60EF5BAA
Grid: Down to the buttons, the title bar gone 103-b13-grid-down 94E140DBD56C
OK in the grid starts the game (before commit 7) 87-grid-ok BEC886D69ADF
Commit 7: OK in the grid opens the tray with Play focused; Down and Right reach Saves and Options 182-tray-ok, 183-tray-down, 184-tray-right 4C656A23BE9C, ECACB18EAF28, D3220ABAABE7
The tray’s Options opens Game Options, and its Saves opens Restore on the first save; BACK closes each, and the tray 185-tray-edit-ok, 187-saves, 190-tray-back AEED587AB980, 92CD7A4C567F, EB51BF3A5259
The tray’s Play starts the game (the testing-mode box); the menu’s Return to Launcher comes back to the grid 191-play, 195-back-to-launcher 5A21435EE56F, EB51BF3A5259
Global Options opens on the tab row, and Down walks the Graphics tab 41-b7-go, 25-go-down1, 26-go-down9 3975A9F2DE0C, see the folder
A checkbox focused; OK toggles it; a pop-up opens on OK and BACK closes it 42-b7-filter, 46-popup-open, 48-popup-back 1329A6C5BAD7, E223DDE5ED7F, C118516746B4
A slider: focused, then Left lowers it 192 → 176 31-volume-slider, 32-slider-left 261773DD8D74, E2D5CC0DBAF4
Keymaps: the GUI’s Up…Right list “D-pad” and “Hat”, and the buttons remap 61-km-gui-dirs 51D884634BE4
Game Options: an edit field focused, no keyboard 115-b16-go-name B8B80BC0DC2A
The search field: focused without the keyboard; OK opens it 111-b14-search, 112-b14-search-ok 083EB34E19E7, 2612177C4A0B
About opens on its scroller, which Down scrolls; BACK returns to the About button 21-b4-down1, 23-about-back CDB647F7222A, 34F9089D6E54
Add Game’s file browser: the list, the checkbox, Go up, Cancel, Choose 91-addgame, 98-b12-right 1571492A84BE, F27DBE27E32A
Showdown: D-pad long presses move the cursor at Sign In 68-signin-dpad, 69-signin-longpress E2575B2A5308, 362D84742B5F
The in-game menu opens on Resume; OK on Save opens the chooser on New Save 70-gmm, 72-save 691737627A1E, 96A8F667EFB3
Return to Launcher from the menu 89-back-launcher B4322C388A1B

The captures come from builds 26041021 to 26041036, and the tray’s from 26041040 (with WP-123 and the grid default). Each build to 26041036 fixed what the earlier captures showed:

Not done or not checked