https://gitlab.synchro.net/main/sbbs/-/commit/cf67bccb2a7bf5111196bd0e
Added Files:
src/doors/termgfx/keymode.c keymode.h
Modified Files:
src/doors/syncretro/syncretro_input.c src/doors/termgfx/CMakeLists.txt Log Message:
termgfx: hoist the terminal key-mode negotiation into keymode.c
SyncDOOM, SyncDuke, SyncConquer and SyncRetro each carried their own copy
of the same keyboard negotiation: enable SyncTERM physical key reports
when the CTDA reply advertises cap 8, else push the kitty keyboard flags
when the terminal answers the CSI?u query, else fall back to the byte
path; undo whichever was enabled on the way out. Four copies of the evdev->ASCII table (byte-for-byte identical), three of the kitty CSI-u parameter decoder, and an evdev/kitty active-flag pair referenced 8 to 28
times per door.
The copies had already drifted, which is the argument for the module:
* SyncConquer never armed the enable-time settle window. SyncTERM
re-reports the keys held at the instant physical key reports are
enabled -- e.g. the Enter still down from picking the door off the
BBS menu -- and acting on those presses a button before the game has
drawn a frame. The other three drop press edges for 500ms.
* SyncRetro's modifier decode recognized only the left-hand Ctrl and
Alt keycodes, so right Ctrl and right Alt were read as ordinary keys.
Both are fixed by construction here: there is one settle window and one modifier classifier.
keymode.h follows the caps.h/term.h convention -- I/O-free. It owns the
state and builds the byte sequences; the door emits them through its own
output path and keeps the only genuinely per-game part, the map from a
key to that game's action. termgfx_keymode_restore() emits only what was actually enabled, so a door can call it unconditionally from its leave
path, and it is idempotent.
This commit adds the module and moves SyncRetro onto it. The three
shipped doors follow in their own commits so each stays bisectable.
Unit-tested (enable/restore/idempotence, evdev-wins precedence both ways,
the settle window across a uint32 millisecond clock wrap, the kitty
event-type and modifier fields, the evdev tables); SyncRetro re-verified against its fake-terminal harness on all three key paths.
---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net