diff options
Diffstat (limited to 'src/input_common/gcadapter/gc_adapter.cpp')
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp index 745f1be27..887cde263 100644 --- a/src/input_common/gcadapter/gc_adapter.cpp +++ b/src/input_common/gcadapter/gc_adapter.cpp | |||
| @@ -130,6 +130,7 @@ void Adapter::Read() { | |||
| 130 | 130 | ||
| 131 | if (payload_size != sizeof(controller_payload_copy) || | 131 | if (payload_size != sizeof(controller_payload_copy) || |
| 132 | controller_payload_copy[0] != LIBUSB_DT_HID) { | 132 | controller_payload_copy[0] != LIBUSB_DT_HID) { |
| 133 | // TODO: It might be worthwhile to Shutdown GC Adapter if we encounter errors here | ||
| 133 | LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size, | 134 | LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size, |
| 134 | controller_payload_copy[0]); | 135 | controller_payload_copy[0]); |
| 135 | } else { | 136 | } else { |
| @@ -200,6 +201,7 @@ void Adapter::StartScanThread() { | |||
| 200 | } | 201 | } |
| 201 | 202 | ||
| 202 | void Adapter::StopScanThread() { | 203 | void Adapter::StopScanThread() { |
| 204 | detect_thread_running = false; | ||
| 203 | detect_thread.join(); | 205 | detect_thread.join(); |
| 204 | } | 206 | } |
| 205 | 207 | ||
| @@ -298,8 +300,6 @@ void Adapter::GetGCEndpoint(libusb_device* device) { | |||
| 298 | Adapter::~Adapter() { | 300 | Adapter::~Adapter() { |
| 299 | StopScanThread(); | 301 | StopScanThread(); |
| 300 | Reset(); | 302 | Reset(); |
| 301 | |||
| 302 | current_status = NO_ADAPTER_DETECTED; | ||
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | void Adapter::Reset() { | 305 | void Adapter::Reset() { |
| @@ -312,11 +312,11 @@ void Adapter::Reset() { | |||
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | if (adapter_thread_running) { | 314 | if (adapter_thread_running) { |
| 315 | adapter_thread_running = false; | ||
| 315 | adapter_input_thread.join(); | 316 | adapter_input_thread.join(); |
| 316 | } | 317 | } |
| 317 | 318 | ||
| 318 | adapter_controllers_status.fill(ControllerTypes::None); | 319 | adapter_controllers_status.fill(ControllerTypes::None); |
| 319 | |||
| 320 | current_status = NO_ADAPTER_DETECTED; | 320 | current_status = NO_ADAPTER_DETECTED; |
| 321 | 321 | ||
| 322 | if (usb_adapter_handle) { | 322 | if (usb_adapter_handle) { |
| @@ -324,6 +324,10 @@ void Adapter::Reset() { | |||
| 324 | libusb_close(usb_adapter_handle); | 324 | libusb_close(usb_adapter_handle); |
| 325 | usb_adapter_handle = nullptr; | 325 | usb_adapter_handle = nullptr; |
| 326 | } | 326 | } |
| 327 | |||
| 328 | if (libusb_ctx) { | ||
| 329 | libusb_exit(libusb_ctx); | ||
| 330 | } | ||
| 327 | } | 331 | } |
| 328 | 332 | ||
| 329 | bool Adapter::DeviceConnected(int port) { | 333 | bool Adapter::DeviceConnected(int port) { |