From 740df609b73caab80ada739516a6ee380bf78401 Mon Sep 17 00:00:00 2001 From: x6568tank Date: Fri, 18 Sep 2026 11:40:35 -0400 Subject: [PATCH] feat: add a cd_reinsert debug command The reinsert hotkey needs a focused window, so no test could exercise the lid. This runs the same tray cycle on the same image from the debug server. It was added to isolate a wedge seen after a savestate save, and it established that the wedge predates the disc-change work: a save followed by this command alone reproduces it, with no disc change. --- runtime/src/debug_server.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/runtime/src/debug_server.c b/runtime/src/debug_server.c index cbd655bc..0609222d 100644 --- a/runtime/src/debug_server.c +++ b/runtime/src/debug_server.c @@ -11873,6 +11873,17 @@ static void handle_disc_select(int id, const char *json) send_fmt("%s", buf); } +/* cd_reinsert: run the tray open/close cycle on the SAME image, which is what + * the reinsert hotkey does. Scripted access matters because the hotkey needs a + * focused window, so nothing could previously exercise the lid from a test. */ +static void handle_cd_reinsert(int id, const char *json) +{ + (void)json; + debug_force_cd_reinsert(); + send_fmt("{\"id\":%d,\"ok\":true,\"has_disc\":%s}", + id, cdrom_has_disc() ? "true" : "false"); +} + /* cdrom_instant_rate: get/set the 'instant' per-frame sector-IRQ budget * (step 3 tunable). Param "n" (optional int): new budget, clamped by * cdrom_set_instant_rate. Always returns the current value, so a no-arg @@ -13933,6 +13944,7 @@ static const CmdEntry s_commands[] = { { "overlay_dump", handle_overlay_dump }, { "cd_read_log", handle_cd_read_log }, { "disc_select", handle_disc_select }, + { "cd_reinsert", handle_cd_reinsert }, { "overlay_loader_status", handle_overlay_loader_status }, { "overlay_candidates", handle_overlay_candidates }, { "overlay_native_ring", handle_overlay_native_ring },