Repository navigation
gameinput: raw HID reports and raw device I/O through SDL's hidapi (RT-175) - #3172
Conversation
…T-175) The shim opens each pad's HID device with SDL_hid_* (by SDL's device path, else the one game-pad collection with the pad's vendor and product id) and reads its report descriptor for every input, output and feature report's id and size. Such a pad reports GameInputKindRawDeviceReport and GameInputDeviceRawIoEnabled and fills inputReportInfo, outputReportInfo and featureReportInfo (no item tables). Readings carry the newest raw input report, and IGameInputReading::GetRawReport returns it as an IGameInputRawDeviceReport. CreateRawDeviceReport, GetRawDeviceFeature, SetRawDeviceFeature and SendRawDeviceOutput work through the backend; an undeclared id or kind is E_INVALIDARG, a failed transfer E_FAIL, and a pad without a HID device keeps E_NOTIMPL. gameinput_abi.h declares IGameInputRawDeviceReport, GameInputRawDeviceReportKind and the three raw report info structs, checked against Microsoft's v0 header (offsetof for every field, the 12 vtable slots, the IID). Xbox pads on Windows go through XInput, whose HID interface SDL's hidapi skips, so they have no raw I/O; the log says so. gameinput_test covers the descriptor parser and the whole path with a fake HID backend (24 checks); gameinput_probe prints each pad's report tables and newest raw input report. docs/gameinput.md: "Raw HID".
Keep RT-160's force-feedback interface and tests next to the raw HID ones. The raw HID test fakes are renamed (FakeRawHid, raw_*) so they no longer clash with the haptic fakes. The API table gets one IGameInputDevice row with both feature sets; the stale duplicate IGameInputDevice and IGameInputDispatcher rows are dropped.
|
Tested 364fdcb on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
|
Tested 76d1add (the head after the merge of
No compiler warnings from the |
- shader_disasm: prune stale listings against every input, not the --skip-existing remainder (a resumed run deleted every listing it had just reused). - progress_dashboard: a drive-letter path is never inside the repository off Windows (it printed user names); its own read_text helper is read_utf8, so the encoding check does not take it for pathlib's. - Translator tests follow this round's rules: desc_lookup's BroadcastFirst in the typed-load condition walker; resinfo sizes are 0 past the last level and a 2D depth word is 0 (SHADER-388); SHADER-315 constant folding in the perm and i16 tests; ItsNotRexed#2089's structured wave64 emulation. - test_semantic_translator_use: 57 oracle-only files merged before it are DEBT; test_spirv_tools_required is allowed (CI meta-test). - Test fixes: image_fuzz fake writes the programs, preflight follows c506d00's loader hint rule, feature_scan reads the first line of a pytest-decorated message, w64_graphics wording. - docs: rows merged again in design.md, README.md, d3d12_vulkan.md; GameInput table rebuilt from ItsNotRexed#3172's rows; orphan rows in models.md and embedded_shaders.md; repeated bullets; anchors; a flag not on main. - Repo rules: stdout guard on 14 programs; LF writes; csv lineterminator in bink_play. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 76d1add on Intel Tiger Lake Xe-LP (0x9a78, iGPU, subgroup 8..32, no mesh), driver 32.0.101.7088, Windows 11, MSVC 14.44: pass Built with -DLEONIDA_SDL3_FETCH=ON so the GameInput SDL3 shim (and its raw-HID path) actually runs: AI-assisted (GLM, operated by the account owner). |
Claimed in the coordination issue as: RT-175 (#2516 (comment))
Depends on: #2939, #2751 (conflicts only). Both edit
runtime/shims/gameinput.cppand/ordocs/gameinput.mdnear the same places. Whichever merges second needs a small merge.What and why
GameInput's raw HID calls returned nothing or
E_NOTIMPL, so a title that talks to a pad through raw reports got nothing. This PR backs them with SDL3's hidapi (SDL_hid_*).rt::gameinput::parse_report_descriptor, gives every input, output and feature report's id and payload size. It handles Report ID/Size/Count, Push/Pop and long items, and refuses malformed descriptors.GameInputKindRawDeviceReportinsupportedInputandGameInputDeviceRawIoEnabledin its status;inputReportInfo,outputReportInfoandfeatureReportInfowith their counts, withitemCount0 (items are not decoded).IGameInputReading::GetRawReportreturns it as anIGameInputRawDeviceReport.CreateRawDeviceReport,GetRawDeviceFeature,SetRawDeviceFeatureandSendRawDeviceOutputwork through the backend, with the id byte in front as hidapi expects.E_INVALIDARG, and a failed transfer isE_FAIL.E_NOTIMPL, and no raw kind.Get/Set/ResetItemValue,ResetAllItemsanswer false),SendRawDeviceOutputWithResponse,ExecuteRawDeviceIoControland exclusive access.gameinput_abi.h, Leonida's own declarations):IGameInputRawDeviceReport(IID61F08CF1-…),GameInputRawDeviceReportKind,GameInputRawDeviceReportInfo,GameInputRawDeviceReportItemInfoandGameInputRawDeviceItemCollectionInfo, withstatic_asserts. Following docs/gameinput.md's ABI section, they were compiled next to Microsoft's public v0 header (NuGetMicrosoft.GameInput0.2303.22621.3038, not added to the repository). The check comparesoffsetoffor all 38 fields, sizes and enum values, calls all 12 vtable slots through Microsoft's interface, and checks the IID. Everything matches.XInput#n). SDL's hidapi skips their XInput HID interface (&IG_; SDL's comment says those carry no full HID reports), so they get no raw I/O. The log now says why.rt::gameinput::set_hid_backend, for tests.Tested
scripts/build_runtime.ps1 -FetchSdl3(SDL 3.4.20).ctest -R gameinputpasses:gameinput_testruns 300 checks with 0 failures, 24 of them new. After mergingmainwith RT-160's force feedback and haptics, both test sets run (the raw HID fakes are renamed so they don't clash).SetRawData's exact size, the item calls,E_INVALIDARG,E_FAILandE_NOTIMPL, and the device closing on unplug.gameinput_probe --seconds 15and press buttons. It should print the descriptor's reports and changing raw bytes.tests/test_report_paths.py, which fails the same way onmainon Windows (unrelated). The pytest files: 1,463 passed, 15 skipped.AI-assisted.
Checklist
docs/design.md, with how it was confirmed. (Not applicable: no translator change.)