GameInput: size PlayStation HID read buffer from HIDP_CAPS #2546
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2546
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2546"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ramon-victor on GitHub · 2026-11-25 22:34 UTC · original
ramon-victor:fix/playstation-hid-read-buffer→main· +88 −2 · 1 files · 1 commits · openFixes #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 (#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
@DavidM1911 on GitHub · 2026-11-25 22:46 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@futurepro62 on GitHub · 2026-11-25 22:53 UTC · original · edited 2026-11-25 22:57 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
20b18f7(on its basee1d84b7).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1413 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.hidp_caps_layout_and_read_buffer_sizing,input_report_byte_length_handles_invalid_handle.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1424 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on maine1d84b7too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@SlopTart on GitHub · 2026-11-25 23:33 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.Targeted run of
hidp_caps_layout_and_read_buffer_sizingandinput_report_byte_length_handles_invalid_handle: 2 passed. No physical pad on this lane; these verify the HID parsing/sizing path, not device I/O.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.
@throny on GitHub · 2026-11-26 01:10 UTC · original
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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.