WP-113: The TV remote’s D-pad and OK in a TerraGlyph game
Status: ✅ Done (2026-11-29). Executed on the TCL 65Q77K, every exit
criterion met (§Result); fork PR barefootbetters/scummvm#38
merged on 2026-11-29 (merge commit e2d74564a9). Diagnosis in §Diagnosis · pre-flight
READY 2026-11-29 (pre-flight-WP-113-2026-11-29),
executed inline in the same session.
Numbering: WP-112 is the last on main; no branch, commit or PR in this
repo, the fork or the private repo uses WP-113
(wp-lifecycle §Supersession check).
Phase: 5 (polish & distribution).
Depends on: WP-085 (the TV app it runs in). Nothing in the Hotspot Magnet
packets; this lands before them (§Notes).
Unblocks: playing a TerraGlyph game with the stock remote at all, before
Hotspot Magnet exists; the cursor-mode fallback that WP-089’s
H1 assumes.
Companion EC: — (one file, one build, one TV run).
Pre-flight required: Yes. It changes engines/terraglyph/**.
Targets generation(s): Gen 1 (Showdown, Phantom: the engine’s keymap
covers every game the engine runs).
Estimated effort: 2–3 hours including the build and the TV run.
Goal
Give TerraGlyph its own game keymap so that, in a game on Android TV, the remote’s D-pad moves the pointer (ScummVM’s Virtual Mouse, as in the launcher) and its OK button clicks. Today neither works anywhere in a TerraGlyph game.
Background
Jeff, 2026-11-28, on the TCL with the stock remote: “In the scooby doo game
showdown - the tv remote isn’t responding at the sign in screen.” The WP-104
session reproduced it with adb; this WP’s session (2026-11-29) found the
cause and tested the fix by configuration.
Diagnosis
Fork origin/scooby-engine at 6b6a2df93a06; the TV ran versionCode
26041019 (the WP-104 build, whose input code is the same).
- A remote D-pad press is a joystick button, not a key.
ScummVMEvents.java:521-542sendsDPAD_UP…CENTERasJE_GAMEPAD;events.cpp:1313-1330turns them intoJOYSTICK_BUTTON_DPAD_*, the hardware inputsJOY_UP…JOY_CENTER. - Android binds the four directions to the Virtual Mouse in the global
keymap (
android.cpp:749-755) andJOY_CENTERto “interact” in the GUI keymap only (android.cpp:759). That’s why the launcher works. - A game keymap that matches wins, and the global keymap is never
asked (
keymapper.cpp:178-196). - TerraGlyph declares no keymap (
engines/terraglyph/metaengine.h:29-41has noinitKeymaps()), sobase/main.cpp:312-315adds ScummVM’s default game keymap,engine-default(engines/metaengine.cpp:87-176). That keymap bindsJOY_UP/DOWN/LEFT/RIGHTto keypad 8/2/4/6 key events (:152-172), and binds left click toMOUSE_LEFTandJOY_Aonly. - The engine ignores those keys. The main loop reads mouse events, and
reads keys only through the room class’s
key()or Escape and Space (terraglyph.cpp:231-243). Keypad keys carry no ASCII, soSignInRoom::key()drops them too (signin_room.cpp:405). - OK is bound nowhere in a game.
JOY_CENTERappears in no game or global keymap, so it does nothing.
So the D-pad and OK do nothing on every TerraGlyph screen, not only Sign In: the keymap is per game, added when the engine starts. Sign In is just the first screen that needs input. Only Sign In was captured on the TV; the rest is from the code.
The Hotspot Magnet plan already recorded steps 3–4 as E27, inferred from source. This session saw it on the TV.
Why the D-pad moved the pointer “in game” for WP-085. WP-085’s TV runs
played Beneath a Steel Sky. Sky declares its own keymap without the D-pad
(engines/sky/metaengine.cpp:81), so there the Virtual Mouse keeps it. Jeff’s
2026-11-26 remark (WP-085 D2) was about that
pointer, not a TerraGlyph one. No regression, so nothing to bisect:
engine-default has bound the D-pad since 2020 (7ecccd3b30).
Evidence (TCL 65Q77K, 2026-11-29, Windows adb pinned to the TV’s serial)
Captures are local, not committed (the game’s art). The SHA-256s are of
screencap -p PNGs.
| Run | Config in [showdown-win] |
Input at Sign In | Result |
|---|---|---|---|
| Launcher (control) | none | 6 × DPAD_LEFT, 6 × DPAD_UP |
Pointer moved up and left by about 60 px |
| A | none (today) | 6 × DPAD_RIGHT, 6 × DPAD_DOWN |
Screen unchanged: three captures all 8D619B81…C812 |
| B | keymap_engine-default_UP= (and _DOWN, _LEFT, _RIGHT) empty |
Same 12, then 80 more | The game’s cursor moved from the top-left to the sign board (C75C62F7… after 12) |
| C | as B | Cursor on “9”, 3 × DPAD_CENTER |
Nothing typed (EB6B3780… before and after). The key’s hover wasn’t visibly lit, so this run is weaker than the code (step 6) |
| D | as B, plus keymap_engine-default_LCLK=MOUSE_LEFT JOY_A JOY_CENTER |
Cursor on “U” (lit), 1 × DPAD_CENTER |
“U” typed on the name board (EBF4A3BA…) |
scummvm.ini was backed up before run B and restored byte-identical after
run D (SHA-256 15A0E1BF…F93C both times). Saves were untouched, and the app
was only force-stopped, never cleared.
Seen along the way: per-press movement is erratic with adb. input
keyevent sends the down and the up within a few milliseconds. The Virtual
Mouse moves only on its 12 ms updates while a direction is held
(virtual-mouse.cpp:57-104, :109-150), so a tap moved anywhere from 0 px to
several hundred. A real remote press lasts longer, but a remote has no “small
step” either; that is the fine-movement gap Jeff noted in WP-085, and the
Hotspot Magnet’s job, not this WP’s.
Scope
In scope
TerraglyphMetaEngine::initKeymaps()inengines/terraglyph/metaengine.{h,cpp}, returning one game keymap with ScummVM’s default actions under the same standard action ids (so Android’s BACK→skip binding by id still applies, plan E44), except:- no
kStandardActionMoveUp/Down/Left/Rightactions, so the D-pad falls through to the Virtual Mouse; - left click also on
JOY_CENTER.
- no
- Partial matches off, as in the default.
- A build of the TV app (the WP-104 tree or its successor, versionCode
above what’s on the TV),
adb install -r. - On the TCL with the stock remote: the D-pad moves the game’s cursor and OK clicks, at Sign In and in one room after it; BACK still skips a movie; MENU still opens the main menu; the launcher still behaves as before.
- The plan’s §6.4 “Hotspot Assist off” line and E27’s last column brought in line with this WP (§Notes).
Out of scope
- Precise pointing, snapping to hotspots, the hold-OK cursor mode: Hotspot Magnet (WP-106, WP-107, packet 6).
- A gamepad’s hat D-pad (
JOY_HAT_*, plan E29) and the left stick, which already reach the Virtual Mouse (engine-defaultdoesn’t bind them). - The Virtual Mouse’s speed and
VMOUSESLOWbinding (android.cpp): backend defaults for every engine, not TerraGlyph’s to change. - A backend-wide fix (Android rebinding
engine-default’s directions for every engine): it would change other engines’ D-pad behaviour. Worth raising upstream separately if wanted. - D-pad focus navigation in the launcher (the WP-104 criterion-10 packet).
Dependencies
- The fork, via
tools\New-ForkWorktree.ps1 -Branch wp-113-dpad-keymap. - The WSL Android build per the smart-TV guide,
run from a script file (
wsl -u root -- bash <file>). - The TCL 65Q77K on
adb, the stock remote, a Showdown install.
Execution
- Fork worktree; write
initKeymaps()per §Scope 1–2, modelled onMetaEngine::initKeymaps()and Sky’s. - Build on Windows with GCC (the engine compiles in the Windows build too).
- Build the TV app, versionCode above the TV’s,
adb install -r(never uninstall, never clear data). - On the TV, check §Scope 4 with screencaps; Jeff confirms with the remote from the couch.
- Fork PR; docs close (this WP, WORK_INDEX, plan §6.4 and E27).
Exit criteria
TerraglyphMetaEngine::initKeymaps()exists; its keymap has no direction actions and binds left click toMOUSE_LEFT,JOY_AandJOY_CENTER.- On the TCL, D-pad presses at Sign In move the game’s cursor (before/after screencaps differ, cursor visibly moved).
- On the TCL, OK on a Sign In letter types it (screencap).
- On the TCL, after signing in, the cursor moves and OK clicks in a room.
- BACK skips a movie and MENU opens the main menu in a game (screencaps). BACK was shown skipping the title, which reads the same Escape key-down as the movie player (§Result).
- The launcher’s D-pad pointer is unchanged (screencap).
- The change compiles under GCC (Windows) and clang (Android) with no new
warnings. (Amended at pre-flight: it said the Windows self-test must match
its previous run, but the self-test’s
test_scriptdriveshandleMouse()and the room’skey()directly and never reads the keymap.) - Plan §6.4 and E27 updated.
Result
Evidence labels: live (session), screencaps this session took and read on the TCL; build, the build logs. Captures stay local (the game’s art).
- The change (source). Fork
wp-113-dpad-keymapat34f0c0b5ab, merged on 2026-11-29 ase2d74564a9; the fork worktree is removed:TerraglyphMetaEngine::initKeymaps()returnsterraglyph-default, the default game keymap’s actions under the same ids, with no up, down, left or right and with left click also onJOY_CENTER. - Builds (build). GCC (MSYS2 UCRT64,
--enable-engine=terraglyph, out of tree) and clang (Android arm-v7a, the WP-104 FreeType tree with only the two files copied in): no warnings inengines/terraglyph. Test APK versionCode 26041020 (2026.4.1-wp113.1), installed withadb install -r; the TV’sscummvm.iniwas unchanged by the install (SHA-25615A0E1BF…F93C). - Launcher (live). The D-pad still moves the pointer.
- Sign In (live). 12 D-pad presses changed the screen (
8D619B81…before,E29C2535…after), and further presses put the cursor on “S”, which lit up. OK typed “S”;adb shell input text TESTtyped the rest, so keyboard entry is unaffected. - A room after Sign In (live). Enter started play as STEST. In the difficulty room, D-pad left moved the cursor to Spooky and its hover followed. OK picked it, and the opening movie played.
- BACK (live). Pressed on the title screen about 17 s after start, it went
straight to Sign In within 2 s (the title otherwise holds until about 45 s).
That is the Skip action’s Escape key-down reaching the engine, the same key
the movie player’s skip reads (
movie.cpp:114-124). A movie skip itself wasn’t isolated: in the opening, cuts and skips look the same on screen. - MENU and the keymap (live). MENU opened the main menu in Town Center. Its Options → Keymaps tab lists “Default game keymappings” with Left click on “Left mouse button, Joy A, D-pad center” (truncated on screen) and Skip on “AC back, Joy Y”. BACK closed the dialog and the menu.
- Left on the TV: the WP-113 build (26041020), and a new save,
showdown-win.003, the STEST test player.scummvm.inihas the same lines as before the session. Later on 2026-11-29 the build was replaced (same versionCode,adb install -r) by the fork’s combinedscooby-enginetip,0c4c18ec59(2026.4.1-tip.1: this keymap with WP-104’s theme and branding, and WP-115/116). - Jeff with the stock remote (live, Jeff). On the combined tip build, at
Showdown’s Sign In, 2026-11-29: “remote works at the sign in now”. On the
same build, just before,
adbD-pad presses moved the game’s pointer there and BACK skipped the intro to it (screencaps, the WP-104 session).
Deliverables
- Fork PR:
engines/terraglyph/metaengine.{h,cpp}. - Docs: this WP’s §Result; WORK_INDEX;
hotspot-magnet-plan.md§6.4 and E27. - Local only: the screencaps (the game’s art).
Notes
- Correction to plan §6.4. It says that with Hotspot Assist off,
initKeymaps()returns ScummVM’s default keymap unchanged, “so input is exactly today’s”. On a TV, today’s input in a TerraGlyph game is a dead remote (§Diagnosis). H1 says turning Magnet off “returns the D-pad to the Virtual Mouse”, which only this keymap does. So after WP-113, the “off” path is WP-113’s keymap, and packet 6 builds Magnet’s keymaps on it. Itsterraglyph-defaultis this keymap withJOY_A/JOY_CENTERmoved toterraglyph-magnet-okwhile Assist is on. - Windows is unaffected. It has no
JOY_CENTERor D-pad on the keyboard, and the keypad keys the default bound were never read by the engine. - A remote with no Play/Pause has no slow-pointer key (
VMOUSESLOWis onAUDIOPLAYPAUSEand the right shoulder). Recorded for the Magnet packets, not changed here. - Seen, not investigated: the TV holds
showdown-win.001and.002from 2026-11-27, but Sign In’s player list was empty on the first four runs. After this session’s STEST was saved (.003), the list showed STEST but still not the two older saves. That may be expected (what Sign In reads from a save) or a gap; it belongs to its own check. - Skip’s bindings on Android are BACK and
JOY_Y, not Escape. Android’s backend sets the standard skip binding toAC_BACK, replacing the keymap’s own Escape (the Keymaps tab shows “AC back, Joy Y”). That was already so with the default keymap. A keyboard’s Escape still skips: nothing maps it, so it reaches the engine as a plain key-down (inferred from the keymapper; not tried on the TV).