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:
authorCodex <codex@openai.com>2026-11-25 21:56:35 +0000
committerCodex <codex@openai.com>2026-11-25 21:56:35 +0000
commitf7e422ee8a307ced9a41e11fb02330b4cb7abdaa (patch)
tree23c1aacc48c0f66b559d0525f2567cdf77e9c1bd /docs/gameinput.md
parenta05f1f3cdbb534d3261f8c557f39b637ac240ca8 (diff)
parentcb699500acb724f4ffa2873ee61b578e9d3e8627 (diff)
Merge upstream main into gameinput-hotplug
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 23a2230ba..3228808b5 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
@@ -461,6 +493,14 @@ rests on a transcription rather than on a side-by-side compile.
461 button, the touchpad, a trigger or a stick, stick drift and a one-count mouse jitter ignored, a real mouse movement 493 button, the touchpad, a trigger or a stick, stick drift and a one-count mouse jitter ignored, a real mouse movement
462 counted, the 300 ms window on the real clock, and `LEONIDA_PROMPTS` forcing, changing, ignoring an unknown value 494 counted, the 300 ms window on the real clock, and `LEONIDA_PROMPTS` forcing, changing, ignoring an unknown value
463 and clearing. 495 and clearing.
496- `gameinput_no_sdl_test` (CTest, only in a build without SDL3, no controller): `gameinput_no_sdl` checks the
497 identity-only object (both names served, `AddRef`/`Release`, `E_NOTIMPL` without touching the out-parameter).
498 `gameinput_no_sdl_script` sets `LEONIDA_INPUT_SCRIPT` with overlapping presses, a mixed-case name, `rsup` and three
499 rejected entries, puts the shim on a fake clock and checks the scripted pad: blocking, async and dispatcher
500 enumeration (and none without enumeration, for another status or another kind), the device info, `FindDeviceFromId`,
501 the buttons, UI navigation and right stick read at chosen times (held for 0.3 s, a later press of the same button
502 not cut short, nothing after the script), no new reading without a change, `GetPreviousReading` and
503 `GetNextReading`, no motion, and reading callbacks answering `E_NOTIMPL`.
464- `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through 504- `gameinput_test` (CTest, no controller): turns SDL's real backends off and drives the shim through
465 `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony 505 `rt::shims::find` with SDL virtual joysticks, an Xbox-style pad with trigger motors, a DualSense (Sony
466 `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick, 506 `054c:0ce6`) and a pad without trigger motors. It checks enumeration and device callbacks, the button, stick,