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).

  1. A remote D-pad press is a joystick button, not a key. ScummVMEvents.java:521-542 sends DPAD_UP…CENTER as JE_GAMEPAD; events.cpp:1313-1330 turns them into JOYSTICK_BUTTON_DPAD_*, the hardware inputs JOY_UP…JOY_CENTER.
  2. Android binds the four directions to the Virtual Mouse in the global keymap (android.cpp:749-755) and JOY_CENTER to “interact” in the GUI keymap only (android.cpp:759). That’s why the launcher works.
  3. A game keymap that matches wins, and the global keymap is never asked (keymapper.cpp:178-196).
  4. TerraGlyph declares no keymap (engines/terraglyph/metaengine.h:29-41 has no initKeymaps()), so base/main.cpp:312-315 adds ScummVM’s default game keymap, engine-default (engines/metaengine.cpp:87-176). That keymap binds JOY_UP/DOWN/LEFT/RIGHT to keypad 8/2/4/6 key events (:152-172), and binds left click to MOUSE_LEFT and JOY_A only.
  5. 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, so SignInRoom::key() drops them too (signin_room.cpp:405).
  6. OK is bound nowhere in a game. JOY_CENTER appears 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

  1. TerraglyphMetaEngine::initKeymaps() in engines/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/Right actions, so the D-pad falls through to the Virtual Mouse;
    • left click also on JOY_CENTER.
  2. Partial matches off, as in the default.
  3. A build of the TV app (the WP-104 tree or its successor, versionCode above what’s on the TV), adb install -r.
  4. 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.
  5. The plan’s §6.4 “Hotspot Assist off” line and E27’s last column brought in line with this WP (§Notes).

Out of scope

Dependencies

Execution

  1. Fork worktree; write initKeymaps() per §Scope 1–2, modelled on MetaEngine::initKeymaps() and Sky’s.
  2. Build on Windows with GCC (the engine compiles in the Windows build too).
  3. Build the TV app, versionCode above the TV’s, adb install -r (never uninstall, never clear data).
  4. On the TV, check §Scope 4 with screencaps; Jeff confirms with the remote from the couch.
  5. Fork PR; docs close (this WP, WORK_INDEX, plan §6.4 and E27).

Exit criteria

  1. TerraglyphMetaEngine::initKeymaps() exists; its keymap has no direction actions and binds left click to MOUSE_LEFT, JOY_A and JOY_CENTER.
  2. On the TCL, D-pad presses at Sign In move the game’s cursor (before/after screencaps differ, cursor visibly moved).
  3. On the TCL, OK on a Sign In letter types it (screencap).
  4. On the TCL, after signing in, the cursor moves and OK clicks in a room.
  5. 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).
  6. The launcher’s D-pad pointer is unchanged (screencap).
  7. 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_script drives handleMouse() and the room’s key() directly and never reads the keymap.)
  8. 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).

Deliverables

Notes