diff options
Diffstat (limited to 'src/input_common/gcadapter/gc_adapter.cpp')
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp index b509b3e46..b98b85441 100644 --- a/src/input_common/gcadapter/gc_adapter.cpp +++ b/src/input_common/gcadapter/gc_adapter.cpp | |||
| @@ -45,13 +45,13 @@ GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_pa | |||
| 45 | const u8 b1 = adapter_payload[1 + (9 * port) + 1]; | 45 | const u8 b1 = adapter_payload[1 + (9 * port) + 1]; |
| 46 | const u8 b2 = adapter_payload[1 + (9 * port) + 2]; | 46 | const u8 b2 = adapter_payload[1 + (9 * port) + 2]; |
| 47 | 47 | ||
| 48 | for (int i = 0; i < b1_buttons.size(); i++) { | 48 | for (std::size_t i = 0; i < b1_buttons.size(); ++i) { |
| 49 | if (b1 & (1 << i)) { | 49 | if (b1 & (1 << i)) { |
| 50 | pad.button |= static_cast<u16>(b1_buttons[i]); | 50 | pad.button |= static_cast<u16>(b1_buttons[i]); |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | for (int j = 0; j < b2_buttons.size(); j++) { | 54 | for (std::size_t j = 0; j < b2_buttons.size(); ++j) { |
| 55 | if (b2 & (1 << j)) { | 55 | if (b2 & (1 << j)) { |
| 56 | pad.button |= static_cast<u16>(b2_buttons[j]); | 56 | pad.button |= static_cast<u16>(b2_buttons[j]); |
| 57 | } | 57 | } |
| @@ -73,7 +73,7 @@ GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_pa | |||
| 73 | 73 | ||
| 74 | void Adapter::PadToState(const GCPadStatus& pad, GCState& state) { | 74 | void Adapter::PadToState(const GCPadStatus& pad, GCState& state) { |
| 75 | for (const auto& button : PadButtonArray) { | 75 | for (const auto& button : PadButtonArray) { |
| 76 | u16 button_value = static_cast<u16>(button); | 76 | const u16 button_value = static_cast<u16>(button); |
| 77 | state.buttons.insert_or_assign(button_value, pad.button & button_value); | 77 | state.buttons.insert_or_assign(button_value, pad.button & button_value); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| @@ -86,7 +86,7 @@ void Adapter::PadToState(const GCPadStatus& pad, GCState& state) { | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | void Adapter::Read() { | 88 | void Adapter::Read() { |
| 89 | LOG_INFO(Input, "GC Adapter Read() thread started"); | 89 | LOG_DEBUG(Input, "GC Adapter Read() thread started"); |
| 90 | 90 | ||
| 91 | int payload_size_in, payload_size_copy; | 91 | int payload_size_in, payload_size_copy; |
| 92 | std::array<u8, 37> adapter_payload; | 92 | std::array<u8, 37> adapter_payload; |
| @@ -109,12 +109,10 @@ void Adapter::Read() { | |||
| 109 | LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size_copy, | 109 | LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size_copy, |
| 110 | adapter_payload_copy[0]); | 110 | adapter_payload_copy[0]); |
| 111 | adapter_thread_running = false; // error reading from adapter, stop reading. | 111 | adapter_thread_running = false; // error reading from adapter, stop reading. |
| 112 | } else { | 112 | break; |
| 113 | for (int port = 0; port < pads.size(); port++) { | ||
| 114 | pads[port] = GetPadStatus(port, adapter_payload_copy); | ||
| 115 | } | ||
| 116 | } | 113 | } |
| 117 | for (int port = 0; port < pads.size(); port++) { | 114 | for (std::size_t port = 0; port < pads.size(); ++port) { |
| 115 | pads[port] = GetPadStatus(port, adapter_payload_copy); | ||
| 118 | if (DeviceConnected(port) && configuring) { | 116 | if (DeviceConnected(port) && configuring) { |
| 119 | if (pads[port].button != PAD_GET_ORIGIN) { | 117 | if (pads[port].button != PAD_GET_ORIGIN) { |
| 120 | pad_queue[port].Push(pads[port]); | 118 | pad_queue[port].Push(pads[port]); |
| @@ -189,14 +187,16 @@ void Adapter::Setup() { | |||
| 189 | 187 | ||
| 190 | adapter_controllers_status.fill(ControllerTypes::None); | 188 | adapter_controllers_status.fill(ControllerTypes::None); |
| 191 | 189 | ||
| 192 | libusb_device** devs; // pointer to list of connected usb devices | 190 | // pointer to list of connected usb devices |
| 191 | libusb_device** devices; | ||
| 193 | 192 | ||
| 194 | const std::size_t cnt = libusb_get_device_list(libusb_ctx, &devs); // get the list of devices | 193 | // populate the list of devices, get the count |
| 194 | const std::size_t device_count = libusb_get_device_list(libusb_ctx, &devices); | ||
| 195 | 195 | ||
| 196 | for (int i = 0; i < cnt; i++) { | 196 | for (std::size_t index = 0; index < device_count; ++index) { |
| 197 | if (CheckDeviceAccess(devs[i])) { | 197 | if (CheckDeviceAccess(devices[index])) { |
| 198 | // GC Adapter found and accessible, registering it | 198 | // GC Adapter found and accessible, registering it |
| 199 | GetGCEndpoint(devs[i]); | 199 | GetGCEndpoint(devices[index]); |
| 200 | break; | 200 | break; |
| 201 | } | 201 | } |
| 202 | } | 202 | } |