diff options
| author | Дмитрий Корлодный <deusex1998@gmail.com> | 2026-11-28 13:59:13 +0000 |
|---|---|---|
| committer | Дмитрий Корлодный <deusex1998@gmail.com> | 2026-11-28 13:59:13 +0000 |
| commit | 5fbcc642a52de0f269be65a9dce208dcb87f00fe (patch) | |
| tree | 518cbe01fe433c290c4cdcd5955bf4585facd68a /docs/gameinput.md | |
| parent | f7e422ee8a307ced9a41e11fb02330b4cb7abdaa (diff) | |
| parent | 9c49bd5332327e689c5c957786c31b10efb3f32b (diff) | |
Merge upstream main into PR #1559
Diffstat (limited to 'docs/gameinput.md')
| -rw-r--r-- | docs/gameinput.md | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md index 3228808b5..9b9975a69 100644 --- a/docs/gameinput.md +++ b/docs/gameinput.md | |||
| @@ -55,10 +55,13 @@ 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 reading is taken when the title asks for one and the script's state | 58 | controller axis and controller button state. A reading is taken when the title asks for one, so no thread polls, |
| 59 | has changed since the last, so no thread polls; the history keeps the last 64 readings. | 59 | but it first adds one reading for every change the script made since the last, stamped with the script's own time: |
| 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. | ||
| 60 | - **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 |
| 61 | log lines for both): seconds from the first `GameInputCreate`, each press held 300 ms, then released. | 63 | log lines for both): seconds from the first `GameInputCreate`, each press held 300 ms (or its own `:hold`, see |
| 64 | `LEONIDA_INPUT_SCRIPT` below), then released. | ||
| 62 | - **Not served:** reading callbacks, aggregate devices, rumble and every other device. Those slots answer `E_NOTIMPL` | 65 | - **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. | 66 | and log the slot once. Controllers and the [keyboard pad](#keyboard-pad) still need SDL3. |
| 64 | 67 | ||
| @@ -70,10 +73,17 @@ The start of the run logs one line with the counts, and each press logs the same | |||
| 70 | [rt] gameinput: press a@40.0 (Scripted pad (Leonida)) | 73 | [rt] gameinput: press a@40.0 (Scripted pad (Leonida)) |
| 71 | ``` | 74 | ``` |
| 72 | 75 | ||
| 73 | 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 |
| 74 | 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 | ||
| 75 | every slot past `Release`, as before. | 81 | every slot past `Release`, as before. |
| 76 | 82 | ||
| 83 | `LEONIDA_INPUT_FILE=<path>` drives a run whose display takes no keyboard input (a headless session): every line | ||
| 84 | appended to that file names one button of the script's table (`a`, `down`, ...) and becomes a press at once, held | ||
| 85 | like a scripted one. The file is read again at most every 250 ms. It is for local runs only. | ||
| 86 | |||
| 77 | `scripts/build_runtime.ps1` (what `make_game.py` runs) builds the shim only on its CMake path, when Visual Studio's | 87 | `scripts/build_runtime.ps1` (what `make_game.py` runs) builds the shim only on its CMake path, when Visual Studio's |
| 78 | C++ CMake tools are installed. Its direct-`cl.exe` fallback compiles a fixed file list without the shim and warns | 88 | C++ CMake tools are installed. Its direct-`cl.exe` fallback compiles a fixed file list without the shim and warns |
| 79 | about it. | 89 | about it. |
| @@ -113,7 +123,8 @@ The title reads gamepads only, so keyboard input has to arrive as a gamepad. Wit | |||
| 113 | shim attaches one SDL virtual gamepad named `Keyboard pad (Leonida)` and presses its buttons from the keyboard on | 123 | shim attaches one SDL virtual gamepad named `Keyboard pad (Leonida)` and presses its buttons from the keyboard on |
| 114 | every poll. It then goes through the same path as a real pad: a device object, the next free player slot, readings, | 124 | every poll. It then goes through the same path as a real pad: a device object, the next free player slot, readings, |
| 115 | reading and device callbacks, and UI navigation derived from its buttons. It reports no rumble motors. It is off by | 125 | reading and device callbacks, and UI navigation derived from its buttons. It reports no rumble motors. It is off by |
| 116 | default. | 126 | default. If SDL fails to attach or open the keyboard pad, the shim retries after one second while the pad is |
| 127 | enabled. Only the first failure in a continuous series is logged; turning the pad off and back on retries immediately. | ||
| 117 | 128 | ||
| 118 | | key | button | | 129 | | key | button | |
| 119 | |---|---| | 130 | |---|---| |
| @@ -152,7 +163,9 @@ sensor, about a pixel at Windows' default pointer speed without acceleration, so | |||
| 152 | 163 | ||
| 153 | With raw input on and a window of this process in the foreground, the cursor is kept inside that window's client | 164 | With raw input on and a window of this process in the foreground, the cursor is kept inside that window's client |
| 154 | area (`ClipCursor`, re-applied every 100 ms) so that a click cannot land on another window; it is released when focus | 165 | area (`ClipCursor`, re-applied every 100 ms) so that a click cannot land on another window; it is released when focus |
| 155 | moves away or the keyboard pad is turned off. The cursor stays visible: hiding it has to happen on the thread that | 166 | moves away or the keyboard pad is turned off. It is also released while the window is moved or sized, while a |
| 167 | menu loop runs, and while a mouse press that began outside the client area (on the title bar or a border) is held, so | ||
| 168 | the window can still be dragged; it comes back once the button is released. The cursor stays visible: hiding it has to happen on the thread that | ||
| 156 | owns the game's window, which is the title's, not the shim's. | 169 | owns the game's window, which is the title's, not the shim's. |
| 157 | 170 | ||
| 158 | Keys are read with `GetAsyncKeyState`, which needs no window or message loop (SDL's keyboard is part of its video | 171 | Keys are read with `GetAsyncKeyState`, which needs no window or message loop (SDL's keyboard is part of its video |
| @@ -334,7 +347,7 @@ line is logged when it takes effect); tracking goes on underneath, so clearing i | |||
| 334 | | `LEONIDA_PROMPTS_SWITCH_MS` | `300` | shortest time between two changes of the active input family, 0..2000 ms | | 347 | | `LEONIDA_PROMPTS_SWITCH_MS` | `300` | shortest time between two changes of the active input family, 0..2000 ms | |
| 335 | | `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) | | 348 | | `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) | |
| 336 | | `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus | | 349 | | `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus | |
| 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. | | 350 | | `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, or `hold` seconds when the entry is `button@seconds:hold` (more than 0, at most 600). With SDL3 a press then stays down until the title has read the pads six times since it began, but never past 5 s from its start (or its hold, if longer). A title reads its pad once a frame, so at a few seconds a frame a 300 ms press can fall between two reads and never arrive: on the retail title's "Couldn't autosave" prompt, three 300 ms `b` presses did nothing, while 120 presses 0.5 s apart got through; one `b@1100:3` replaces them. Buttons are `a b x y start back lb rb up down left right`. Spaces around entries are allowed. Empty entries, unknown buttons, invalid times (including negative or non-finite values) and invalid holds (0 or less, more than 600, not a number) are counted and ignored. | |
| 338 | | `LEONIDA_MOUSE_SENSITIVITY` | `1` | scales how far the mouse moves the keyboard pad's right stick, 0.1..10 | | 351 | | `LEONIDA_MOUSE_SENSITIVITY` | `1` | scales how far the mouse moves the keyboard pad's right stick, 0.1..10 | |
| 339 | 352 | ||
| 340 | SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to | 353 | SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to |