diff options
| author | NotRexed <therealnothingfn@gmail.com> | 2026-11-27 02:18:51 -0500 |
|---|---|---|
| committer | NotRexed <therealnothingfn@gmail.com> | 2026-11-27 02:18:51 -0500 |
| commit | dc6eb33c63fd57afeb4f917a56d8e7589dcb52e1 (patch) | |
| tree | 6d4e7fa594f608d050c537e8bff6d78c6725f25b /docs/gameinput.md | |
| parent | 5f7b9d08521fc7553b0652675581ca6e432bb8da (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.md | 35 |
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 | |||
| 174 | whenever the window has focus). Unit-tested (`mouse_look_turns_speed_into_a_stick_past_the_dead_zone`); the dead zone | 174 | whenever the window has focus). Unit-tested (`mouse_look_turns_speed_into_a_stick_past_the_dead_zone`); the dead zone |
| 175 | and curve are first guesses at the title's own stick response, not measured. | 175 | and 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 | |||
| 179 | The D3D12 runtime has no SDL. Besides XInput it reads Sony pads (vendor `054C`: DualSense `0CE6`, DualSense Edge `0DF2`, | ||
| 180 | DualShock 4 `05C4`, `09CC`, USB adapter `0BA0`) over Windows HID directly (`gameinput/hid.rs`), on USB and Bluetooth, | ||
| 181 | written from the public report layouts (the Linux `hid-playstation` driver documents them). One thread per pad reads | ||
| 182 | input reports; a rescan every 2 s finds pads that came or went. A Bluetooth pad is moved to its full report by reading | ||
| 183 | calibration 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 | |||
| 190 | Buttons: Cross, Circle, Square, Triangle are A, B, X, Y; L1/R1 the shoulders; L2/R2 the triggers (analog byte, the | ||
| 191 | digital bit is ignored); L3/R3 the stick clicks; Options is Menu; Create (Share) and the touchpad click are View; | ||
| 192 | the 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 | ||
| 194 | seeded with `0xA2`). Trigger effects and the lightbar are not driven. A Sony pad takes the first slot XInput leaves | ||
| 195 | empty (all pads are one pad for the title anyway, `LEONIDA_ONE_PAD`). | ||
| 196 | |||
| 197 | A pad that Steam Input or DS4Windows already shows through XInput is not read twice: when input comes on an XInput pad and | ||
| 198 | on 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 | ||
| 199 | reading is left out of what the title sees. A Sony pad present but not openable (hidden by HidHide, held exclusively) | ||
| 200 | counts 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 | ||
| 203 | device was used last: `Family::Xbox`, `Family::PlayStation` or `Family::KeyboardMouse`; `family_generation()` goes up by one | ||
| 204 | with each change. It follows the rules of [Active input](#active-input) above (an edge counts, the first reading of a | ||
| 205 | device is its baseline, a change waits `LEONIDA_PROMPTS_SWITCH_MS` = 300 ms), with the keyboard and mouse as a third | ||
| 206 | family (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 | ||
| 207 | present 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 | ||
| 210 | real 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 |