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:
authorquackottu <224479491+quackottu@users.noreply.github.com>2026-11-22 12:49:29 +0530
committerquackottu <224479491+quackottu@users.noreply.github.com>2026-11-22 12:49:29 +0530
commit851eb563b62c821ac2f7ee9aa375b21cb58b60f3 (patch)
treed66d4a9e0f52887d8684787c124b7a318076355f /docs/gameinput.md
parentc63773d51235d72250d48699f29830ac9ddafd60 (diff)
gameinput: keyboard pad moves and aims: WASD left stick, mouse right stick, mouse buttons LT/RT
The keyboard pad only pressed buttons, enough for menus. WASD now drives the left stick (opposite keys cancel, diagonals on the round gate), cursor movement the right stick (decaying back to center), and the right/left mouse buttons the left/right triggers. Everything is released on focus loss. A set_cursor_source seam sits beside set_keyboard_source for tests.
Diffstat (limited to 'docs/gameinput.md')
-rw-r--r--docs/gameinput.md33
1 files changed, 26 insertions, 7 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md
index 855d2626e..055cec655 100644
--- a/docs/gameinput.md
+++ b/docs/gameinput.md
@@ -80,15 +80,29 @@ default.
80| Q / E | left / right shoulder | 80| Q / E | left / right shoulder |
81| Esc | `Menu` | 81| Esc | `Menu` |
82| Tab | `View` | 82| Tab | `View` |
83| W / A / S / D | left stick up / left / down / right |
84| mouse movement | right stick |
85| right mouse button | left trigger (aim) |
86| left mouse button | right trigger (fire) |
83 87
84This is enough to drive menus and press prompts. The sticks and triggers stay at rest: moving with WASD and aiming 88Letters are Windows virtual-key codes, so `Y` is the key labelled Y on the active layout (it sits where Z does on a
85with the mouse are for a later change. Letters are Windows virtual-key codes, so `Y` is the key labelled Y on the 89QWERTY keyboard with a German layout). Mouse buttons are the physical ones: `GetAsyncKeyState` ignores the
86active layout (it sits where Z does on a QWERTY keyboard with a German layout). 90swapped-buttons setting.
91
92WASD pushes the left stick to full deflection. Opposite keys cancel (W+S is centered on Y), and a diagonal sits on
93the round gate as a real stick reports it: about 0.707 on each axis, not 1.
94
95The right stick follows the cursor's movement (`GetCursorPos`), not its position. Each poll (2 ms with the
96background thread) the stick keeps 7/8 of its value and adds 1024 axis units (of 32767) per pixel the cursor moved
97since the last poll, clamped to full. Steady movement of 4 pixels a poll (2000 pixels a second) is full deflection;
98when the mouse stops, the stick falls back from full to exactly 0 in 67 polls (134 ms). Moving the mouse down pushes
99the stick down. The cursor is not captured, so movement stops counting when it reaches the edge of the screen.
87 100
88Keys are read with `GetAsyncKeyState`, which needs no window or message loop (SDL's keyboard is part of its video 101Keys 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 102subsystem, 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 103window of this process is in the foreground, so typing in another application presses nothing, and every button,
91released when focus moves away. `LEONIDA_KEYBOARD_PAD=always` reads them whatever has focus; a console tool such as 104stick and trigger is released when focus moves away (the cursor is read afresh when focus returns, so the right
105stick does not jump). `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. 106`gameinput_probe` needs it, because its console window belongs to the terminal, not to the tool.
93 107
94To try it by hand: `set LEONIDA_KEYBOARD_PAD=always`, then `gameinput_probe --seconds 20` and press keys. 108To try it by hand: `set LEONIDA_KEYBOARD_PAD=always`, then `gameinput_probe --seconds 20` and press keys.
@@ -222,8 +236,10 @@ shim fills (`GameInputDeviceInfo` 320 bytes with `deviceFamily` at 96 and the in
222 dispatcher, async and blocking enumeration, unregistering, unplugging and replugging, and three identical pads 236 dispatcher, async and blocking enumeration, unregistering, unplugging and replugging, and three identical pads
223 (an id each, `FindDeviceFromId` and device-filtered readings per pad, replugging one, two and all three, and the 237 (an id each, `FindDeviceFromId` and device-filtered readings per pad, replugging one, two and all three, and the
224 first twin's id equal to the single-pad id). The keyboard pad is 238 first twin's id equal to the single-pad id). The keyboard pad is
225 driven through `rt::gameinput::set_keyboard_source` with fake keys and focus: every binding, two keys at once, no 239 driven through `rt::gameinput::set_keyboard_source` and `set_cursor_source` with fake keys, focus and cursor: every
226 input out of focus, release on focus loss, the `always` mode, and turning it off and on again. 240 binding, two keys at once, each WASD direction, opposite keys cancelling, diagonals, the mouse moving the right
241 stick, clamping and decaying to 0, the mouse-button triggers, no input out of focus, release of buttons, sticks and
242 triggers on focus loss, the `always` mode, and turning it off and on again.
227- `gameinput_probe [--seconds N] [--rumble]` (by hand, with a pad connected): lists the pads, plays each motor and 243- `gameinput_probe [--seconds N] [--rumble]` (by hand, with a pad connected): lists the pads, plays each motor and
228 trigger for a second with `--rumble`, then prints the live reading. 244 trigger for a second with `--rumble`, then prints the live reading.
229 245
@@ -250,5 +266,8 @@ These need the game executable or a test on hardware:
250- **Keyboard pad as a second pad**: it is one more connected gamepad, so with a controller plugged in the title sees 266- **Keyboard pad as a second pad**: it is one more connected gamepad, so with a controller plugged in the title sees
251 two. A title that follows only the first pad it saw, or asks the player to press a button to pick the active pad, 267 two. A title that follows only the first pad it saw, or asks the player to press a button to pick the active pad,
252 may ignore one of them; whether the game does either is unknown. 268 may ignore one of them; whether the game does either is unknown.
269- **Mouse on the right stick**: the scale (1024 units per pixel per poll) and decay (7/8 per poll) are a starting
270 point, not tuned in game. The title adds its own stick acceleration and deadzone on top, so aiming may feel slow
271 near center or jumpy.
253- **DualSense effect parameters**: the `06` (vibration) and `01` (resistance) byte meanings follow SDL's 272- **DualSense effect parameters**: the `06` (vibration) and `01` (resistance) byte meanings follow SDL's
254 `testcontroller.c`; how strong 255 feels and what frequency suits the Xbox signal needs a session on a real pad. 273 `testcontroller.c`; how strong 255 feels and what frequency suits the Xbox signal needs a session on a real pad.