mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-27 00:28:14 +00:00
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 <[email protected]>
5.6 KiB
5.6 KiB
libSceUsbd technical debt
Silent stubs
- libSceUsbd passes the calls through to the host with libusb built from the
3rdparty/libusb-cmakesubmodule. Devices, handles and descriptors are libusb's own objects: the device, config, interface and endpoint descriptor layouts of FreeBSD 11.4 libusb match libusb's field for field, whichstatic_assertpins. Each one handed to the title is tracked, and a pointer this library did not return throws. Errors are libusb's codes mapped to0x80240000 - code, withLIBUSB_ERROR_OTHERat0x802400FF, following shadPS4; the null arguments FreeBSD libusb rejects (libusb10.c, libusb10_desc.c, libusb10_io.c) return0x80240002, andsceUsbdOpenandsceUsbdGetActiveConfigDescriptorthrow on a null device, which it dereferences. A submitted transfer is copied into a host transfer whose completion copies the status, actual length and iso packet results back and then calls the title's callback fromsceUsbdHandleEventsTimeout; transfer flags other than short-not-ok and add-zero-packet throw.sceUsbdAttachKernelDriverreturns 0 as FreeBSD's stub does,sceUsbdCheckConnectedreports a device gone when reading its configuration fails withLIBUSB_ERROR_NO_DEVICE(FreeBSD asks the kernel directly), andsceUsbdEventHandlingOkreturns 1. When the host has no USB access, initialization keeps the empty device list and event handling waits for its timeout. Opening, descriptors, string and control requests, interface claims and an asynchronous control transfer were checked against an Xbox 360 controller on Windows; the transfer layout, the argument lists, the error codes and isochronous transfers are unverified on PS5
Unknown function info
- sceUsbdEventHandlerActive, sceUsbdHandleEvents, sceUsbdHandleEventsLocked, sceUsbdLockEventWaiters, sceUsbdLockEvents, sceUsbdTryLockEvents, sceUsbdUnlockEventWaiters, sceUsbdUnlockEvents, sceUsbdWaitForEvent (libSceUsbd) - signatures follow the console type database in orbital, but their behavior is unknown and each call throws; not measured on a console
Functional
- sceUsbdGetConfiguration, sceUsbdGetConfigDescriptorByValue, sceUsbdGetDescriptor, sceUsbdGetStringDescriptorAscii (libSceUsbd) - not measured on a console; they follow FreeBSD 11.4 (libusb10_desc.c, libusb20.c). The configuration and descriptor queries return host libusb errors.
sceUsbdGetStringDescriptorAsciirebuildslibusb20_dev_req_string_simple_syncwith only its 255-byte read: libusb's Windows HID backend reports the requested length asbLength, cutting a 4-byte header read to one character. Unlike the hostlibusb_get_string_descriptor_asciiit accepts index 0, drops non-printable characters and<>instead of writing?, and fails with0x802400FF. Closes when: measured on a PS5 - sceUsbdGetDevice, sceUsbdGetDeviceSpeed, sceUsbdGetMaxPacketSize, sceUsbdGetMaxIsoPacketSize, sceUsbdOpenDeviceWithVidPid (libSceUsbd) - not measured on a console; they follow FreeBSD 11.4 libusb10.c over the host libusb. The packet sizes are searched in the active configuration and the iso size is scaled as FreeBSD does, not through the host's versions, which differ for an unreadable configuration and for SuperSpeed endpoints. A host SuperSpeed+ device reports SuperSpeed, the fastest speed FreeBSD 11.4 has. A null device in
sceUsbdGetMaxIsoPacketSizethrows, as FreeBSD dereferences it. A device stays known while a handle to it is open, so the device of a handle fromsceUsbdOpenDeviceWithVidPidcan be used until that handle is closed. Closes when: measured on a PS5 - sceUsbdSetInterfaceAltSetting, sceUsbdClearHalt, sceUsbdDetachKernelDriver (libSceUsbd) - not measured on a console; they follow FreeBSD 11.4 libusb10.c over the host libusb.
sceUsbdSetInterfaceAltSettingchecks the interface range and this library's record of claimed interfaces, and returns0x802400FFfor any other failure; it throws while the device has transfers in flight, which FreeBSD cancels first.sceUsbdClearHaltreturns 0, or0x802400FFfor an endpoint the host does not find; FreeBSD ignores the result of the clear itself, so the host's other errors throw, and so does a null handle, which FreeBSD dereferences.sceUsbdDetachKernelDriverreturns0x802400FFfor any failure, which on Windows is every call, as libusb cannot detach drivers there. Closes when: measured on a PS5