diff options
| author | gbc dev <gbc@localhost> | 2026-07-04 22:46:11 +0200 |
|---|---|---|
| committer | gbc dev <gbc@localhost> | 2026-07-04 22:46:11 +0200 |
| commit | 54081ce90bf2b4cad803ab78db65b91c1217cc83 (patch) | |
| tree | f5e51723c2e9a40265b5251b07870b48c81d048d /src/main.c | |
| parent | renderer: inter-frame diffing to minimize terminal output (diff) | |
| download | sl0pboy-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 'src/main.c')
| -rw-r--r-- | src/main.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -34,6 +34,7 @@ int main(int argc, char **argv) { double seconds = 30.0; int shot_frames = -1; const char *shot_path = "shot.ppm"; + const char *fifo_path = NULL; for (int i = 2; i < argc; i++) { if (!strcmp(argv[i], "--test")) { test = true; @@ -41,6 +42,9 @@ int main(int argc, char **argv) { } else if (!strcmp(argv[i], "--shot")) { if (i + 1 < argc) shot_frames = atoi(argv[++i]); if (i + 1 < argc && argv[i+1][0] != '-') shot_path = argv[++i]; + } else if (!strcmp(argv[i], "--fifo")) { + fifo_path = (i + 1 < argc && argv[i+1][0] != '-') + ? argv[++i] : "/tmp/gbc.fifo"; } } @@ -72,6 +76,11 @@ int main(int argc, char **argv) { signal(SIGINT, on_sig); signal(SIGTERM, on_sig); + if (fifo_path) { + input_open_fifo(fifo_path); + fprintf(stderr, "control fifo: echo 'a' > %s (a b start select " + "up down left right; +x/-x hold/release; release)\n", fifo_path); + } term_init(); const double frame_time = 1.0 / 59.73; @@ -93,6 +102,7 @@ int main(int argc, char **argv) { } term_restore(); + input_close_fifo(); cart_free(&gb->cart); free(gb); return 0; |
