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:
authorCozma <65982369+Cozmaaa@users.noreply.github.com>2026-11-22 18:09:44 +0200
committerCozma <65982369+Cozmaaa@users.noreply.github.com>2026-11-22 18:09:44 +0200
commit3ff74e8d58cb9420e4dae884378b98eb55ce62b2 (patch)
treeeed1cb4e1caa7d5aa5c42c19cafaf49da97c457c /docs/gameinput.md
parent4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff)
gameinput: the keyboard pad's right stick reads raw mouse input and keeps the cursor in the window
GetCursorPos deltas stop at the screen edge and include pointer acceleration. A message-only window on its own thread now registers for raw mouse input (RIDEV_INPUTSINK) and sums the relative counts; the poll takes the difference of that total. Absolute reports are ignored, and GetCursorPos stays as the fallback if registration fails. With raw input on and a window of this process in the foreground, the cursor is clipped to that window's client area (re-applied every 100 ms), and released on focus loss or when the pad is turned off. LEONIDA_MOUSE_SENSITIVITY (0.1..10, default 1) scales the axis units per count.
Diffstat (limited to 'docs/gameinput.md')
-rw-r--r--docs/gameinput.md26
1 files changed, 21 insertions, 5 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md
index f848ab0d2..6a98ed5a0 100644
--- a/docs/gameinput.md
+++ b/docs/gameinput.md
@@ -92,11 +92,23 @@ swapped-buttons setting.
92WASD pushes the left stick to full deflection. Opposite keys cancel (W+S is centered on Y), and a diagonal sits on 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. 93the round gate as a real stick reports it: about 0.707 on each axis, not 1.
94 94
95The right stick follows the cursor's movement (`GetCursorPos`), not its position. Each poll (2 ms with the 95The right stick follows the mouse's movement, not the cursor's position. Each poll (2 ms with the background thread)
96background thread) the stick keeps 7/8 of its value and adds 1024 axis units (of 32767) per pixel the cursor moved 96the stick keeps 7/8 of its value and adds 1024 axis units (of 32767, times `LEONIDA_MOUSE_SENSITIVITY`) per count the mouse moved since the last poll,
97since the last poll, clamped to full. Steady movement of 4 pixels a poll (2000 pixels a second) is full deflection; 97clamped to full. Steady movement of 4 counts a poll (2000 a second) is full deflection; when the mouse stops, the
98when the mouse stops, the stick falls back from full to exactly 0 in 67 polls (134 ms). Moving the mouse down pushes 98stick falls back from full to exactly 0 in 67 polls (134 ms). Moving the mouse down pushes the stick down.
99the stick down. The cursor is not captured, so movement stops counting when it reaches the edge of the screen. 99
100The movement comes from raw input (`WM_INPUT`): what the mouse itself reports, so it does not stop at the edge of the
101screen and Windows' pointer acceleration does not change it. When the keyboard pad attaches, the shim starts one
102thread with a message-only window (never shown) registered for raw mouse input (`RIDEV_INPUTSINK`), which adds each
103relative movement to a running total; the poll takes the difference of that total between polls. Absolute reports
104(remote desktop, some virtual machines, pen tablets) are ignored. If the window or the registration fails, the shim
105logs it and falls back to `GetCursorPos` deltas, which stop at the screen edge. A count is one step of the mouse's
106sensor, about a pixel at Windows' default pointer speed without acceleration, so the feel depends on the mouse's DPI.
107
108With raw input on and a window of this process in the foreground, the cursor is kept inside that window's client
109area (`ClipCursor`, re-applied every 100 ms) so that a click cannot land on another window; it is released when focus
110moves away or the keyboard pad is turned off. The cursor stays visible: hiding it has to happen on the thread that
111owns the game's window, which is the title's, not the shim's.
100 112
101Keys are read with `GetAsyncKeyState`, which needs no window or message loop (SDL's keyboard is part of its video 113Keys are read with `GetAsyncKeyState`, which needs no window or message loop (SDL's keyboard is part of its video
102subsystem, which this build leaves out) and works under Wine. With `LEONIDA_KEYBOARD_PAD=1` keys count only while a 114subsystem, which this build leaves out) and works under Wine. With `LEONIDA_KEYBOARD_PAD=1` keys count only while a
@@ -170,6 +182,7 @@ sensors are enabled when the pad is opened, at SDL's requested rate, and every p
170| `LEONIDA_RUMBLE` | `1` | `0` turns all rumble and trigger output off | 182| `LEONIDA_RUMBLE` | `1` | `0` turns all rumble and trigger output off |
171| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) | 183| `LEONIDA_GAMEINPUT_THREAD` | `1` | `0` stops the background poll thread; only `rt::gameinput::poll()` then reads the pads (tests) |
172| `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus | 184| `LEONIDA_KEYBOARD_PAD` | `off` | `1` adds the [keyboard pad](#keyboard-pad), read while this process has focus; `always` reads keys whatever has focus |
185| `LEONIDA_MOUSE_SENSITIVITY` | `1` | scales how far the mouse moves the keyboard pad's right stick, 0.1..10 |
173 186
174SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to 187SDL's own hints (`SDL_JOYSTICK_*`, see SDL's `SDL_hints.h`) also apply, for example `SDL_JOYSTICK_HIDAPI_PS5=0` to
175leave a DualSense to the generic driver, or `SDL_GAMECONTROLLERCONFIG` to add a mapping for an unknown pad. 188leave a DualSense to the generic driver, or `SDL_GAMECONTROLLERCONFIG` to add a mapping for an unknown pad.
@@ -295,6 +308,9 @@ These need the game executable or a test on hardware:
295- **Identical pads at start**: twins are numbered in the order the shim opens them. For pads already connected when 308- **Identical pads at start**: twins are numbered in the order the shim opens them. For pads already connected when
296 it starts, that is SDL's enumeration order, not measured on Windows for identical pads; if it varies between runs, 309 it starts, that is SDL's enumeration order, not measured on Windows for identical pads; if it varies between runs,
297 so does which pad gets which id. 310 so does which pad gets which id.
311- **Raw mouse registration**: Windows keeps one raw-input target window per device type and process, so if the title
312 registers raw mouse input itself (a console title is not expected to), it replaces the shim's registration and the
313 right stick falls back to nothing. The shim does not detect that yet.
298- **Keyboard pad as a second pad**: it is one more connected gamepad, so with a controller plugged in the title sees 314- **Keyboard pad as a second pad**: it is one more connected gamepad, so with a controller plugged in the title sees
299 two. A title that follows only the first pad it saw, or asks the player to press a button to pick the active pad, 315 two. A title that follows only the first pad it saw, or asks the player to press a button to pick the active pad,
300 may ignore one of them; whether the game does either is unknown. 316 may ignore one of them; whether the game does either is unknown.