Skip to content

fix(port): prevent menu close input from leaking into game input - #233

Open
jacobjordan94 wants to merge 1 commit into
999sian:masterfrom
jacobjordan94:fix/menu-close-input-leak
Open

jacobjordan94 wants to merge 1 commit into
999sian:masterfrom
jacobjordan94:fix/menu-close-input-leak

Conversation

@jacobjordan94

Copy link
Copy Markdown

Summary

Closing the F8 menu with a controller (A to confirm, or the Select+Start combo) could leak that same button press into the game on the exact frame the menu closed. Port_Config_InputPressed() polls hardware state directly instead of edges, so whatever button had just closed the overlay was still physically held the instant Port_UpdateInput()'s overlay mask lifted, and that stale press got read as a brand new input.

In practice, this meant that if a player had the in-game pause menu open on its default Equipment page and closed F8 with A, the leaked A press reassigned their equipped item, since Equipment's A-button press treats it as "equip the selected item."
Closing with Select+Start leaked a Start press the same way, opening or closing the in-game pause menu right behind F8.

Fixed with a debounce: once an overlay closes, Port_UpdateInput() now keeps masking all GBA buttons released until every mapped input has actually been released at least once, not just until the overlay itself reports closed.

Fixes #225.

Testing

Linux, Bazzite host, built inside a Debian distrobox container.

  • xmake build -y tmc_pc: clean build.
  • Headless smoke run (TMC_AUTOPLAY=1, dummy video/audio) reaches "Port
    layer initialized. Entering AgbMain...".
  • Manually tested with a controller on the host (not distrobox, since audio/input access from inside the container is unreliable here): closed the F8 menu with A while the in-game pause menu sat on its default Equipment page, and again with Select+Start. Confirmed neither the equipped item nor the in-game pause menu changes on close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Possible bug] Menu "close" button detected as in-game input

1 participant