Repository navigation
ESP32: keys work at the menus after JK is quit and relaunched; console commands too - #4
Merged
Merged
Conversation
…e commands too
tab5-emu runs the engine several times in one process, and desktop's
per-launch OpenJKDF2_Globals_Reset doesn't run there, so state that assumes a
fresh process carried over:
- The message handler table. jk_esp_engine_startup reset only the count.
stdControl's handler is never removed, and on ESP32 neither is
Windows_GdiHandler, so their re-adds were refused as duplicates. Dispatch
visits g_handler_count slots and stopped before the GUI's handler: in the
second session keys and taps were ignored at every menu (the first tally
waited forever for Enter) and Esc no longer opened the in-game menu. Only
the on-screen pad still worked, because jkGuiRend_UpdateController calls
the GUI's handler directly. Window_ESP32_ResetMsgHandlers clears the table
and the count at session start.
- sithConsole_numRegisteredCmds and jkDev_numCheats outlived their tables.
Each session registered on top of the last one's count, and from the third
session every console command and cheat was refused ("not recognized").
Both are reset when their tables are made.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After JK was quit and relaunched, keys stopped working at the menus
tab5-emu runs the engine several times in one process. Desktop resets every global at each launch (
OpenJKDF2_Globals_Resetinmain.c), but that doesn't run on ESP32, so state that assumes a fresh process carried over to the next session:jk_esp_engine_startupresetg_handler_countbut notWindow_ext_handlers[].stdControl_MessageHandleris never removed, and on ESP32 neither isWindows_GdiHandler(Windows_ShutdownGdiis gated on a flag only the Win32 path sets). So their re-adds in session 2 were refused as duplicates and the count came out 2 short.g_handler_countslots, so it stopped beforejkGuiRend_WindowHandler. In the second session keys and taps were ignored at every menu: the first tally waited forever for Enter, and Esc no longer opened the in-game menu.jkGuiRend_UpdateControllercalls the GUI's handler directly.count 4with the GUI's handler in slot 3; session 2 hadcount 2with the same four entries.Window_ESP32_ResetMsgHandlers()clears the table and the count at session start.sithConsole_numRegisteredCmdsandjkDev_numCheatsoutlived their tables. Each session registered on top of the previous one's count, and from the third session every console command and cheat was refused ("Console command thereisnotry not recognized"). Both are now reset when their tables are made.Testing (Tab5, with esp-cpp/tab5-emu#39)
Four JK sessions in one boot. Each one starts level 1, ends it for real (cutscene, tally, Enter) and reaches level 2, then quits.
count 4in every session)The same freeze happened on a build without #3, so it was already there. That PR's runs never relaunched JK in the same boot.
Reviewed adversarially. An audit of every state that survives a session in the window, GUI and input paths found the same cause independently. A review of this patch found no defects; its one finding was an existing out-of-memory path that both skeptics rejected. The broader fix, running
OpenJKDF2_Globals_Resetper session on ESP32, would also reset globals the port sets up before engine startup, so it is left for a separate audit.🤖 Generated with Claude Code
https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY