upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/gameinput.md
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 07:39:13 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 07:39:13 -0500
commitc68f494160c8e79c76bfa109b2e99571a5c11358 (patch)
treedd03d57136b41a752dfcf4a7a2f0befc670bfbe3 /docs/gameinput.md
parent0d80bc5df7c873f40965f34f185cb96913786765 (diff)
RT-INPUT-SCRIPT-NO-SDL3: serve LEONIDA_INPUT_SCRIPT without SDL3
A build without SDL3 answered GameInputCreate with no devices and E_NOTIMPL for every other slot, so the title waited at its first "press A" prompt forever: no CI artifact or offline build could get past it. With LEONIDA_INPUT_SCRIPT set, gameinput_no_sdl.cpp now serves one scripted pad (an Xbox One gamepad) driven by the script alone: device enumeration through RegisterDeviceCallback (blocking, async, dispatcher), FindDeviceFromId, and GetCurrentReading/GetNextReading/GetPreviousReading whose gamepad and UI navigation state follow the script. Readings are taken when the title asks, so no thread polls. Without the variable it behaves as before. The parser, the 300 ms timeline, the button names, the press log lines and the UI navigation mapping move from gameinput.cpp into gameinput_script.h, which both shims use; nothing in it needs SDL. gameinput.cpp checks the shared SDL button numbers against SDL_GamepadButton at compile time. gameinput_no_sdl_test --input-script (CTest gameinput_no_sdl_script) checks the scripted pad on a fake clock. Docs: runtime/README.md, docs/gameinput.md, docs/linux_proton.md, docs/README.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/gameinput.md')
-rw-r--r--docs/gameinput.md50
1 files changed, 45 insertions, 5 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md
index feed39153..06c2013a5 100644
--- a/docs/gameinput.md
+++ b/docs/gameinput.md
@@ -37,10 +37,42 @@ SDL3 is available in one of these ways:
37- **A local copy of that tarball**: extract it and pass `-DFETCHCONTENT_SOURCE_DIR_SDL3=<path to SDL3-3.4.20>`; it is 37- **A local copy of that tarball**: extract it and pass `-DFETCHCONTENT_SOURCE_DIR_SDL3=<path to SDL3-3.4.20>`; it is
38 built the same way, without a download. 38 built the same way, without a download.
39 39
40Without any of these, or with `-DLEONIDA_SDL3=OFF`, configure prints a message and `gta6rt` is built without the shim: 40Without any of these, or with `-DLEONIDA_SDL3=OFF`, configure prints a message and `gta6rt` is built without the SDL3
41it has no `GameInputCreate`, as before, so the loader binds it to the host's `GameInput.dll` or the unimplemented 41shim. It links `runtime/shims/gameinput_no_sdl.cpp` instead, which still serves `GameInputCreate` (by name and as
42thunk. `gameinput_test` and `gameinput_probe` are not built, and CTest lists `gameinput` as not run (disabled) rather 42`gameinput.dll!#1`): with no devices, or with `LEONIDA_INPUT_SCRIPT` set with one scripted pad (see
43than failing. 43[Scripted input without SDL3](#scripted-input-without-sdl3)). `gameinput_test` and `gameinput_probe` are not built,
44and CTest lists `gameinput` and `gameinput_script` as not run (disabled) rather than failing; `gameinput_no_sdl` and
45`gameinput_no_sdl_script` run instead.
46
47### Scripted input without SDL3
48
49The Windows artifacts of CI and offline builds have no SDL3. Without a device, the title waits at its first "press A"
50prompt forever, so no headless or CI run could get past it. With `LEONIDA_INPUT_SCRIPT` set, such a build serves one
51scripted pad, driven by the script alone:
52
53- **The device:** an Xbox One gamepad named `Scripted pad (Leonida)`, connected from the first `GameInputCreate`. It
54 is reported by `RegisterDeviceCallback` enumeration (blocking on the caller's thread, async from a thread of the
55 shim, or through `IGameInputDispatcher::Dispatch` once the title made a dispatcher) and found by `FindDeviceFromId`.
56 It is already connected, so a callback registered without enumeration hears nothing.
57- **The readings:** `GetCurrentReading`, `GetNextReading` and `GetPreviousReading`, with gamepad, UI navigation,
58 controller axis and controller button state. A reading is taken when the title asks for one and the script's state
59 has changed since the last, so no thread polls; the history keeps the last 64 readings.
60- **The timeline:** the same as with SDL3 (`runtime/shims/gameinput_script.h` holds the parser, the timeline and the
61 log lines for both): seconds from the first `GameInputCreate`, each press held 300 ms, then released.
62- **Not served:** reading callbacks, aggregate devices, rumble and every other device. Those slots answer `E_NOTIMPL`
63 and log the slot once. Controllers and the [keyboard pad](#keyboard-pad) still need SDL3.
64
65The start of the run logs one line with the counts, and each press logs the same lines as with SDL3:
66
67```text
68[rt] gameinput: served without SDL3: one scripted pad for LEONIDA_INPUT_SCRIPT (3 scripted press(es), 0 rejected); controllers and the keyboard pad need SDL3
69[rt] gameinput: scripted press of button 0 at 40.0 s
70[rt] gameinput: press a@40.0 (Scripted pad (Leonida))
71```
72
73A press is logged when the title reads it, so a press the title never reads is not logged. `LEONIDA_INPUT_LOG=0`
74turns the `press` lines off. Without `LEONIDA_INPUT_SCRIPT`, the shim serves no devices and answers `E_NOTIMPL` for
75every slot past `Release`, as before.
44 76
45`scripts/build_runtime.ps1` (what `make_game.py` runs) builds the shim only on its CMake path, when Visual Studio's 77`scripts/build_runtime.ps1` (what `make_game.py` runs) builds the shim only on its CMake path, when Visual Studio's
46C++ CMake tools are installed. Its direct-`cl.exe` fallback compiles a fixed file list without the shim and warns 78C++ CMake tools are installed. Its direct-`cl.exe` fallback compiles a fixed file list without the shim and warns
@@ -302,7 +334,7 @@ line is logged when it takes effect); tracking goes on underneath, so clearing i
302| `LEONIDA_PROMPTS_SWITCH_MS` | `300` | shortest time between two changes of the active input family, 0..2000 ms | 334| `LEONIDA_PROMPTS_SWITCH_MS` | `300` | shortest time between two changes of the active input family, 0..2000 ms |
303| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) | 335| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) |
304| `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus | 336| `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus |
305| `LEONIDA_INPUT_SCRIPT` | unset | With the keyboard pad enabled, set comma-separated `button@seconds` entries, e.g. `a@2,a@4,start@6`. The first pad update reads the script once at startup and starts the clock. `reload_config()` does not reread it. Each press lasts 300 ms. Buttons are `a b x y start back lb rb up down left right`. Spaces around entries are allowed. Empty entries, unknown buttons and invalid times (including negative or non-finite values) are counted and ignored. | 337| `LEONIDA_INPUT_SCRIPT` | unset | Comma-separated `button@seconds` entries, e.g. `a@2,a@4,start@6`. With SDL3 they drive the keyboard pad, which has to be enabled; without SDL3 they drive [one scripted pad](#scripted-input-without-sdl3), the only device. The first pad update (without SDL3, the first `GameInputCreate`) reads the script once at startup and starts the clock. `reload_config()` does not reread it. Each press lasts 300 ms. Buttons are `a b x y start back lb rb up down left right`. Spaces around entries are allowed. Empty entries, unknown buttons and invalid times (including negative or non-finite values) are counted and ignored. |
306| `LEONIDA_MOUSE_SENSITIVITY` | `1` | scales how far the mouse moves the keyboard pad's right stick, 0.1..10 | 338| `LEONIDA_MOUSE_SENSITIVITY` | `1` | scales how far the mouse moves the keyboard pad's right stick, 0.1..10 |
307 339
308SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to 340SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to
@@ -457,6 +489,14 @@ rests on a transcription rather than on a side-by-side compile.
457 button, the touchpad, a trigger or a stick, stick drift and a one-count mouse jitter ignored, a real mouse movement 489 button, the touchpad, a trigger or a stick, stick drift and a one-count mouse jitter ignored, a real mouse movement
458 counted, the 300 ms window on the real clock, and `LEONIDA_PROMPTS` forcing, changing, ignoring an unknown value 490 counted, the 300 ms window on the real clock, and `LEONIDA_PROMPTS` forcing, changing, ignoring an unknown value
459 and clearing. 491 and clearing.
492- `gameinput_no_sdl_test` (CTest, only in a build without SDL3, no controller): `gameinput_no_sdl` checks the
493 identity-only object (both names served, `AddRef`/`Release`, `E_NOTIMPL` without touching the out-parameter).
494 `gameinput_no_sdl_script` sets `LEONIDA_INPUT_SCRIPT` with overlapping presses, a mixed-case name, `rsup` and three
495 rejected entries, puts the shim on a fake clock and checks the scripted pad: blocking, async and dispatcher
496 enumeration (and none without enumeration, for another status or another kind), the device info, `FindDeviceFromId`,
497 the buttons, UI navigation and right stick read at chosen times (held for 0.3 s, a later press of the same button
498 not cut short, nothing after the script), no new reading without a change, `GetPreviousReading` and
499 `GetNextReading`, no motion, and reading callbacks answering `E_NOTIMPL`.
460- `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through 500- `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through
461 `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony 501 `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony
462 `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick, 502 `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick,