feat(libSceUsbd): report a USB stack with no devices attached #1350

Merged
gjonn merged 2 commits from upstream-pr/1350 into main 2026-10-08 11:54:01 +00:00
gjonn commented 2026-10-08 00:03:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-08T00:03:08Z.


What

libSceUsbd exported only a dummy function. A title and its bundled logiWheel.prx import 30 of its functions (a libusb-style API) to look for steering wheels. This implements the host as a USB stack with no devices attached:

  • sceUsbdInit() succeeds and sceUsbdExit() does nothing.
  • sceUsbdGetDeviceList(list) stores an empty null-terminated array and returns 0 devices; sceUsbdFreeDeviceList accepts that array and throws for any other pointer.
  • sceUsbdHandleEventsTimeout(timeout) validates the timeval (seconds and microseconds as 64-bit fields, microseconds below 1000000), waits for the timeout because no event can arrive, and returns 0. The title's USB event threads call it in a loop with 500 ms, so returning at once would spin.
  • The other 25 imports need a device or transfer, which can never exist, and throw NotImplemented.

Error values use SCE_USBD_ERROR_INVALID_ARG (0x80240002). The module gets a CMakeLists so the test can be registered.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0: new guest_usbd test (empty list, invalid arguments, the timeout wait, a device call throws) passes.
  • A title that imports these functions: its USB and Thrustmaster force-feedback threads start and wait in sceUsbdHandleEventsTimeout; start-up continues.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779953538 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1350). Originally posted by [gjonn](https://github.com/gjonn) on 2026-10-08T00:03:08Z. --- ### What `libSceUsbd` exported only a dummy function. A title and its bundled `logiWheel.prx` import 30 of its functions (a libusb-style API) to look for steering wheels. This implements the host as a USB stack with no devices attached: - `sceUsbdInit()` succeeds and `sceUsbdExit()` does nothing. - `sceUsbdGetDeviceList(list)` stores an empty null-terminated array and returns 0 devices; `sceUsbdFreeDeviceList` accepts that array and throws for any other pointer. - `sceUsbdHandleEventsTimeout(timeout)` validates the `timeval` (seconds and microseconds as 64-bit fields, microseconds below 1000000), waits for the timeout because no event can arrive, and returns 0. The title's USB event threads call it in a loop with 500 ms, so returning at once would spin. - The other 25 imports need a device or transfer, which can never exist, and throw `NotImplemented`. Error values use `SCE_USBD_ERROR_INVALID_ARG` (0x80240002). The module gets a CMakeLists so the test can be registered. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0: new `guest_usbd` test (empty list, invalid arguments, the timeout wait, a device call throws) passes. - A title that imports these functions: its USB and Thrustmaster force-feedback threads start and wait in `sceUsbdHandleEventsTimeout`; start-up continues. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-08 00:03:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T00:03:30Z.


Progress report (fae39c6 → 53b3da5)

📉 System libraries: 84.73% (-0.68%, +5 implemented, +25 declared functions)

✅ 5 implemented
Library Name
libSceUsbd sceUsbdExit
libSceUsbd sceUsbdFreeDeviceList
libSceUsbd sceUsbdGetDeviceList
libSceUsbd sceUsbdHandleEventsTimeout
libSceUsbd sceUsbdInit
🆕 25 declared as stubs
Library Name
libSceUsbd sceUsbdAllocTransfer
libSceUsbd sceUsbdAttachKernelDriver
libSceUsbd sceUsbdCancelTransfer
libSceUsbd sceUsbdCheckConnected
libSceUsbd sceUsbdClaimInterface
libSceUsbd sceUsbdClose
libSceUsbd sceUsbdControlTransfer
libSceUsbd sceUsbdEventHandlingOk
libSceUsbd sceUsbdFillInterruptTransfer
libSceUsbd sceUsbdFreeConfigDescriptor
libSceUsbd sceUsbdFreeTransfer
libSceUsbd sceUsbdGetActiveConfigDescriptor
libSceUsbd sceUsbdGetBusNumber
libSceUsbd sceUsbdGetConfigDescriptor
libSceUsbd sceUsbdGetDeviceAddress
libSceUsbd sceUsbdGetDeviceDescriptor
libSceUsbd sceUsbdGetStringDescriptor
libSceUsbd sceUsbdKernelDriverActive
libSceUsbd sceUsbdOpen
libSceUsbd sceUsbdRefDevice
libSceUsbd sceUsbdReleaseInterface
libSceUsbd sceUsbdResetDevice
libSceUsbd sceUsbdSetConfiguration
libSceUsbd sceUsbdSubmitTransfer
libSceUsbd sceUsbdUnrefDevice
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6049326258 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1350#issuecomment-6049326258). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-08T00:03:30Z. --- <!-- progress-report --> ### Progress report (fae39c6 → 53b3da5) 📉 **System libraries**: 84.73% (-0.68%, +5 implemented, +25 declared functions) <details> <summary>✅ 5 implemented</summary> | Library | Name | | - | - | | libSceUsbd | `sceUsbdExit` | | libSceUsbd | `sceUsbdFreeDeviceList` | | libSceUsbd | `sceUsbdGetDeviceList` | | libSceUsbd | `sceUsbdHandleEventsTimeout` | | libSceUsbd | `sceUsbdInit` | </details> <details> <summary>🆕 25 declared as stubs</summary> | Library | Name | | - | - | | libSceUsbd | `sceUsbdAllocTransfer` | | libSceUsbd | `sceUsbdAttachKernelDriver` | | libSceUsbd | `sceUsbdCancelTransfer` | | libSceUsbd | `sceUsbdCheckConnected` | | libSceUsbd | `sceUsbdClaimInterface` | | libSceUsbd | `sceUsbdClose` | | libSceUsbd | `sceUsbdControlTransfer` | | libSceUsbd | `sceUsbdEventHandlingOk` | | libSceUsbd | `sceUsbdFillInterruptTransfer` | | libSceUsbd | `sceUsbdFreeConfigDescriptor` | | libSceUsbd | `sceUsbdFreeTransfer` | | libSceUsbd | `sceUsbdGetActiveConfigDescriptor` | | libSceUsbd | `sceUsbdGetBusNumber` | | libSceUsbd | `sceUsbdGetConfigDescriptor` | | libSceUsbd | `sceUsbdGetDeviceAddress` | | libSceUsbd | `sceUsbdGetDeviceDescriptor` | | libSceUsbd | `sceUsbdGetStringDescriptor` | | libSceUsbd | `sceUsbdKernelDriverActive` | | libSceUsbd | `sceUsbdOpen` | | libSceUsbd | `sceUsbdRefDevice` | | libSceUsbd | `sceUsbdReleaseInterface` | | libSceUsbd | `sceUsbdResetDevice` | | libSceUsbd | `sceUsbdSetConfiguration` | | libSceUsbd | `sceUsbdSubmitTransfer` | | libSceUsbd | `sceUsbdUnrefDevice` | </details>
adriadam10 commented 2026-10-08 11:37:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T11:37:22Z.


Checked build + full ctest (449/449) after rebasing on current main; guest_usbd passes and doesn't even link without the change. Signatures, timeval handling and the sleeping HandleEventsTimeout match KytyPS5 and shadPS4 (SCE_USBD_ERROR_INVALID_ARG = libusb invalid param as mapped there).

Only conflict was the TechnicalDebt line next to the Hmd2/Mbus ones; I rebased and moved it a few lines away. Merging once CI is green on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6059015668 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1350#issuecomment-6059015668). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T11:37:22Z. --- Checked build + full ctest (449/449) after rebasing on current main; `guest_usbd` passes and doesn't even link without the change. Signatures, `timeval` handling and the sleeping `HandleEventsTimeout` match KytyPS5 and shadPS4 (`SCE_USBD_ERROR_INVALID_ARG` = libusb invalid param as mapped there). Only conflict was the TechnicalDebt line next to the Hmd2/Mbus ones; I rebased and moved it a few lines away. Merging once CI is green on the rebased head.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1350
No description provided.