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:
authorVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-23 00:19:13 +0100
committerVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-23 00:19:13 +0100
commitfcda84bb0d2c6abb99e42409f413025d00ddb4be (patch)
tree27a5ee092be10547ffa5b4447ee050c623c62850 /docs/gameinput.md
parent3a1ed28bebf374321149bc4bbffc005ea6f691c4 (diff)
parent3986b50821272791333c00df80bdb8526a8fdb9c (diff)
Merge hw4-ps-oracle into hw4-ps-formats (#3499)
docs/shader_validation.md tools/ps_oracle.py AI-assisted.
Diffstat (limited to 'docs/gameinput.md')
-rw-r--r--docs/gameinput.md83
1 files changed, 75 insertions, 8 deletions
diff --git a/docs/gameinput.md b/docs/gameinput.md
index 21421351e..fa216a2ee 100644
--- a/docs/gameinput.md
+++ b/docs/gameinput.md
@@ -264,24 +264,74 @@ never touch SDL: they read the latest reading or leave a request, so a call cost
264button) run on that thread, as GameInput runs them on its own threads. Once the title creates a dispatcher 264button) run on that thread, as GameInput runs them on its own threads. Once the title creates a dispatcher
265(`IGameInput::CreateDispatcher`), callbacks are queued instead, the dispatcher's wait handle is signalled, and 265(`IGameInput::CreateDispatcher`), callbacks are queued instead, the dispatcher's wait handle is signalled, and
266`IGameInputDispatcher::Dispatch` runs them on the title's thread, oldest first, within its quota: at least one queued 266`IGameInputDispatcher::Dispatch` runs them on the title's thread, oldest first, within its quota: at least one queued
267event per call (a quota of 0 runs exactly one), no further event once the quota has passed, and the wait handle is 267event per call (a quota of 0 runs exactly one), no further event once the quota has passed, and only the events
268signalled again while events remain. 268queued when the call started (later ones wait for the next call, so even an unlimited quota returns). The wait
269handle is signalled again while events remain.
269 270
270The API surface: 271The API surface:
271 272
272| interface | implemented | not implemented | 273| interface | implemented | not implemented |
273|---|---|---| 274|---|---|---|
274| `IGameInput` | `GetCurrentTimestamp` (µs), `GetCurrentReading`, `GetNextReading`, `GetPreviousReading`, `RegisterReadingCallback`, `RegisterDeviceCallback` (blocking and async enumeration), `RegisterGuideButtonCallback`, `RegisterKeyboardLayoutCallback` (never fires), `StopCallback`, `UnregisterCallback`, `CreateDispatcher`, `FindDeviceFromId`, `EnableOemDeviceSupport` (no-op), `SetFocusPolicy` (no-op) | `GetTemporalReading` (`E_NOTIMPL`, as in GameInput v0 itself; see below), `CreateAggregateDevice`, `FindDeviceFromObject/PlatformHandle/PlatformString` | 275| `IGameInput` | `GetCurrentTimestamp` (µs), `GetCurrentReading`, `GetNextReading`, `GetPreviousReading`, `RegisterReadingCallback`, `RegisterDeviceCallback` (blocking and async enumeration), `RegisterGuideButtonCallback`, `RegisterKeyboardLayoutCallback` (never fires), `StopCallback`, `UnregisterCallback`, `CreateDispatcher`, `FindDeviceFromId`, `EnableOemDeviceSupport` (no-op), `SetFocusPolicy` (no-op) | `GetTemporalReading` (`E_NOTIMPL`, as in GameInput v0 itself; see below), `CreateAggregateDevice`, `FindDeviceFromObject/PlatformHandle/PlatformString` |
275| `IGameInputReading` | kind, sequence number, timestamp, device, gamepad state, UI navigation state, controller axes and buttons, motion state | raw report, keyboard, mouse, touch, arcade/flight stick, racing wheel (all return nothing) | 276| `IGameInputReading` | kind, sequence number, timestamp, device, gamepad state, UI navigation state, controller axes and buttons, motion state, raw report (pads opened through HID, see [Raw HID](#raw-hid)) | keyboard, mouse, touch, arcade/flight stick, racing wheel (all return nothing) |
276| `IGameInputDevice` | device info, status, battery, `SetRumbleState`, force-feedback motors with `CreateForceFeedbackEffect`/`IGameInputForceFeedbackEffect`, `IsForceFeedbackMotorPoweredOn`, `SetForceFeedbackMotorGain`, haptic trigger motors with `SetHapticMotorState` | raw device I/O, power off, input synchronization (no-ops) | 277| `IGameInputDevice` | device info, status, battery, `SetRumbleState`, force-feedback motors with `CreateForceFeedbackEffect`/`IGameInputForceFeedbackEffect`, `IsForceFeedbackMotorPoweredOn`, `SetForceFeedbackMotorGain`, haptic trigger motors with `SetHapticMotorState`, `CreateRawDeviceReport`, `GetRawDeviceFeature`, `SetRawDeviceFeature`, `SendRawDeviceOutput` (pads opened through HID) | `SendRawDeviceOutputWithResponse`, `ExecuteRawDeviceIoControl`, exclusive raw access, power off, input synchronization (no-ops) |
277| `IGameInputDispatcher` | `Dispatch`, `OpenWaitHandle` | the quota (the queue is short) | 278| `IGameInputRawDeviceReport` | device, report info (kind, id, size), raw data size, get and set raw data | item values (`Get/Set/ResetItemValue`, `ResetAllItems` answer false: no item tables) |
278| `IGameInputDevice` | device info, status, battery, `SetRumbleState` | force feedback and haptic motors (none reported), raw device I/O, power off, input synchronization (no-ops) |
279| `IGameInputDispatcher` | `Dispatch` (with its quota), `OpenWaitHandle` | | 279| `IGameInputDispatcher` | `Dispatch` (with its quota), `OpenWaitHandle` | |
280 280
281`CreateAggregateDevice` takes exactly one of the keyboard, mouse, gamepad, arcade stick, flight stick or racing wheel
282kinds (none, several, or another kind is `E_INVALIDARG`) and returns one device per kind, the same object on every
283call: family `GameInputFamilyAggregate`, always connected, with that kind as its `supportedInput`, and a fixed
284`deviceId` per kind that `FindDeviceFromId` also answers. Readings asked
285through it (`GetCurrentReading`, `GetNextReading`, `GetPreviousReading`) come from every connected device of that
286kind (`GetCurrentReading` answers the most recent of them); asking it for another kind is
287`GAMEINPUT_E_READING_NOT_FOUND`. A reading or device callback registered with an aggregate device as its filter is
288refused with `E_NOTIMPL` and an invalid token.
289
281A device object stays alive for the whole process. When a pad is unplugged its status drops to 290A device object stays alive for the whole process. When a pad is unplugged its status drops to
282`GameInputDeviceNoStatus` and its device callback runs; when the same pad is plugged in again (matched by SDL GUID and 291`GameInputDeviceNoStatus` and its device callback runs; when the same pad is plugged in again (matched by SDL GUID and
283serial or device path) the title gets the same object back, connected again. 292serial or device path) the title gets the same object back, connected again.
284 293
294## Raw HID
295
296A title can read a pad's raw HID input reports and send it output and feature reports (RT-175). The shim opens each
297pad's HID device through SDL's hidapi (`SDL_hid_*`), by the device path SDL reports for the pad. When that path is not
298a HID path, it falls back to the pad's vendor and product id, but only when exactly one game-pad collection (usage page
2991, usage 5) has them, so twins never mix. It reads the report descriptor to find every input, output and feature
300report: its id (0 when the descriptor declares none) and its payload size in bytes, without the id byte.
301
302A pad opened this way gets the following:
303
304- `GameInputKindRawDeviceReport` in `supportedInput` and `GameInputDeviceRawIoEnabled` in its status.
305- `inputReportInfo`, `outputReportInfo` and `featureReportInfo` tables with their counts. Every report has `itemCount`
306 0: the descriptor's items (usages, logical ranges, units) are not decoded.
307- Readings that carry the newest raw input report. Each poll drains the reports that arrived, the last declared one
308 wins, and a report with new bytes makes a reading of its own. Before the first report, a reading carries none.
309- These device calls, each on any `IGameInputRawDeviceReport` of the right kind whose id the pad declares:
310 - `CreateRawDeviceReport(id, kind)` makes a zeroed report.
311 - `GetRawDeviceFeature(id)` reads a feature report.
312 - `SetRawDeviceFeature` sends one.
313 - `SendRawDeviceOutput` writes an output report.
314
315 An undeclared id or kind is `E_INVALIDARG`, and a failed transfer `E_FAIL`.
316
317`SetRawData` takes a buffer of exactly the report's size and refuses any other size, so a report is never half old and
318half new. The item calls answer false. `SendRawDeviceOutputWithResponse`, `ExecuteRawDeviceIoControl` and exclusive
319access still return `E_NOTIMPL` / false.
320
321A pad without such a HID device keeps the old answers: no raw kind, no tables, `E_NOTIMPL` from the raw calls.
322
323- **Xbox pads on Windows** are read by SDL through XInput (path `XInput#n`). SDL's hidapi skips their XInput HID
324 interface (`&IG_` in the path), noting that it carries no full HID reports. So they have no raw I/O here, and the log
325 says so.
326- **SDL virtual joysticks and the keyboard pad** have no path, so no HID device either.
327- **Pads SDL reads through hidapi** can have raw I/O: DualSense, DualShock 4, Switch Pro, and most others in DirectInput
328 mode.
329
330`rt::gameinput::set_hid_backend` replaces the hidapi backend (tests). `rt::gameinput::parse_report_descriptor` is the
331descriptor walk: main items Input, Output and Feature add Report Size × Report Count bits to the current Report ID, Push
332and Pop save and restore the globals, and long items are skipped. It refuses a truncated item, Report ID 0 or above
333255, a Pop without a Push, and a report over 64 KiB.
334
285## Reading history 335## Reading history
286 336
287Each pad keeps the readings the poll took for it, one per change it saw, so `GetNextReading` and `GetPreviousReading` 337Each pad keeps the readings the poll took for it, one per change it saw, so `GetNextReading` and `GetPreviousReading`
@@ -359,8 +409,16 @@ rests on a transcription rather than on a side-by-side compile.
359 binding, two keys at once, each WASD direction, opposite keys cancelling, diagonals, the mouse moving the right 409 binding, two keys at once, each WASD direction, opposite keys cancelling, diagonals, the mouse moving the right
360 stick, clamping and decaying to 0, the mouse-button triggers, no input out of focus, release of buttons, sticks and 410 stick, clamping and decaying to 0, the mouse-button triggers, no input out of focus, release of buttons, sticks and
361 triggers on focus loss, the `always` mode, and turning it off and on again. 411 triggers on focus loss, the `always` mode, and turning it off and on again.
362- `gameinput_probe [--seconds N] [--rumble]` (by hand, with a pad connected): lists the pads, plays each motor and 412 Raw HID (RT-175) is tested in two ways:
363 trigger for a second with `--rumble`, then prints the live reading. 413 - `parse_report_descriptor` runs on synthetic descriptors: report ids, none, Push/Pop, a long item, and the refused
414 forms.
415 - A fake backend (`set_hid_backend`) stands behind a virtual pad with pid.codes test ids. The test checks the report
416 tables, the kind and status bits, a reading's raw report (newest declared id, without the id byte, an undeclared id
417 ignored), creating, sending and reading back output and feature reports with their id byte, `SetRawData`'s exact
418 size, the item calls, `E_INVALIDARG` / `E_FAIL` / `E_NOTIMPL`, and the HID device closing on unplug.
419- `gameinput_probe [--seconds N] [--rumble]` (by hand, with a pad connected): lists the pads with each one's raw HID
420 report tables (or why it has none), plays each motor and trigger for a second with `--rumble`, then prints the live
421 reading and the newest raw input report.
364 422
365## VERIFY 423## VERIFY
366 424
@@ -416,3 +474,12 @@ These need the game executable or a test on hardware:
416- **Haptic waveforms**: the single intensity waveform (usage 0x0F/0x58) is this shim's choice, not the pad's table, so 474- **Haptic waveforms**: the single intensity waveform (usage 0x0F/0x58) is this shim's choice, not the pad's table, so
417 a title that asks for a particular waveform gets intensity-only behaviour. Whether the game uses haptic motors at 475 a title that asks for a particular waveform gets intensity-only behaviour. Whether the game uses haptic motors at
418 all — as opposed to `SetRumbleState` — is unknown. 476 all — as opposed to `SetRumbleState` — is unknown.
477- **Raw HID on a real pad**: only the synthetic tests and the XInput refusal have run.
478 - What ran: an Xbox Series X controller over Bluetooth on Windows 11 connects and plays normally, with no raw I/O,
479 and the log names the reason.
480 - Still to confirm: a DualSense, DualShock 4 or Switch Pro through `gameinput_probe`, which should print the
481 descriptor's reports and changing raw input bytes.
482 - Size convention: report sizes exclude the id byte, and `GetRawData` returns the payload without it. What
483 Microsoft's runtime does for a device with report ids is not documented on the reference pages.
484 - Readings: a pad that streams reports makes a reading for each changed one, like the runtime's
485 `GameInputKindRawDeviceReport` stream, but whether the title asks for raw reports at all is unknown.