summaryrefslogtreecommitdiffstats
path: root/src/input_common/gcadapter/gc_adapter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/gcadapter/gc_adapter.cpp')
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp10
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() {
if (payload_size != sizeof(controller_payload_copy) ||
controller_payload_copy[0] != LIBUSB_DT_HID) {
+ // TODO: It might be worthwhile to Shutdown GC Adapter if we encounter errors here
LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size,
controller_payload_copy[0]);
} else {
@@ -200,6 +201,7 @@ void Adapter::StartScanThread() {
}
void Adapter::StopScanThread() {
+ detect_thread_running = false;
detect_thread.join();
}
@@ -298,8 +300,6 @@ void Adapter::GetGCEndpoint(libusb_device* device) {
Adapter::~Adapter() {
StopScanThread();
Reset();
-
- current_status = NO_ADAPTER_DETECTED;
}
void Adapter::Reset() {
@@ -312,11 +312,11 @@ void Adapter::Reset() {
}
if (adapter_thread_running) {
+ adapter_thread_running = false;
adapter_input_thread.join();
}
adapter_controllers_status.fill(ControllerTypes::None);
-
current_status = NO_ADAPTER_DETECTED;
if (usb_adapter_handle) {
@@ -324,6 +324,10 @@ void Adapter::Reset() {
libusb_close(usb_adapter_handle);
usb_adapter_handle = nullptr;
}
+
+ if (libusb_ctx) {
+ libusb_exit(libusb_ctx);
+ }
}
bool Adapter::DeviceConnected(int port) {