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:
- WP-104 (🚧): the TV theme the focus state is drawn in, and D7’s list-view default this packet may reverse;
- WP-113 ✅: the game keymap that gives the D-pad to the game. This packet must not change it.
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
- Jeff at 3 m, 2026-11-28 (WP-104 §Result): “arrows move the pointer, not the highlight”. It holds in the list view as well as the grid, so D7’s premise, that the list view gives the remote arrow navigation, doesn’t hold on the TV.
- Why. The Android backend binds the D-pad’s joystick buttons (
JOY_UP…JOY_RIGHT, which is what the TCL’s remote sends, WP-113 §Diagnosis) to the Global keymap’s Virtual Mouse (VMOUSEUP…), and it replaces the GUI keymap’s ownJOY_*defaults for Up, Down, Left and Right with the keyboard arrows only (backends/platform/android/android.cpp, ingetKeymapperDefaultBindings(), atscooby-engine0c4c18ec59). The comment there says why, and names this packet’s work as the condition for undoing it:TODO If/when full key-based (ie. non-mouse) navigation of the ScummVM GUI is implemented, we can revert back to the core behavior of DPAD being mapped to “up”, “down”, “left”, “right” directions.
- What the GUI has today (fork
0c4c18ec59, which includes upstream to 2026-11-21):- A focused widget per dialog (
Dialog::_focusedWidget), given only to widgets whosewantsFocus()is true: the edit field, the list (and grouped list), the console and About’s scroller. Buttons, checkboxes, radio buttons, sliders, pop-ups and tabs never take focus. - The list moves its selection on the arrow keys when focused, and the launcher’s Tab switches the focus between the list (or grid) and the search field.
- No widget is drawn as focused. The theme has the states disabled, enabled, highlight (hover) and pressed, and no focus state.
- Upstream’s recent focus work, already in the fork: focus changes are
spoken for text-to-speech (
bc9a62f95f,d9c03aec2f), the dialog-open focus chain (9b21baacd4), list arrow keys scroll to the selection (2cf0713e29,0a5743bbc9). Upstream’sfa8126a019(2026-11-22, “GUI: Make GridWidget accept focus”) isn’t in the fork yet.
- A focused widget per dialog (
- The grid’s keyboard pop-up (WP-104 §Notes): in the grid view the search field takes the focus on launch, which opens the touch keyboard on the TV.
- Hotspot Magnet is a different layer. It moves a selection between a
game’s hotspots, in games only, and its code lives in
engines/(plan H1, H4). Its directional rules (plan §5, after Android’sFocusFinder) are a good model for moving between GUI controls, butgui/can’t call intoengines/(D3).
Scope
In scope
- 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). - 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. - 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).
- 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.
- The grid. The grid takes focus (upstream
fa8126a019brought 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). - The bindings. In the GUI keymap, the D-pad (
JOY_UP…JOY_RIGHT, andJOY_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. - 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
- Hotspot Magnet and anything in a game’s own screens: WP-106, WP-107 and packet 6 of the plan. WP-113’s game keymap stays as is.
- Guided import and the empty-library welcome: new flows (WP-104 §Out of scope).
- A simplified options set for families: its own packet.
- Theme work beyond the focus state: WP-104’s theme carries everything else.
- Sending the change upstream: D6 decides whether to offer it; this packet doesn’t open an upstream PR.
- Windows and Raspberry Pi default bindings: unchanged, though the traversal itself works with a keyboard’s arrows on every platform.
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
- The fork’s
scooby-enginebranch at or after0c4c18ec59, and upstreamfa8126a019to bring in. - The WSL Android build with FreeType (
/opt/build/ft-v7a) and the private identity, as WP-104 built it; the TCL 65Q77K on Windowsadb, pinned with-s; the stock remote, and a game controller forJOY_HAT_*. - MSYS2 UCRT64 for the Windows build (keyboard arrows, mouse regression).
Execution
- Fork worktree with
tools/New-ForkWorktree.ps1; cherry-pick upstreamfa8126a019. - The traversal and activation in
GUI::Dialogand the widgets (scope 1–3), then the focus state (scope 4) and the grid (scope 5). - The Android bindings (scope 6), as D2 decides.
- Windows build: keyboard arrows move the focus in every scope-7 screen, the mouse behaves as before.
- 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. - D5, if (a): the TV default back to the grid, Jeff’s check in the grid.
- Fork PR into
scooby-engine; docs close (this WP, WORK_INDEX, WP-104 criterion 10, D7’s note inDECISIONS.md).
Exit criteria
- 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, thenJOY_*); the stock remote itself is criterion 4. - 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).
- 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.
- 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.
- 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 (
- 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.
- 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.
- The change builds under GCC (Windows, MSYS2 UCRT64) and clang
(Android) with no warnings in
gui/orbackends/platform/android/. - 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 storedgui_launcher_chooser=listtaken out ofscummvm.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. - WP-104 criterion 10 updated with this packet’s result.
Deliverables
- Fork commits on
wp-118-tv-dpad-gui-focus, ScummVM-style prefixes (GUI:,ANDROID:), one concern each, brand-free; fork PR intoscooby-engine. - This WP’s §Result, EC-018, the WORK_INDEX row, WP-104 criterion 10.
- Captures stay local where they show the app’s name or id.
Notes
- WP-104 named this packet as the follow-up for “grid keys, button focus,
focus state, something-focused-at-launch” (§Out of scope) and as the
condition that brings the grid back (D7,
docs/ai/DECISIONS.md). - Text-to-speech. Upstream already speaks the widget that gains the focus
(
bc9a62f95f), so the traversal should give spoken feedback for free; worth a check on Windows, where TTS is available. - The touch keyboard. Any edit field that takes the focus may open it on Android; scope 3 keeps it from happening on launch, and an edit field should open the keyboard only on OK.
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):
GUI: Make GridWidget accept focus: upstreamfa8126a019, cherry-picked.GUI: Move the focus between a dialog's controls with the arrow keysGUI: Navigate the launcher grid with the arrow keysGUI: Open dialogs with a control focused when gui_dpad_focus is setGUI: Add a Select action for controllers with arrows and one buttonANDROID: Map the D-pad to GUI focus navigation with gui_dpad_focusGUI: 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
- Which widgets the arrows can focus. A new
Widget::wantsNavigationFocus()covers everything a click focuses (the edit field, the list, the grid) plus buttons of every kind (including checkboxes and radio buttons), sliders, pop-ups and the tab row. A click still focuses only what it did before. - The direction rule (D3). It is the Hotspot Magnet rule of plan §5,
applied to rectangles:
- candidates lie further along the direction;
- one overlapping the focused widget’s span across the direction wins, then one within 45°, then the rest;
- within each, the score is major² + 4·minor²;
- ties break on integers, and there is no wrap.
Two changes came from the TV:
- minor is the gap between the rectangles, not between their centres. Measured centre to centre, the launcher’s large list lost to the small list-view toggle below “?”.
- The arrows stay inside their group. They search the innermost group holding the focused widget first (a scroll container, a tab, an options container) and widen outward only when it has nothing that way. Without this, Global Options’ Keymaps tab went from Reset straight to Cancel, and controls scrolled out of view were unreachable.
- Edges. The list hands Up and Down on at its first and last rows. The grid moves by entry and hands on at its edges. A slider changes its value in sixteenths and hands on at its ends. The tab row switches tabs with Left and Right. An edit field the arrows reach passes every arrow on until OK starts editing; while editing, it keeps Left and Right.
- Activation. The new GUI action Select (
SELT) is bound on the TV to the remote’s OK (JOY_CENTER),SELECTandJOY_A. It sends Return to the focused control, or clicks at the pointer when the pointer moved after the arrows last moved the focus. Interact loses its TV bindings, since Select covers it. BACK closes dialogs as before. - The focus look (D4, the highlight state). Buttons and sliders use the
theme’s hover state. Where the themes have no clear one, the control draws
a highlighted button instead:
- a pop-up, with its value as the label;
- a checkbox’s or radio button’s label;
- the active tab.
A focused edit field and the grid’s selected entry use the focused list’s green bar. These looks are drawn in the foreground layer only: drawn into the background, a highlighted button left a stale box behind once a scroll had redrawn the dialog (seen on the TV).
- Opening focus. With
gui_dpad_focusset, a dialog with nothing a click would focus opens on its Return button, or else its top-left control. Otherwise dialogs open as before. The launcher already opened on its list, and withfa8126a019it opens on its grid, never on the search field. - Games. GUI-keymap bindings win over the global keymap only while the GUI
keymap is active. In a game the D-pad still reaches WP-113’s
terraglyph-defaultkeymap and the Virtual Mouse.
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:
- the list losing to the view toggle;
- the pop-up’s weak highlight;
- the stale box after scrolling;
- the checkbox’s partial pill;
- the Keymaps tab (options containers aren’t “enabled”, so their children were skipped);
- drop-down buttons without a focus look;
- Load opening on the view toggle;
- the grid’s focus not told from its selection.
Not done or not checked
- A crash found during Jeff’s check, not this packet’s: Showdown
aborted right after Sign In, in
GZipReadStream::seek. Loading a player’s save showed its room from inside the load, and the room’s player save rewrote the file the load still had open. Fixed under WP-126. - Help, a controller’s stick and hat, the mouse and text-to-speech on Windows: not checked.
- Right from the grid’s last entry goes to the nearest control to the right (Quit), by the rule. It doesn’t stay.