Repository navigation
feat(libSceUsbd): pass the device, packet size, alternate setting and halt calls through to libusb - #9338
Merged
oneandonlydean merged 1 commit intoOct 25, 2026
Conversation
12 tasks done
Progress report (cf528e7 → 64ae578)📈 System libraries: 48.86% (+0.06%, +8 implemented functions) ✅ 8 implemented
Changed libraries (implemented exports)
|
12 tasks done
Contributor
|
Linux data point for
AI-assisted (Claude Code). |
This was referenced Oct 22, 2026
… halt calls through to libusb sceUsbdGetDevice, sceUsbdGetDeviceSpeed, sceUsbdGetMaxPacketSize, sceUsbdGetMaxIsoPacketSize, sceUsbdOpenDeviceWithVidPid, sceUsbdSetInterfaceAltSetting, sceUsbdClearHalt and sceUsbdDetachKernelDriver follow FreeBSD 11.4 libusb10.c over the host libusb. The packet sizes and the alternate setting checks are done as FreeBSD does them, so the library records which interfaces are claimed, and a device stays known while a handle to it is open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxLikesCode
force-pushed
the
feat/usbd-device-calls
branch
from
October 25, 2026 00:19
b77a110 to
64ae578
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements eight more
sceUsbdcalls over the host libusb, with the argument checks and results of FreeBSD 11.4libusb10.c, as #9190 does for the configuration and descriptor queries. Their signatures were already in the file, from the console type database in orbital; shadPS4 maps each of these calls one-to-one onto libusb.sceUsbdGetDevicesceUsbdGetDeviceSpeedsceUsbdGetMaxPacketSizewMaxPacketSizeof the first endpoint with that address in any interface and alternate setting of the active configuration,0x80240005if there is none,0x80240004for a null devicesceUsbdGetMaxIsoPacketSize(size & 0x7FF) * min(1 + ((size >> 11) & 3), 3)sceUsbdOpenDeviceWithVidPidsceUsbdSetInterfaceAltSetting0x80240002for an interface outside 0 to 31,0x80240005for an interface the handle has not claimed,0x802400FFfor any other failure; the alternate setting is taken as 8 bitssceUsbdClearHalt0x802400FFfor an endpoint the host does not findsceUsbdDetachKernelDriver0x802400FFfor any failure; on Windows libusb cannot detach drivers, so it always returns0x802400FFthereThe two packet sizes are computed as FreeBSD computes them, not through the host's
libusb_get_max_packet_sizeandlibusb_get_max_iso_packet_size, which returnLIBUSB_ERROR_OTHERfor an unreadable configuration and scale SuperSpeed endpoints by their companion descriptor.To make the alternate setting check FreeBSD's, the library now records which interfaces each handle has claimed (
sceUsbdClaimInterface,sceUsbdReleaseInterface,sceUsbdClose,sceUsbdExit). A device also stays known while a handle to it is open, so the device returned bysceUsbdGetDevicefor a handle fromsceUsbdOpenDeviceWithVidPidcan be used (and referenced) until that handle is closed.These throw:
sceUsbdSetInterfaceAltSettingwhile the device has transfers in flight, which FreeBSD cancels first;sceUsbdClearHaltfor host errors other than a missing endpoint, because FreeBSD ignores the result of the clear itself, so they have no known result; and for a null handle, which FreeBSD dereferences;sceUsbdGetMaxIsoPacketSizefor a null device, which FreeBSD dereferences;docs/dev/debt/libSceUsbd.mdmoves the eight calls from the unknown list to two entries that say what follows FreeBSD and what the host cannot do. The event calls (sceUsbdHandleEvents, the event locks,sceUsbdWaitForEvent,sceUsbdEventHandlerActive) are left for a separate change.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, full Release build with
BUILD_TESTING=ON, onmainb4d1058 with #9190; this branch, which sits on #9190's commit, was rechecked merged ontomainb00235d (guest_usbd3 of 3, device run 2 of 2, conventions).guest_usbdgains checks for null and unknown handles and devices for all eight calls, and forsceUsbdOpenDeviceWithVidPidwith no matching device, before and aftersceUsbdExit. It passes 3 of 3. WithExport.cppfrom feat(libSceUsbd): pass configuration and descriptor queries through to libusb #9190 and the new tests, it fails at the first placeholder (sceUsbdDetachKernelDriver not implemented).guest_usbd_tests devicewithAPS5_USBD_DEVICE=1b1c:0c1a(CORSAIR Lighting Node CORE, full speed, HID) passes 12 of 12 runs and checks:sceUsbdGetDeviceof an open handle is the device it was opened from, and the speed is 1 to 4 (2 here);0x80240005for an absent endpoint;0x80240005before the claim and after the release,0x80240002for interfaces 32 and -1, and 0 for setting 0 of the claimed interface;sceUsbdClearHaltreturns 0 on the interrupt endpoint and0x802400FFfor an absent one;sceUsbdDetachKernelDriverreturns0x802400FF(Windows);sceUsbdOpenDeviceWithVidPidopens it again, its device has the same vendor and product and the same packet size, and that device is unknown again once the handle is closed.0b05:19af), the device run stops at feat(libSceUsbd): pass configuration and descriptor queries through to libusb #9190's existingclaiming an interface failed, before the new checks: Windows does not give libusb its non-HID interfaces.python tools/select_tests.py ctest build --output-on-failure --timeout 180 --parallel 8: 1523 of the 1526 selected tests pass. The 3 failures areagc_driver_sample_order,agc_driver_sample_order_grid_referenceandagc_driver_sample_order_recipe_depth_locations, which fail the same way onmainon this RTX 4090 and which test(agc): read the sample order tests' depth through a sampled copy #9056 fixes.agc_driver_image_array_window_past_layer_limitis not built: it does not compile with MinGW onmain(test(agc): align the array window test's texels at run time #8310).python tools/check_conventions.py --base origin/mainpasses.python tools/pr_overlap.py --branch feat/usbd-device-callsreports only feat(libSceUsbd): pass configuration and descriptor queries through to libusb #9190, which this builds on. test(libSceUsbd): cover sceUsbdFillControlSetup buffer formatting #9116 adds test lines toGuestUsbd.cpptoo; the two merge cleanly.guest_usbd_tests devicefrom feat(libSceUsbd): handle events with FreeBSD libusb's event lock and handler thread #9339's branch, which contains feat(libSceUsbd): pass the device, packet size, alternate setting and halt calls through to libusb #9338, on Windows 11 Pro 26200 (comment): an MSI Mystic Light HID controller (1462:7D75, full speed) and a Wooting 80HE keyboard (31E3:1402, high speed) pass 3 of 3 each, andsceUsbdDetachKernelDriverreturns0x802400FFon both. On the Wooting the iso packet size check takes the multiplier path above full speed.guest_usbd_testson Linux (WSL2, Ubuntu 24.04, GCC 13.3, Release) from this head merged ontomaindf2569d (comment): it exits with 0, and withExport.cppreset tomainit aborts (SIGABRT).main38d463a after refactor(libs): add full export headers for libs #10706 moved the declarations intolibSceUsbd/include/Api.hpp, which already declares the eight calls with these signatures. At 64ae578,guest_usbdpasses 3 of 3 and fails 3 of 3 withExport.cppfrommain, and the device run withAPS5_USBD_DEVICE=1b1c:0c1apasses 2 of 2.public_headersand the conventions check pass.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)🤖 Generated with Claude Code