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:
authorNotRexed <therealnothingfn@gmail.com>2026-11-27 02:18:51 -0500
committerNotRexed <therealnothingfn@gmail.com>2026-11-27 02:18:51 -0500
commitdc6eb33c63fd57afeb4f917a56d8e7589dcb52e1 (patch)
tree6d4e7fa594f608d050c537e8bff6d78c6725f25b /docs/gameinput.md
parent5f7b9d08521fc7553b0652675581ca6e432bb8da (diff)
leonida-hle: read DualSense and DualShock 4 over HID, and follow which kind of input is in use
Sony pads (USB and Bluetooth) are read from the public HID report layouts without SDL, rumble goes out as output reports, and a pad that XInput already shows through a remapper is not read twice. gameinput::active_family() says Xbox, PlayStation or keyboard and mouse (LEONIDA_PROMPTS forces it). Unit-tested on hand-made report bytes; not run against a real pad. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/gameinput.md')
-rw-r--r--docs/gameinput.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md
index 2f71b8105..ee2885efa 100644
--- a/docs/gameinput.md
+++ b/docs/gameinput.md
@@ -174,6 +174,41 @@ gives the mouse back. Settings: `LEONIDA_MOUSE_SENSITIVITY` (1, 0.1..10), `LEONI
174whenever the window has focus). Unit-tested (`mouse_look_turns_speed_into_a_stick_past_the_dead_zone`); the dead zone 174whenever the window has focus). Unit-tested (`mouse_look_turns_speed_into_a_stick_past_the_dead_zone`); the dead zone
175and curve are first guesses at the title's own stick response, not measured. 175and curve are first guesses at the title's own stick response, not measured.
176 176
177## PlayStation pads and the active input of the D3D12 runtime
178
179The D3D12 runtime has no SDL. Besides XInput it reads Sony pads (vendor `054C`: DualSense `0CE6`, DualSense Edge `0DF2`,
180DualShock 4 `05C4`, `09CC`, USB adapter `0BA0`) over Windows HID directly (`gameinput/hid.rs`), on USB and Bluetooth,
181written from the public report layouts (the Linux `hid-playstation` driver documents them). One thread per pad reads
182input reports; a rescan every 2 s finds pads that came or went. A Bluetooth pad is moved to its full report by reading
183calibration feature report `0x05`.
184
185| | USB input | Bluetooth input | USB output | Bluetooth output |
186|---|---|---|---|---|
187| DualSense | `0x01`, 64 bytes, data from byte 1 | `0x31`, 78 bytes, data from byte 2 | `0x02`, 63 | `0x31`, 78, CRC-32 last |
188| DualShock 4 | `0x01`, 64 bytes, data from byte 1 | `0x11`, data from byte 3 | `0x05`, 32 | `0x11`, 78, CRC-32 last |
189
190Buttons: Cross, Circle, Square, Triangle are A, B, X, Y; L1/R1 the shoulders; L2/R2 the triggers (analog byte, the
191digital bit is ignored); L3/R3 the stick clicks; Options is Menu; Create (Share) and the touchpad click are View;
192the PS and mute buttons are not passed. Sticks are 0..255, centre 128. Rumble: the big motor of the title's
193`SetRumbleState` goes to the pad's left motor, the small one to its right (`rumble_report`; on Bluetooth the CRC is
194seeded with `0xA2`). Trigger effects and the lightbar are not driven. A Sony pad takes the first slot XInput leaves
195empty (all pads are one pad for the title anyway, `LEONIDA_ONE_PAD`).
196
197A pad that Steam Input or DS4Windows already shows through XInput is not read twice: when input comes on an XInput pad and
198on a readable Sony pad within 150 ms of each other, they are one controller for the next 10 s, and the Sony pad's own
199reading is left out of what the title sees. A Sony pad present but not openable (hidden by HidHide, held exclusively)
200counts the same way: input on XInput is then PlayStation input.
201
202**Active input.** `gameinput::active_family()` (`leonida-hle`, readable from any thread, lock-free) says which kind of
203device was used last: `Family::Xbox`, `Family::PlayStation` or `Family::KeyboardMouse`; `family_generation()` goes up by one
204with each change. It follows the rules of [Active input](#active-input) above (an edge counts, the first reading of a
205device is its baseline, a change waits `LEONIDA_PROMPTS_SWITCH_MS` = 300 ms), with the keyboard and mouse as a third
206family (a key going down, or mouse look pushing the stick past 0.35). Before the first input it is PlayStation if a Sony pad is
207present and Xbox otherwise. One line is logged on each change (`input in use: PlayStation (Sony pad input)`).
208`LEONIDA_PROMPTS=xbox|playstation|keyboard|auto` forces it. The button prompts follow it: see
209[prompt_glyphs.md](prompt_glyphs.md). Unit-tested on hand-made report bytes and the family rules; not run against a
210real pad yet.
211
177## Rumble and triggers 212## Rumble and triggers
178 213
179`IGameInputDevice::SetRumbleState` takes four motor levels, 0..1. The two body motors go to `SDL_RumbleGamepad` on 214`IGameInputDevice::SetRumbleState` takes four motor levels, 0..1. The two body motors go to `SDL_RumbleGamepad` on