with this we can set it up at 2 and no memory leaks atm.

This commit is contained in:
Dmugetsu 2025-05-08 15:40:43 -06:00 committed by Dmugetsu
parent dab3eaba7f
commit 33a0681ac8

View File

@ -44,16 +44,16 @@ void PS4_SYSV_ABI sceUsbdExit() {
s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list) { s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list) {
LOG_DEBUG(Lib_Usbd, "called"); LOG_DEBUG(Lib_Usbd, "called");
static ssize_t device_count = 2;
ssize_t count = libusb_get_device_list(g_libusb_context, list); ssize_t count = libusb_get_device_list(g_libusb_context, list);
if (count < 0) if (count <= 0)
return libusb_to_orbis_error((int)count); return libusb_to_orbis_error((int)count);
if (count > 2) if (count != device_count) {
LOG_WARNING(Lib_Usbd, "Too many USB devices connected to list: {}", count); LOG_INFO(Lib_Usbd, "Found {} USB devices", count);
libusb_unref_device((*list)[2]); device_count = count;
count = -1; }
return ORBIS_FAIL;
return libusb_to_orbis_error((int)count);
} }
void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices) { void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices) {