From 36acf324fa05d8b3772de476ebfa08f2fdb074e5 Mon Sep 17 00:00:00 2001 From: James Dansereau <106631954+jkdansereau@users.noreply.github.com> Date: Sun, 30 Aug 2026 15:05:12 -0400 Subject: [PATCH] M-27: D145 - ESC no longer hard-quits (it is the menu back key) port/src/video.c, port/fast3d/gfx_sdl2.cpp, port/src/input.c: bare ESC was wired to exit(0) in both event handlers. On the front-end / debrief / mission- complete screens ESC is the natural "back / previous page" key, so a player paging through the post-mission report with ESC quit the whole game -- a clean exit(0), no crash log, looked like a crash. ESC now feeds the N64 B button (back / cancel) through input.c alongside X/R/F; quitting is window-close (X) or Alt+F4 only. Verified: -level_09 boots crash-free, 8 frames rendered. --- port/fast3d/gfx_sdl2.cpp | 6 +++--- port/src/input.c | 2 +- port/src/video.c | 10 ++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/port/fast3d/gfx_sdl2.cpp b/port/fast3d/gfx_sdl2.cpp index 25ce3c3d..d6369669 100644 --- a/port/fast3d/gfx_sdl2.cpp +++ b/port/fast3d/gfx_sdl2.cpp @@ -299,9 +299,9 @@ static void gfx_sdl_handle_events(void) { if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) { // alt-enter received, switch fullscreen state set_fullscreen(!fullscreen_state, true); - } else if (event.key.keysym.sym == SDLK_ESCAPE) { - // GE's own menus use the keyboard; ESC on an empty event - // queue is our quit key (matches the Phase 1 demo loop). + } else if (event.key.keysym.sym == SDLK_F4 && (event.key.keysym.mod & KMOD_ALT)) { + // D145: Alt+F4 quits; bare ESC no longer does (it is the + // menu "back" key -- see port/src/video.c / input.c). exit(0); } break; diff --git a/port/src/input.c b/port/src/input.c index 9b617221..00a81cca 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -435,7 +435,7 @@ unsigned inputComputePad(int idx, signed char *stick_x, signed char *stick_y) wheelPulse--; } if (keyDown(ks, SDL_SCANCODE_X) || keyDown(ks, SDL_SCANCODE_R) || - keyDown(ks, SDL_SCANCODE_F)) + keyDown(ks, SDL_SCANCODE_F) || keyDown(ks, SDL_SCANCODE_ESCAPE)) /* D145: ESC = B (back/cancel) */ button |= GE_CONT_B; if (keyDown(ks, SDL_SCANCODE_Q)) button |= GE_CONT_L; diff --git a/port/src/video.c b/port/src/video.c index 7143e1a0..d08ffb57 100644 --- a/port/src/video.c +++ b/port/src/video.c @@ -197,8 +197,14 @@ void videoPumpEvents(void) exit(0); break; case SDL_KEYDOWN: - if (ev.key.keysym.sym == SDLK_ESCAPE) { - sysLogPrintf(LOG_INFO, "video: ESC -> quit"); + /* D145: bare ESC used to exit(0). On the front-end / debrief + * screens ESC is the natural "back" key, so a player pressing it + * to page back instead quit the whole game (looked like a crash -- + * clean exit, no crash log). ESC now feeds the N64 B button + * (back / cancel) via input.c; quitting is window-close (the X) or + * Alt+F4 only. */ + if ((ev.key.keysym.sym == SDLK_F4) && (ev.key.keysym.mod & KMOD_ALT)) { + sysLogPrintf(LOG_INFO, "video: Alt+F4 -> quit"); exit(0); } else if (ev.key.keysym.sym == SDLK_F12 && !ev.key.repeat) { screenshotReq = 1;