feat(usbd): add native synchronous USB backend #2224
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2224"
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 obojeoboje on 2026-10-09T12:10:21Z.
What
Replace 22 throwing
libSceUsbdexports with a synchronous host USB backend using libusb 1.0.30. Previously the library always returned an empty device list and threw on all device operations. It now enumerates real host devices, reads device/configuration/string descriptors, manages device references and handles, claims/releases interfaces, performs control transfers, and exposes native configuration/reset/driver operations.Add libusb as a pinned submodule (
libusb/libusb-cmake, tagv1.0.30-0, commitc8477c10ac2ac6b1718d4d498e102b9f18b776f5) and build it statically from source. Linux uses the bundled netlink enumeration backend rather than a system libudev dependency. Hide native libusb exports from the guest library.Use the signatures, native descriptor layouts and USB error conversion documented by shadPS4 usbd.h and usbd.cpp, with locally written wrappers. Own a separate reference-counted libusb context and convert the guest's 64-bit timeval fields to the host representation.
Transfer allocation/free and interrupt-transfer preparation work, preserving the guest callback pointer. Asynchronous submit/cancel and
sceUsbdCheckConnectedremain throwing stubs. Host permissions and USB drivers apply; console lifecycle and invalid-argument error precedence remain unverified. Record these limits in TechnicalDebt and remove the obsolete no-device silent-stub entry.The progress scanner changes from 2578/3044 (84.69%) to 2600/3044 (85.41%), +22 implementations and +0.72 percentage points.
Tested
Windows, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON:
Native USB tests enumerated 9 host devices, read cached device descriptors and available configuration descriptors, checked device/list reference lifetimes, repeated initialization/exit, transfer allocation/preparation, SysV guest callback invocation, invalid arguments, and remaining throwing paths.
Deterministic control-transfer tests replace only the native libusb control-transfer call at link time. They verify setup fields, byte counts and buffer output, error conversion (including OTHER), zero/maximum/invalid lengths, string-descriptor requests, and that invalid calls never reach the backend.
Native libusb functions are not exported from the built guest library.
Test registration and conventions checks passed.
cmake --build build --parallel 12completed successfully, as didcmake --build build --target libs --parallel 12.ctest --test-dir build --output-on-failure --parallel 4 --timeout 30: 506 passed, 1 skipped (guest_video_out_wqhd_detection_no_vulkan), 1 timed out (agc_driver_flat_store). The timeout was 30.06 s; no timeout setting was raised.Re-ran
agc_driver_flat_store,guest_usbdandguest_usbd_controlsequentially with the same 30-second limit: all 3 passed (24.19 s, 0.10 s, 0.01 s respectively).No game or homebrew was tested. Physical devices were enumerated and their descriptors read; control-transfer payload tests used the test backend. Linux has not been tested locally.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.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-09T12:40:23Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL246docs/dev/TechnicalDebt.mdL23-24Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:10:23Z.
Closing: no title reaches these Usbd calls on main, and a new libusb dependency needs one that does. If you find a title that talks to a USB device, please reopen with its ID and the log line.
Pull request closed