mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-27 09:12:46 +01:00
Fix deallocation of GC Adapter
This commit is contained in:
parent
901bc09dd7
commit
d4e07fd95e
3 changed files with 10 additions and 4 deletions
|
@ -130,6 +130,7 @@ void Adapter::Read() {
|
||||||
|
|
||||||
if (payload_size != sizeof(controller_payload_copy) ||
|
if (payload_size != sizeof(controller_payload_copy) ||
|
||||||
controller_payload_copy[0] != LIBUSB_DT_HID) {
|
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,
|
LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size,
|
||||||
controller_payload_copy[0]);
|
controller_payload_copy[0]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -200,6 +201,7 @@ void Adapter::StartScanThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adapter::StopScanThread() {
|
void Adapter::StopScanThread() {
|
||||||
|
detect_thread_running = false;
|
||||||
detect_thread.join();
|
detect_thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,8 +300,6 @@ void Adapter::GetGCEndpoint(libusb_device* device) {
|
||||||
Adapter::~Adapter() {
|
Adapter::~Adapter() {
|
||||||
StopScanThread();
|
StopScanThread();
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
current_status = NO_ADAPTER_DETECTED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adapter::Reset() {
|
void Adapter::Reset() {
|
||||||
|
@ -312,11 +312,11 @@ void Adapter::Reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adapter_thread_running) {
|
if (adapter_thread_running) {
|
||||||
|
adapter_thread_running = false;
|
||||||
adapter_input_thread.join();
|
adapter_input_thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter_controllers_status.fill(ControllerTypes::None);
|
adapter_controllers_status.fill(ControllerTypes::None);
|
||||||
|
|
||||||
current_status = NO_ADAPTER_DETECTED;
|
current_status = NO_ADAPTER_DETECTED;
|
||||||
|
|
||||||
if (usb_adapter_handle) {
|
if (usb_adapter_handle) {
|
||||||
|
@ -324,6 +324,10 @@ void Adapter::Reset() {
|
||||||
libusb_close(usb_adapter_handle);
|
libusb_close(usb_adapter_handle);
|
||||||
usb_adapter_handle = nullptr;
|
usb_adapter_handle = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (libusb_ctx) {
|
||||||
|
libusb_exit(libusb_ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Adapter::DeviceConnected(int port) {
|
bool Adapter::DeviceConnected(int port) {
|
||||||
|
|
|
@ -82,7 +82,6 @@ enum {
|
||||||
ADAPTER_DETECTED = 1,
|
ADAPTER_DETECTED = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Singleton Adapter class
|
|
||||||
class Adapter {
|
class Adapter {
|
||||||
public:
|
public:
|
||||||
/// Initialize the GC Adapter capture and read sequence
|
/// Initialize the GC Adapter capture and read sequence
|
||||||
|
|
|
@ -59,7 +59,10 @@ void Shutdown() {
|
||||||
#endif
|
#endif
|
||||||
udp.reset();
|
udp.reset();
|
||||||
Input::UnregisterFactory<Input::ButtonDevice>("gcpad");
|
Input::UnregisterFactory<Input::ButtonDevice>("gcpad");
|
||||||
|
Input::UnregisterFactory<Input::AnalogDevice>("gcpad");
|
||||||
|
|
||||||
gcbuttons.reset();
|
gcbuttons.reset();
|
||||||
|
gcanalog.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Keyboard* GetKeyboard() {
|
Keyboard* GetKeyboard() {
|
||||||
|
|
Loading…
Reference in a new issue