From 33a0681ac88c577acc075dcf60c74a5fefd63ca5 Mon Sep 17 00:00:00 2001 From: Dmugetsu Date: Thu, 8 May 2025 15:40:43 -0600 Subject: [PATCH] with this we can set it up at 2 and no memory leaks atm. --- src/core/libraries/usbd/usbd.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/libraries/usbd/usbd.cpp b/src/core/libraries/usbd/usbd.cpp index b6f62cc3b..5821d59dd 100644 --- a/src/core/libraries/usbd/usbd.cpp +++ b/src/core/libraries/usbd/usbd.cpp @@ -44,16 +44,16 @@ void PS4_SYSV_ABI sceUsbdExit() { s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list) { LOG_DEBUG(Lib_Usbd, "called"); + static ssize_t device_count = 2; ssize_t count = libusb_get_device_list(g_libusb_context, list); - if (count < 0) + if (count <= 0) return libusb_to_orbis_error((int)count); - if (count > 2) - LOG_WARNING(Lib_Usbd, "Too many USB devices connected to list: {}", count); - libusb_unref_device((*list)[2]); - count = -1; - - return libusb_to_orbis_error((int)count); + if (count != device_count) { + LOG_INFO(Lib_Usbd, "Found {} USB devices", count); + device_count = count; + } + return ORBIS_FAIL; } void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices) {