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:
authornicolas <44988633+nschlaepfer@users.noreply.github.com>2026-11-21 21:58:55 -0700
committernicolas <44988633+nschlaepfer@users.noreply.github.com>2026-11-21 21:58:55 -0700
commit5190d597c8c6efd4cefa615df79e7c1a5f008775 (patch)
treeb61d71980b1fdbfb7552873b320a84416263c770 /docs/gameinput.md
parentb72fc5a4fec776ffa4b19d37c7bf8d62836e3df5 (diff)
parent067d3e8b97189fcf272dc699fdbb871eae496660 (diff)
Merge keyboard-pad coverage with controller reading history
Diffstat (limited to 'docs/gameinput.md')
-rw-r--r--docs/gameinput.md39
1 files changed, 38 insertions, 1 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md
index 2faa2fdbc..bab5d423d 100644
--- a/docs/gameinput.md
+++ b/docs/gameinput.md
@@ -62,6 +62,37 @@ controller-button array (`GetControllerButtonState`, indexed in SDL's `SDL_Gamep
62- Player LEDs (and SDL's default lightbar colour) follow connection order: the first pad is player 1, and a pad 62- Player LEDs (and SDL's default lightbar colour) follow connection order: the first pad is player 1, and a pad
63 plugged in later takes the lowest free slot. 63 plugged in later takes the lowest free slot.
64 64
65## Keyboard pad
66
67The title reads gamepads only, so keyboard input has to arrive as a gamepad. With `LEONIDA_KEYBOARD_PAD` set, the
68shim attaches one SDL virtual gamepad named `Keyboard pad (Leonida)` and presses its buttons from the keyboard on
69every poll. It then goes through the same path as a real pad: a device object, the next free player slot, readings,
70reading and device callbacks, and UI navigation derived from its buttons. It reports no rumble motors. It is off by
71default.
72
73| key | button |
74|---|---|
75| arrow keys | d-pad |
76| Enter | `A` |
77| Backspace | `B` |
78| X | `X` |
79| Y | `Y` |
80| Q / E | left / right shoulder |
81| Esc | `Menu` |
82| Tab | `View` |
83
84This is enough to drive menus and press prompts. The sticks and triggers stay at rest: moving with WASD and aiming
85with the mouse are for a later change. Letters are Windows virtual-key codes, so `Y` is the key labelled Y on the
86active layout (it sits where Z does on a QWERTY keyboard with a German layout).
87
88Keys are read with `GetAsyncKeyState`, which needs no window or message loop (SDL's keyboard is part of its video
89subsystem, which this build leaves out) and works under Wine. With `LEONIDA_KEYBOARD_PAD=1` keys count only while a
90window of this process is in the foreground, so typing in another application presses nothing, and every button is
91released when focus moves away. `LEONIDA_KEYBOARD_PAD=always` reads them whatever has focus; a console tool such as
92`gameinput_probe` needs it, because its console window belongs to the terminal, not to the tool.
93
94To try it by hand: `set LEONIDA_KEYBOARD_PAD=always`, then `gameinput_probe --seconds 20` and press keys.
95
65## Rumble and triggers 96## Rumble and triggers
66 97
67`IGameInputDevice::SetRumbleState` takes four motor levels, 0..1. The two body motors go to `SDL_RumbleGamepad` on 98`IGameInputDevice::SetRumbleState` takes four motor levels, 0..1. The two body motors go to `SDL_RumbleGamepad` on
@@ -101,6 +132,7 @@ An effect is sent only when its bytes change, so a steady level costs one report
101| `LEONIDA_DS_LIGHTBAR` | unset | `RRGGBB` (hex) sets the DualSense/DualShock 4 lightbar when the pad connects; `off` turns it dark; unset keeps SDL's player colour | 132| `LEONIDA_DS_LIGHTBAR` | unset | `RRGGBB` (hex) sets the DualSense/DualShock 4 lightbar when the pad connects; `off` turns it dark; unset keeps SDL's player colour |
102| `LEONIDA_RUMBLE` | `1` | `0` turns all rumble and trigger output off | 133| `LEONIDA_RUMBLE` | `1` | `0` turns all rumble and trigger output off |
103| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) | 134| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) |
135| `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus |
104 136
105SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to 137SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to
106leave a DualSense to the generic driver, or `SDL_GAMECONTROLLERCONFIG` to add a mapping for an unknown pad. 138leave a DualSense to the generic driver, or `SDL_GAMECONTROLLERCONFIG` to add a mapping for an unknown pad.
@@ -171,7 +203,9 @@ shim fills (`GameInputDeviceInfo` 320 bytes with `deviceFamily` at 96 and the in
171 the fact, both directions, two pads interleaved and filtered by device, ageing out, held readings, unplug and 203 the fact, both directions, two pads interleaved and filtered by device, ageing out, held readings, unplug and
172 replug), the guide button, motor and trigger 204 replug), the guide button, motor and trigger
173 rumble as SDL receives them, the DualSense effect bytes in each `LEONIDA_DS_TRIGGERS` mode, the lightbar, a 205 rumble as SDL receives them, the DualSense effect bytes in each `LEONIDA_DS_TRIGGERS` mode, the lightbar, a
174 dispatcher, async and blocking enumeration, unregistering, and unplugging and replugging. 206 dispatcher, async and blocking enumeration, unregistering, and unplugging and replugging. The keyboard pad is
207 driven through `rt::gameinput::set_keyboard_source` with fake keys and focus: every binding, two keys at once, no
208 input out of focus, release on focus loss, the `always` mode, and turning it off and on again.
175- `gameinput_probe [--seconds N] [--rumble]` (by hand, with a pad connected): lists the pads, plays each motor and 209- `gameinput_probe [--seconds N] [--rumble]` (by hand, with a pad connected): lists the pads, plays each motor and
176 trigger for a second with `--rumble`, then prints the live reading. 210 trigger for a second with `--rumble`, then prints the live reading.
177 211
@@ -192,5 +226,8 @@ These need the game executable or a test on hardware:
192- **`UnregisterCallback` timeout** is not honoured; it waits for a callback that is running. 226- **`UnregisterCallback` timeout** is not honoured; it waits for a callback that is running.
193- **Device family**: every pad is reported as `GameInputFamilyXboxOne`; a title that filters on family sees only 227- **Device family**: every pad is reported as `GameInputFamilyXboxOne`; a title that filters on family sees only
194 that. 228 that.
229- **Keyboard pad as a second pad**: it is one more connected gamepad, so with a controller plugged in the title sees
230 two. A title that follows only the first pad it saw, or asks the player to press a button to pick the active pad,
231 may ignore one of them; whether the game does either is unknown.
195- **DualSense effect parameters**: the `06` (vibration) and `01` (resistance) byte meanings follow SDL's 232- **DualSense effect parameters**: the `06` (vibration) and `01` (resistance) byte meanings follow SDL's
196 `testcontroller.c`; how strong 255 feels and what frequency suits the Xbox signal needs a session on a real pad. 233 `testcontroller.c`; how strong 255 feels and what frequency suits the Xbox signal needs a session on a real pad.