diff --git a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp index d365e77c62..9b1258442e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp @@ -136,7 +136,7 @@ usb_handler_thread::usb_handler_thread() return; // look if any device which we could be interested in is actually connected - libusb_device** list; + libusb_device** list = nullptr; ssize_t ndev = libusb_get_device_list(ctx, &list); bool found_skylander = false; @@ -191,8 +191,7 @@ usb_handler_thread::usb_handler_thread() check_device(0x046D, 0xC220, 0xC220, "buzzer9"); } - if (ndev > 0) - libusb_free_device_list(list, 1); + libusb_free_device_list(list, 1); if (!found_skylander) { @@ -363,9 +362,12 @@ void usb_handler_thread::check_devices_vs_ldds() { for (const auto& dev : usb_devices) { + if (dev->assigned_number) + continue; + for (const auto& ldd : ldds) { - if (dev->device._device.idVendor == ldd.id_vendor && dev->device._device.idProduct >= ldd.id_product_min && dev->device._device.idProduct <= ldd.id_product_max && !dev->assigned_number) + if (dev->device._device.idVendor == ldd.id_vendor && dev->device._device.idProduct >= ldd.id_product_min && dev->device._device.idProduct <= ldd.id_product_max) { if (!dev->open_device()) { @@ -637,7 +639,7 @@ error_code sys_usbd_receive_event(ppu_thread& ppu, u32 handle, vm::ptr arg1 // hack for Guitar Hero Live // Attaching the device too fast seems to result in a nullptr along the way if (*arg1 == SYS_USBD_ATTACH) - lv2_obj::wait_timeout(5000); + lv2_obj::sleep(ppu), lv2_obj::wait_timeout(5000); return CELL_OK; } @@ -659,6 +661,10 @@ error_code sys_usbd_receive_event(ppu_thread& ppu, u32 handle, vm::ptr arg1 *arg1 = ppu.gpr[4]; *arg2 = ppu.gpr[5]; *arg3 = ppu.gpr[6]; + + if (*arg1 == SYS_USBD_ATTACH) + lv2_obj::sleep(ppu), lv2_obj::wait_timeout(5000); + return CELL_OK; }