aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorgbc dev <gbc@localhost>2026-07-04 22:46:11 +0200
committergbc dev <gbc@localhost>2026-07-04 22:46:11 +0200
commit54081ce90bf2b4cad803ab78db65b91c1217cc83 (patch)
treef5e51723c2e9a40265b5251b07870b48c81d048d /README.md
parentrenderer: inter-frame diffing to minimize terminal output (diff)
downloadsl0pboy-54081ce90bf2b4cad803ab78db65b91c1217cc83.tar.gz
sl0pboy-54081ce90bf2b4cad803ab78db65b91c1217cc83.tar.xz
sl0pboy-54081ce90bf2b4cad803ab78db65b91c1217cc83.zip
input: external control channel via FIFO
Adds --fifo [path] opening a named pipe that accepts button commands from any process. Supports momentary taps (a, start, name:N), deterministic hold/release (+name / -name), and 'release'. Merges with keyboard input; held state carries true key-up semantics the terminal can't provide. GBC_INPUT_DEBUG traces state.
Diffstat (limited to 'README.md')
-rw-r--r--README.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/README.md b/README.md
index 947211d..620f4c9 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,36 @@ Requires a truecolor-capable terminal (`COLORTERM=truecolor`) at least
Since terminals don't report key-release, buttons are held for a few frames
after each keypress (relying on the terminal's key-repeat for sustained holds).
+### External control channel (FIFO)
+
+Start with `--fifo [path]` (default `/tmp/gbc.fifo`) to open a named pipe that
+accepts button commands from any process. Unlike the terminal keyboard, this
+can send true key-**release** events, so it gives deterministic input for
+scripting and automated testing.
+
+```sh
+./build/gbc rom.gb --fifo /tmp/gbc.fifo &
+echo 'a' > /tmp/gbc.fifo # momentary tap of A
+echo 'start' > /tmp/gbc.fifo # tap Start
+echo '+left' > /tmp/gbc.fifo # press and HOLD Left
+echo 'a b' > /tmp/gbc.fifo # tap A and B together (Left still held)
+echo '-left' > /tmp/gbc.fifo # release Left
+echo 'release' > /tmp/gbc.fifo # release everything held
+echo 'a:30' > /tmp/gbc.fifo # tap A, held for 30 frames
+```
+
+Commands (one line, space/comma separated tokens, case-insensitive):
+
+| Token | Effect |
+|----------------|-----------------------------------------|
+| `a b start select up down left right` | momentary tap |
+| `name:N` | tap held for N frames |
+| `+name` | press and hold until released |
+| `-name` | release a held button |
+| `release` | release all held buttons |
+
+Set `GBC_INPUT_DEBUG=1` to trace resulting joypad state to stderr.
+
## Architecture
| File | Responsibility |