summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmeer <aj662@drexel.edu>2020-06-23 18:47:58 +0200
committerAmeer <aj662@drexel.edu>2020-06-23 18:47:58 +0200
commitd4e07fd95e999e34562428c628985a6eb1fb532d (patch)
tree06f75257618ce8250239a8cd809781adb4784dd9
parentSmall quality of life indication that mapped button is GC (diff)
downloadyuzu-d4e07fd95e999e34562428c628985a6eb1fb532d.tar
yuzu-d4e07fd95e999e34562428c628985a6eb1fb532d.tar.gz
yuzu-d4e07fd95e999e34562428c628985a6eb1fb532d.tar.bz2
yuzu-d4e07fd95e999e34562428c628985a6eb1fb532d.tar.lz
yuzu-d4e07fd95e999e34562428c628985a6eb1fb532d.tar.xz
yuzu-d4e07fd95e999e34562428c628985a6eb1fb532d.tar.zst
yuzu-d4e07fd95e999e34562428c628985a6eb1fb532d.zip
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp10
-rw-r--r--src/input_common/gcadapter/gc_adapter.h1
-rw-r--r--src/input_common/main.cpp3
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() {
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) {
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 {
ADAPTER_DETECTED = 1,
};
-/// Singleton Adapter class
class Adapter {
public:
/// 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() {
#endif
udp.reset();
Input::UnregisterFactory<Input::ButtonDevice>("gcpad");
+ Input::UnregisterFactory<Input::AnalogDevice>("gcpad");
+
gcbuttons.reset();
+ gcanalog.reset();
}
Keyboard* GetKeyboard() {