From aa7319e043b39456c8f6418a7816939a3469d7db Mon Sep 17 00:00:00 2001 From: Matthew Parlane Date: Tue, 27 Aug 2013 00:46:04 +1200 Subject: [PATCH] Slightly better error handling for libusb_init not working. --- .../Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp index e7a2310fc6..99c0d4e3b7 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp @@ -97,16 +97,25 @@ CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::strin { deviceCommandAddress = 0; memset(hidDeviceAliases, 0, sizeof(hidDeviceAliases)); - libusb_init(NULL); - - usb_thread_running = true; - usb_thread = std::thread(checkUsbUpdates, this); + int ret = libusb_init(NULL); + if (ret) + { + ERROR_LOG(WII_IPC_HID, "libusb_init failed with error: %d", ret); + } + else + { + usb_thread_running = true; + usb_thread = std::thread(checkUsbUpdates, this); + } } CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() { - usb_thread_running = false; - usb_thread.join(); + if (usb_thread_running) + { + usb_thread_running = false; + usb_thread.join(); + } for ( std::map::const_iterator iter = open_devices.begin(); iter != open_devices.end(); ++iter ) {