Repository navigation
GameInput: size PlayStation HID read buffer from HIDP_CAPS - #2546
ramon-victor wants to merge 1 commit into
Conversation
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Tested: current PR head merged onto current
Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
|
Two contributors checked independently and found that #2525 solves the same problem (for #2465) in a different way: #1607, group D120. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
Fixes #2465.
Problem
crates/xcl/src/hle/playstation.rsmatches DualShock 4 controllers over Bluetooth (vid&0002054c, service00001124-0000-1000-8000-00805f9b34fb), opens their HID handle, and reads reports into a hardcoded 128-byte buffer (let mut buf = [0u8; 128];).On Windows,
hidclass.sysrejects everyReadFilecall whose buffer is smaller thanHIDP_CAPS.InputReportByteLengthwithERROR_INVALID_USER_BUFFER(1784). A DualShock 4 over Bluetooth advertisesInputReportByteLength = 547(input report0x19), soReadFilefails immediately on the first call, causingreader()to close the handle, sleep 1 s, and reconnect in a loop without reading input.Fix
HIDP_CAPS.InputReportByteLengthon the opened HID handle viaHidD_GetPreparsedData,HidP_GetCaps, andHidD_FreePreparsedData(hid.dll,raw-dylib), always freeing preparsed data before returning.ReadFilebuffer dynamically toread_buffer_len(input_report_byte_length(h)), clamping nonzero cap lengths to at least 64 bytes and falling back to 1024 bytes (>= 547) ifHIDP_CAPScannot be queried or reports zero.buf[0]) against zero-length reads so it does not log a stale report ID.known()andparse()untouched so this change stays independent of Bluetooth DualSense report-parsing work (GameInput: read a DualSense and a DualShock 4's full reports over Bluetooth #2081).playstation::read_buffer_testscoveringHidpCapsABI size/offset against Windows SDKhidpi.h, buffer sizing across USB/Bluetooth/fallback lengths, and invalid-handle handling throughhid.dll.Tested
cargo test --lib -p xcl playstation): 4 passed, 0 failed (hidp_caps_layout_and_read_buffer_sizing,input_report_byte_length_handles_invalid_handle, plus the 2 existing PlayStation tests)..\scripts\test.ps1, NVIDIA GeForce RTX 3070, Windows 11):1425 passed, 0 failed, 46 ignored.cargo build --release -p xcl) and 60 s retail smoke run (see below).Not tested
HIDP_CAPSlayout andHidD_GetPreparsedData/HidP_GetCaps/HidD_FreePreparsedDatasignatures were verified against Windows SDKhidpi.h/hidsdi.h, andhid.dllraw-dylibinvocation was verified onINVALID_HANDLE_VALUE).Regression run
Main (
f087b99):This PR (
20b18f7):AI use