feat(libSceUsbd): pass configuration and descriptor queries through to libusb #9190
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9190"
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?
Imported from boykopovar/AnyPS5. Originally posted by simnJS on 2026-10-21T14:48:22Z.
What
Implement
sceUsbdGetConfiguration,sceUsbdGetConfigDescriptorByValue,sceUsbdGetDescriptorandsceUsbdGetStringDescriptorAsciiover the host libusb, with the argument checks of FreeBSD 11.4 libusb (libusb10.c,libusb10_desc.c). Null arguments and a length below 1 return0x80240002before the buffer is written; a handle or device this library did not return throws, as in the other calls.sceUsbdGetStringDescriptorAsciirebuilds FreeBSD'slibusb20_dev_req_string_simple_sync(libusb20.c) over host control transfers instead of calling the hostlibusb_get_string_descriptor_ascii, whose result differs (index 0 rejected,?for non-ASCII characters, specific error codes). It reads each string with FreeBSD's single 255-byte request and skips the 4-byte header read that FreeBSD tries first: libusb's Windows HID backend (_hid_get_string_descriptorinwindows_winusb.c) reports the requested length asbLength, so the two-step read cut the string to its first character (MforMYSTIC LIGHT). The differences and the unverified console behaviour are recorded indocs/dev/debt/libSceUsbd.md.Tested
Windows 11 Pro 10.0.26200, MinGW-w64 GCC 15.2.0 (WinLibs
x86_64-ucrt-posix-sehr7), Release build.ctest --test-dir build -R guest_usbd: passed. It covers null arguments, a zero length, and handles or devices this library did not return for the four calls, and checks that a rejected call leaves the buffer or output untouched.guest_usbd_tests devicewithAPS5_USBD_DEVICEset: passed on an MSI Mystic Light HID controller (1462:7D75) and a Wooting 80HE keyboard (31E3:1402). The configuration value matches the active config descriptor, the config descriptor found by that value has the same value, value 0 is not found,sceUsbdGetDescriptorreturns the cached device descriptor, and the ASCII product string equals the printable characters of the product string in the device's first language (MYSTIC LIGHT,Wooting 80HE). A 4-byte buffer gets a terminated prefix.046D:C54D), the device run stops at the existingthe cancel race failedcheck, after the new checks.mainat2c4b116dafails the same way on this receiver, so this change does not cause it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T15:42:17Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/tests/GuestUsbd.cppImported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-21T18:11:45Z.
@simnJS I'd like to take the remaining
sceUsbdplaceholders over libusb with FreeBSD 11.4's checks, the way you did here:ClearHalt,SetInterfaceAltSetting,GetDevice,GetDeviceSpeed,GetMaxPacketSize,GetMaxIsoPacketSize,OpenDeviceWithVidPidandDetachKernelDriverfirst, then the event-handling calls. Are you already working on any of these? If not, I'll base mine on this PR so the two don't collide.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by simnJS on 2026-10-21T18:34:33Z.
@MaxLikesCode I'm not working on any of them, go ahead. Two things I hit while testing this PR on Windows:
_hid_get_string_descriptorinwindows_winusb.c) reports the requested length asbLength, so a FreeBSD-style two-step read (4-byte header, thenbLengthbytes) cuts a string descriptor to its first character. Anything you port that reads a descriptor's length from a short first request will hit the same thing on HID devices.guest_usbd_tests devicerun fails atthe cancel race failedon a Logitech LIGHTSPEED receiver (046D:C54D) onmaintoo, so don't use that device to judge your changes.I can run your branch's device tests on an MSI Mystic Light HID controller (
1462:7D75) and a Wooting 80HE keyboard (31E3:1402) on Windows 11 once it's up.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-21T18:50:19Z.
Thanks @simnJS. None of the new calls reads a descriptor's length from a short first request: the packet sizes come from libusb's parsed active configuration and
sceUsbdOpenDeviceWithVidPidmatches the cached device descriptor, so the HID length quirk doesn't apply. I ran the device tests on a CORSAIR Lighting Node CORE (1b1c:0c1a) and kept away from the LIGHTSPEED receiver.They're up as #9338 (the eight device calls, on this PR) and #9339 (the event calls, on #9338). A run of
guest_usbd_tests devicefrom #9339's branch on your MSI and Wooting devices would be very welcome, since it covers both.AI-assisted: yes (Claude Code)