diff options
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.cpp | 10 | ||||
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.h | 1 | ||||
| -rw-r--r-- | src/input_common/main.cpp | 3 |
3 files changed, 10 insertions, 4 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) { |
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h index ff0202e3b..7aed0b480 100644 --- a/src/input_common/gcadapter/gc_adapter.h +++ b/src/input_common/gcadapter/gc_adapter.h | |||
| @@ -82,7 +82,6 @@ enum { | |||
| 82 | ADAPTER_DETECTED = 1, | 82 | ADAPTER_DETECTED = 1, |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | /// Singleton Adapter class | ||
| 86 | class Adapter { | 85 | class Adapter { |
| 87 | public: | 86 | public: |
| 88 | /// Initialize the GC Adapter capture and read sequence | 87 | /// Initialize the GC Adapter capture and read sequence |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index a9572c23c..f13420b38 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -59,7 +59,10 @@ void Shutdown() { | |||
| 59 | #endif | 59 | #endif |
| 60 | udp.reset(); | 60 | udp.reset(); |
| 61 | Input::UnregisterFactory<Input::ButtonDevice>("gcpad"); | 61 | Input::UnregisterFactory<Input::ButtonDevice>("gcpad"); |
| 62 | Input::UnregisterFactory<Input::AnalogDevice>("gcpad"); | ||
| 63 | |||
| 62 | gcbuttons.reset(); | 64 | gcbuttons.reset(); |
| 65 | gcanalog.reset(); | ||
| 63 | } | 66 | } |
| 64 | 67 | ||
| 65 | Keyboard* GetKeyboard() { | 68 | Keyboard* GetKeyboard() { |