Pre-Flight — WP-118 — 2026-11-29
Filled-in copy of docs/reference/pre-flight for WP-118. Verdict at the bottom.
Pre-flighted and executed in one session, started by the WP-104 session after Jeff approved D1–D6 (2026-11-29), and run when Jeff said “Merged, go”. Execution runs inline, so there is no separate session prompt.
Header
- WP:
WP-118 - Title: TV remote D-pad focus in the launcher and menus
- Pre-flight date:
2026-11-29 - Targets generation(s): none (the GUI is engine-independent)
- Targets disc(s): none; the TV’s installed Showdown data for criterion 5
Dependency check
| Prereq | Status in WORK_INDEX |
Notes |
|---|---|---|
| WP-104 | 🚧 | Its theme and packaged defaults are merged (fork PR #36, private PR #63) and on the TV. Its open criterion 10 is this packet’s work. |
| WP-113 | ✅ | The game keymap that gives the D-pad to the game in play. Unchanged here. |
Rule check: WP-104 isn’t ✅, but the parts WP-118 builds on (the
tvapp.ini reader, the TV theme) are merged and installed; noted rather than
blocking.
Repo + disc state
- The draft: docs PR #300
(WP-118, EC-018, D1–D6). When execution started it was still open, with a
WORK_INDEXconflict against WP-119’s row; this session mergedmaininto it, keeping both rows (fd095e8). This execution’s docs branch,docs/wp-118-execution, is cut from that commit. - Nobody else holds it: no other WP-118 PR, branch or worktree. (Fork
branch
wp-118-room-of-doorsand docs PR #301 used the number by mistake for what became WP-119; both are merged or closed.) - Fork worktree, the claim:
tools/New-ForkWorktree.ps1 -Branch wp-118-tv-dpad-gui-focus, forked fromorigin/scooby-engine @ dc8a9b3a57(past the packet’s0c4c18ec59pin: WP-117 and WP-119, engine-only). - Upstream
fa8126a019is still needed: not an ancestor of the fork tip. Cherry-picked first (516b27b7d3, with-x). - TV: TCL 65Q77K at
192.168.0.47:46421, versionCode 26041020 (versionName2026.4.1-tip.1, installed 2026-11-29 16:32). The test builds go from 26041021. - WSL build tree:
/opt/build/wt/wp118, a copy of WP-104’s/opt/build/wt/tip104(in-tree configure:--host=android-arm-v7a --disable-all-engines --enable-engine=terraglyph,sky --with-png-prefix=/opt/build/png-v7a --disable-debug --enable-release,PKG_CONFIG_LIBDIR=/opt/build/ft-v7a/lib/pkgconfig). The worktree is synced over it by content, so only changed files rebuild.
What the code has today (fork dc8a9b3a57)
Dialog::handleKeyDowngives the key to_focusedWidget, then handles button hotkeys, Escape and Tab. Arrow keys nobody handles are dropped.wantsFocus()is true for the edit field, the list, the grid (afterfa8126a019), the console and About’s scroller. A mouse click focuses only those (Dialog::handleMouseDown), andsetDefaultFocusedWidget()picks the first of them in the widget chain.- The list already draws a focus look (
kTextInversionFocuson its selection), the grid draws its selected entry highlighted, and buttons, checkboxes, radio buttons and sliders draw a highlight state fromWIDGET_HILITED(hover). - The list keeps Up and Down even at its first and last rows; the grid has no
key handling at all;
PopUpDialoghandles its own arrows and Return. - The edit field opens the touch keyboard in
receivedFocusWidget(). - The GUI keymap (
GuiManager::getKeymap()) mapsJOY_Ato Interact (a left click at the pointer), and Up…Right to the arrow keys andJOY_UP…JOY_RIGHT. Android’sgetKeymapperDefaultBindings()replaces the directions with the keyboard arrows only, addsJOY_CENTERandSELECTto Interact, and binds the D-pad to the Global keymap’s Virtual Mouse. Keymapper::mapEventlooks at the Global keymap only when the active GUI or game keymap has no exact match, so a GUI binding ofJOY_UPwins over the Virtual Mouse in the launcher and menus, and the Virtual Mouse keeps the D-pad in a game (WP-113’s keymap has no directions).getKeymapperDefaultBindings()runs fromsetupKeymapper(), afterinitBackend()has registered thetvapp.inidefaults, so it can read them.
Design
- Two kinds of focus.
wantsFocus()keeps its meaning (what a click focuses, what a dialog focuses on open). A newWidget::wantsNavigationFocus()(default:wantsFocus()) is also true for buttons and their subclasses (checkbox, radio, drop-down, picture), sliders, pop-ups and the tab row. Mouse use doesn’t change: clicking a button still doesn’t focus it. - Traversal (D3) in
Dialog: an arrow the focused widget doesn’t use moves the focus. Candidates are the visible, enabled navigation targets in the dialog’s tree, descending into containers, scroll containers and the active tab, but not into a target’s own children (the list’s scroll bar, the grid’s items). From the focused widget’s focus rectangle (the list’s or grid’s selected row or cell, otherwise its bounds):- a candidate lies strictly further along the direction (its centre past the origin’s centre and its far edge past the origin’s far edge);
- tier 0 overlaps the origin’s beam (its span across the direction), tier 1 lies within 45° by centres, tier 2 is the rest, the lowest tier used;
- score major² + 4·minor², with major the gap between the edges along the direction and minor the distance between centres across it;
- ties to the smaller major, then the smaller y, then the smaller x;
- no candidate: the focus stays (no wrap). Integer arithmetic only, as in the plan’s §5.
- Edges. The list hands Up and Down on at its first and last rows; the grid moves by cell and hands on at its edges; a slider changes its value and hands on at its ends; the tab row switches tabs with Left and Right and hands on at its first and last tab; an edit field keeps Left and Right (the caret) and hands on Up and Down.
- Activation. Return and keypad Enter on a focused button press it, toggle a checkbox, select a radio button, open a pop-up or a drop-down’s main action. The grid starts the selected game. An edit field reached by the arrows doesn’t open the touch keyboard; Return does.
- The focus look (D4). A navigation-focused button, checkbox, radio button, slider or pop-up draws in the highlight state; the tab row draws its active tab highlighted. The list and grid keep their own looks. A scroll container scrolls the focused widget into view.
- Initial focus (scope 3). Unchanged where a dialog has a
wantsFocus()widget. Where it has none, the dialog focuses its default button (the one whose hotkey is Return), else the top-left target, but only when the switch below is on; on the desktop the first arrow press focuses that widget instead, so a dialog opens looking as it does today. The launcher focuses its list or grid, never the search field. - The switch (D2): a ConfMan key,
gui_dpad_focus(default false). The TV app’stvapp.inisets it to true. It does two things: Android binds the D-pad (andJOY_HAT_*, where the backend has them) to the GUI’s Up…Right and OK to a new GUI action, and dialogs open with a control focused (6). The traversal itself works on every platform with the keyboard’s arrows. - OK on the TV. A new GUI action, Select (
SELT), bound in TV builds toJOY_CENTER,SELECTandJOY_A: it activates the focused control, or, if the pointer moved since the last arrow press (a controller’s left stick), clicks at the pointer as Interact does. Interact keeps its bindings off the TV. Both stay remappable in Global Options → Keymaps.
Amended during execution
What the TV showed changed some of the design above. WP-118 §Result has the details.
- Design 2: minor is the gap between the rectangles across the direction, with the centre offset as the first tie-break. The arrows also search the innermost group holding the focused widget before the whole dialog.
- Design 5: pop-ups, checkboxes, radio buttons and the tab row draw a highlighted button, since their themes have no clear highlight. Edit fields and the grid’s selected entry use the focused list’s bar. All these looks are drawn in the foreground layer only. Drop-down buttons show their button half hovered.
- Design 6: with
gui_dpad_focusset, even a dialog that opens on an edit field counts the focus as the arrows’, so the keyboard waits for OK. The saved-games grid chooser chooses its focus again once its slots exist. - Scope lock:
gui/ThemeEngine.{h,cpp}(getLayerToDraw(),getButtonDirtyRect()),gui/saveload-dialog.cppandbase/commandLine.cpp(thegui_dpad_focusdefault) were added. The launcher needed no change.
Scope lock
This repo: WP-118, EC-018, this file, WORK_INDEX.md, WP-104 (criterion
10 and its row only), docs/ai/DECISIONS.md (D7’s note, if D5 lands).
Fork: gui/dialog.{h,cpp}, gui/widget.{h,cpp}, gui/widgets/list.{h,cpp},
gui/widgets/grid.{h,cpp}, gui/widgets/tab.{h,cpp},
gui/widgets/popup.{h,cpp}, gui/widgets/edittext.{h,cpp},
gui/widgets/scrollcontainer.{h,cpp}, gui/launcher.cpp,
gui/gui-manager.{h,cpp}, backends/platform/android/android.cpp, staged by
name. Commits brand-free, GUI: / ANDROID: prefixes, one concern each.
Private repo: private/tv-app-identity/assets/tvapp.ini
(gui_dpad_focus=true, and gui_launcher_chooser=grid for D5).
TV: adb install -r only; never uninstall, never clear data.
Risk review
| Risk | Likelihood | Impact | Mitigation |
|---|---|---|---|
| Desktop behaviour changes: the list now hands Down on at its last row, and the arrows move a focus on dialogs that ignored them. | high | low | Intended (D1: the traversal works with the keyboard everywhere). A dialog opens as before off the TV; a click on another widget clears a navigation-only focus. Checked on Windows (criterion 6). |
A widget eats an arrow and traps the focus (the edit field’s Left and Right, a subclass’s own handleKeyDown). |
med | med | Edit fields still hand on Up and Down. Every scope-7 dialog walked on the TV with screencaps. |
| Scroll containers (the options tabs) leave the focus off screen. | med | med | Scroll the focused widget into view on each move. |
Pop-ups open a PopUpDialog whose own keys must work. |
low | med | It already handles Up, Down, Return and Escape; checked on the TV. |
| The touch keyboard opens whenever an edit field takes the focus. | high | med | Navigation focus doesn’t open it; OK does. The launcher never starts on the search field. |
| WP-113’s game keymap: the D-pad must still drive the game’s cursor. | low | high | GUI bindings apply only while the GUI keymap is active; the Virtual Mouse keeps JOY_UP… for games. Checked at Showdown’s Sign In (criterion 5). |
| OK clicks at a stale pointer. | med | med | Select activates the focus unless the pointer moved since the last arrow. |
Old user bindings. A remapped Up…Right in the TV’s scummvm.ini would override the new defaults. |
low | med | Checked on the TV before install (run-as read of scummvm.ini). |
Verdict
- READY TO EXECUTE
- NOT READY
Prepared by: Claude (WP-118 execution session) Date: 2026-11-29