diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 13:17:06 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 13:17:06 -0500 |
| commit | 657808a7df4d7f1ea636d29dda8127ec65575f1b (patch) | |
| tree | ec874c8efd8f70e4c78e49269083573c38958b82 /docs/gameinput.md | |
| parent | 48f87a9c9bea054b0072364ebf0e51e2d59f354d (diff) | |
gameinput (no SDL3): take the script's changes between two reads at their own time instead of a clock thread (maintainer fix on #2372)
#2372 started a detached thread that took the input lock every 8 ms, so that a scripted press that begins and ends
while the title is not reading reaches the reading history. That works around the cause and adds its own: the
history then depends on how the host schedules a Sleep(8) thread (a slow or loaded machine keeps fewer edges, and a
Windows timer tick of 15.6 ms drops a short hold), the thread never ends, and it contends with the title's reads.
The cause is that update() looked only at the state at the moment of the read. It now first adds a reading for every
start and end of a press since the last update, stamped with the script's time, then the state at the read: the
history is the same however often the title reads, on any machine, and no thread runs. The press log lines carry the
script's time of the press.
Also: LEONIDA_INPUT_TRACE (added by #2372) is documented in docs/gameinput.md and runtime/README.md, as
tests/test_docs_env_vars.py requires. gameinput_no_sdl_script gains y@10, which the title never reads while it is down
(reads at 4.5 s and 60 s): the press and its release must be in the history with their own timestamps. On main the
history has no Y reading.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/gameinput.md')
| -rw-r--r-- | docs/gameinput.md | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md index 2a613b1ba..e0df71085 100644 --- a/docs/gameinput.md +++ b/docs/gameinput.md | |||
| @@ -55,9 +55,10 @@ scripted pad, driven by the script alone: | |||
| 55 | shim, or through `IGameInputDispatcher::Dispatch` once the title made a dispatcher) and found by `FindDeviceFromId`. | 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. | 56 | It is already connected, so a callback registered without enumeration hears nothing. |
| 57 | - **The readings:** `GetCurrentReading`, `GetNextReading` and `GetPreviousReading`, with gamepad, UI navigation, | 57 | - **The readings:** `GetCurrentReading`, `GetNextReading` and `GetPreviousReading`, with gamepad, UI navigation, |
| 58 | controller axis and controller button state. A clock thread advances the script every 8 ms and stores each state | 58 | controller axis and controller button state. A reading is taken when the title asks for one, so no thread polls, |
| 59 | change so `GetNextReading` can observe edges while the title waits between reads; the history keeps the last 64 | 59 | but it first adds one reading for every change the script made since the last, stamped with the script's own time: |
| 60 | readings. | 60 | a press that starts and ends between two reads of the title is still in the history, where `GetNextReading` finds |
| 61 | it, and the readings are the same however often the title reads. The history keeps the last 64 readings. | ||
| 61 | - **The timeline:** the same as with SDL3 (`runtime/shims/gameinput_script.h` holds the parser, the timeline and the | 62 | - **The timeline:** the same as with SDL3 (`runtime/shims/gameinput_script.h` holds the parser, the timeline and the |
| 62 | log lines for both): seconds from the first `GameInputCreate`, each press held 300 ms (or its own `:hold`, see | 63 | log lines for both): seconds from the first `GameInputCreate`, each press held 300 ms (or its own `:hold`, see |
| 63 | `LEONIDA_INPUT_SCRIPT` below), then released. | 64 | `LEONIDA_INPUT_SCRIPT` below), then released. |
| @@ -72,8 +73,11 @@ The start of the run logs one line with the counts, and each press logs the same | |||
| 72 | [rt] gameinput: press a@40.0 (Scripted pad (Leonida)) | 73 | [rt] gameinput: press a@40.0 (Scripted pad (Leonida)) |
| 73 | ``` | 74 | ``` |
| 74 | 75 | ||
| 75 | A press is logged when the title reads it, so a press the title never reads is not logged. `LEONIDA_INPUT_LOG=0` | 76 | A press is logged at the next reading the title asks for, with the script's time of the press, so a press is logged |
| 76 | turns the `press` lines off. Without `LEONIDA_INPUT_SCRIPT`, the shim serves no devices and answers `E_NOTIMPL` for | 77 | once the title reads its pad again. `LEONIDA_INPUT_LOG=0` turns the `press` lines off. `LEONIDA_INPUT_TRACE=1` |
| 78 | (diagnostic, this shim only) logs what the title asks for: the first 128 `GetCurrentReading`, `GetNextReading` and | ||
| 79 | `GetPreviousReading` calls, then every one that returns a pressed button and every 1000th, the device callbacks and | ||
| 80 | `RegisterDeviceCallback` calls, and the first few calls of each reading method. Without `LEONIDA_INPUT_SCRIPT`, the shim serves no devices and answers `E_NOTIMPL` for | ||
| 77 | every slot past `Release`, as before. | 81 | every slot past `Release`, as before. |
| 78 | 82 | ||
| 79 | `LEONIDA_INPUT_FILE=<path>` drives a run whose display takes no keyboard input (a headless session): every line | 83 | `LEONIDA_INPUT_FILE=<path>` drives a run whose display takes no keyboard input (a headless session): every line |