summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/CMakeLists.txt3
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp80
-rw-r--r--src/input_common/gcadapter/gc_adapter.h25
-rw-r--r--src/input_common/gcadapter/gc_poller.cpp60
-rw-r--r--src/input_common/gcadapter/gc_poller.h2
-rw-r--r--src/input_common/main.cpp1
-rw-r--r--src/input_common/udp/client.cpp2
7 files changed, 111 insertions, 62 deletions
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt
index 3bd76dd23..317c25bad 100644
--- a/src/input_common/CMakeLists.txt
+++ b/src/input_common/CMakeLists.txt
@@ -30,7 +30,8 @@ if(SDL2_FOUND)
30 target_compile_definitions(input_common PRIVATE HAVE_SDL2) 30 target_compile_definitions(input_common PRIVATE HAVE_SDL2)
31endif() 31endif()
32 32
33target_link_libraries(input_common PUBLIC ${LIBUSB_LIBRARIES}) 33target_include_directories(input_common SYSTEM PRIVATE ${LIBUSB_INCLUDE_DIR})
34target_link_libraries(input_common PRIVATE ${LIBUSB_LIBRARIES})
34 35
35create_target_directory_groups(input_common) 36create_target_directory_groups(input_common)
36target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost) 37target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost)
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp
index 6d9f4d9eb..898a278a9 100644
--- a/src/input_common/gcadapter/gc_adapter.cpp
+++ b/src/input_common/gcadapter/gc_adapter.cpp
@@ -4,6 +4,7 @@
4 4
5#include <chrono> 5#include <chrono>
6#include <thread> 6#include <thread>
7#include <libusb.h>
7#include "common/logging/log.h" 8#include "common/logging/log.h"
8#include "input_common/gcadapter/gc_adapter.h" 9#include "input_common/gcadapter/gc_adapter.h"
9 10
@@ -24,6 +25,7 @@ Adapter::Adapter() {
24 LOG_INFO(Input, "GC Adapter Initialization started"); 25 LOG_INFO(Input, "GC Adapter Initialization started");
25 26
26 current_status = NO_ADAPTER_DETECTED; 27 current_status = NO_ADAPTER_DETECTED;
28 get_origin.fill(true);
27 29
28 const int init_res = libusb_init(&libusb_ctx); 30 const int init_res = libusb_init(&libusb_ctx);
29 if (init_res == LIBUSB_SUCCESS) { 31 if (init_res == LIBUSB_SUCCESS) {
@@ -33,15 +35,10 @@ Adapter::Adapter() {
33 } 35 }
34} 36}
35 37
36GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_payload) { 38GCPadStatus Adapter::GetPadStatus(std::size_t port, const std::array<u8, 37>& adapter_payload) {
37 GCPadStatus pad = {}; 39 GCPadStatus pad = {};
38 bool get_origin = false;
39 40
40 ControllerTypes type = ControllerTypes(adapter_payload[1 + (9 * port)] >> 4); 41 ControllerTypes type = ControllerTypes(adapter_payload[1 + (9 * port)] >> 4);
41 if (type != ControllerTypes::None) {
42 get_origin = true;
43 }
44
45 adapter_controllers_status[port] = type; 42 adapter_controllers_status[port] = type;
46 43
47 static constexpr std::array<PadButton, 8> b1_buttons{ 44 static constexpr std::array<PadButton, 8> b1_buttons{
@@ -57,6 +54,11 @@ GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_pa
57 PadButton::PAD_TRIGGER_L, 54 PadButton::PAD_TRIGGER_L,
58 }; 55 };
59 56
57 if (adapter_controllers_status[port] == ControllerTypes::None && !get_origin[port]) {
58 // Controller may have been disconnected, recalibrate if reconnected.
59 get_origin[port] = true;
60 }
61
60 if (adapter_controllers_status[port] != ControllerTypes::None) { 62 if (adapter_controllers_status[port] != ControllerTypes::None) {
61 const u8 b1 = adapter_payload[1 + (9 * port) + 1]; 63 const u8 b1 = adapter_payload[1 + (9 * port) + 1];
62 const u8 b2 = adapter_payload[1 + (9 * port) + 2]; 64 const u8 b2 = adapter_payload[1 + (9 * port) + 2];
@@ -73,16 +75,22 @@ GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_pa
73 } 75 }
74 } 76 }
75 77
76 if (get_origin) {
77 pad.button |= PAD_GET_ORIGIN;
78 }
79
80 pad.stick_x = adapter_payload[1 + (9 * port) + 3]; 78 pad.stick_x = adapter_payload[1 + (9 * port) + 3];
81 pad.stick_y = adapter_payload[1 + (9 * port) + 4]; 79 pad.stick_y = adapter_payload[1 + (9 * port) + 4];
82 pad.substick_x = adapter_payload[1 + (9 * port) + 5]; 80 pad.substick_x = adapter_payload[1 + (9 * port) + 5];
83 pad.substick_y = adapter_payload[1 + (9 * port) + 6]; 81 pad.substick_y = adapter_payload[1 + (9 * port) + 6];
84 pad.trigger_left = adapter_payload[1 + (9 * port) + 7]; 82 pad.trigger_left = adapter_payload[1 + (9 * port) + 7];
85 pad.trigger_right = adapter_payload[1 + (9 * port) + 8]; 83 pad.trigger_right = adapter_payload[1 + (9 * port) + 8];
84
85 if (get_origin[port]) {
86 origin_status[port].stick_x = pad.stick_x;
87 origin_status[port].stick_y = pad.stick_y;
88 origin_status[port].substick_x = pad.substick_x;
89 origin_status[port].substick_y = pad.substick_y;
90 origin_status[port].trigger_left = pad.trigger_left;
91 origin_status[port].trigger_right = pad.trigger_right;
92 get_origin[port] = false;
93 }
86 } 94 }
87 return pad; 95 return pad;
88} 96}
@@ -131,31 +139,31 @@ void Adapter::Read() {
131 for (std::size_t port = 0; port < pads.size(); ++port) { 139 for (std::size_t port = 0; port < pads.size(); ++port) {
132 pads[port] = GetPadStatus(port, adapter_payload_copy); 140 pads[port] = GetPadStatus(port, adapter_payload_copy);
133 if (DeviceConnected(port) && configuring) { 141 if (DeviceConnected(port) && configuring) {
134 if (pads[port].button != PAD_GET_ORIGIN) { 142 if (pads[port].button != 0) {
135 pad_queue[port].Push(pads[port]); 143 pad_queue[port].Push(pads[port]);
136 } 144 }
137 145
138 // Accounting for a threshold here because of some controller variance 146 // Accounting for a threshold here because of some controller variance
139 if (pads[port].stick_x > pads[port].MAIN_STICK_CENTER_X + pads[port].THRESHOLD || 147 if (pads[port].stick_x > origin_status[port].stick_x + pads[port].THRESHOLD ||
140 pads[port].stick_x < pads[port].MAIN_STICK_CENTER_X - pads[port].THRESHOLD) { 148 pads[port].stick_x < origin_status[port].stick_x - pads[port].THRESHOLD) {
141 pads[port].axis = GCAdapter::PadAxes::StickX; 149 pads[port].axis = GCAdapter::PadAxes::StickX;
142 pads[port].axis_value = pads[port].stick_x; 150 pads[port].axis_value = pads[port].stick_x;
143 pad_queue[port].Push(pads[port]); 151 pad_queue[port].Push(pads[port]);
144 } 152 }
145 if (pads[port].stick_y > pads[port].MAIN_STICK_CENTER_Y + pads[port].THRESHOLD || 153 if (pads[port].stick_y > origin_status[port].stick_y + pads[port].THRESHOLD ||
146 pads[port].stick_y < pads[port].MAIN_STICK_CENTER_Y - pads[port].THRESHOLD) { 154 pads[port].stick_y < origin_status[port].stick_y - pads[port].THRESHOLD) {
147 pads[port].axis = GCAdapter::PadAxes::StickY; 155 pads[port].axis = GCAdapter::PadAxes::StickY;
148 pads[port].axis_value = pads[port].stick_y; 156 pads[port].axis_value = pads[port].stick_y;
149 pad_queue[port].Push(pads[port]); 157 pad_queue[port].Push(pads[port]);
150 } 158 }
151 if (pads[port].substick_x > pads[port].C_STICK_CENTER_X + pads[port].THRESHOLD || 159 if (pads[port].substick_x > origin_status[port].substick_x + pads[port].THRESHOLD ||
152 pads[port].substick_x < pads[port].C_STICK_CENTER_X - pads[port].THRESHOLD) { 160 pads[port].substick_x < origin_status[port].substick_x - pads[port].THRESHOLD) {
153 pads[port].axis = GCAdapter::PadAxes::SubstickX; 161 pads[port].axis = GCAdapter::PadAxes::SubstickX;
154 pads[port].axis_value = pads[port].substick_x; 162 pads[port].axis_value = pads[port].substick_x;
155 pad_queue[port].Push(pads[port]); 163 pad_queue[port].Push(pads[port]);
156 } 164 }
157 if (pads[port].substick_y > pads[port].C_STICK_CENTER_Y + pads[port].THRESHOLD || 165 if (pads[port].substick_y > origin_status[port].substick_y + pads[port].THRESHOLD ||
158 pads[port].substick_y < pads[port].C_STICK_CENTER_Y - pads[port].THRESHOLD) { 166 pads[port].substick_y < origin_status[port].substick_y - pads[port].THRESHOLD) {
159 pads[port].axis = GCAdapter::PadAxes::SubstickY; 167 pads[port].axis = GCAdapter::PadAxes::SubstickY;
160 pads[port].axis_value = pads[port].substick_y; 168 pads[port].axis_value = pads[port].substick_y;
161 pad_queue[port].Push(pads[port]); 169 pad_queue[port].Push(pads[port]);
@@ -198,7 +206,7 @@ void Adapter::StartScanThread() {
198 } 206 }
199 207
200 detect_thread_running = true; 208 detect_thread_running = true;
201 detect_thread = std::thread([=] { ScanThreadFunc(); }); 209 detect_thread = std::thread(&Adapter::ScanThreadFunc, this);
202} 210}
203 211
204void Adapter::StopScanThread() { 212void Adapter::StopScanThread() {
@@ -227,7 +235,7 @@ void Adapter::Setup() {
227 } 235 }
228 236
229 if (devices != nullptr) { 237 if (devices != nullptr) {
230 for (std::size_t index = 0; index < device_count; ++index) { 238 for (std::size_t index = 0; index < static_cast<std::size_t>(device_count); ++index) {
231 if (CheckDeviceAccess(devices[index])) { 239 if (CheckDeviceAccess(devices[index])) {
232 // GC Adapter found and accessible, registering it 240 // GC Adapter found and accessible, registering it
233 GetGCEndpoint(devices[index]); 241 GetGCEndpoint(devices[index]);
@@ -236,6 +244,9 @@ void Adapter::Setup() {
236 } 244 }
237 libusb_free_device_list(devices, 1); 245 libusb_free_device_list(devices, 1);
238 } 246 }
247 // Break out of the ScanThreadFunc() loop that is constantly looking for the device
248 // Assumes user has GC adapter plugged in before launch to use the adapter
249 detect_thread_running = false;
239} 250}
240 251
241bool Adapter::CheckDeviceAccess(libusb_device* device) { 252bool Adapter::CheckDeviceAccess(libusb_device* device) {
@@ -344,6 +355,7 @@ void Adapter::Reset() {
344 adapter_input_thread.join(); 355 adapter_input_thread.join();
345 356
346 adapter_controllers_status.fill(ControllerTypes::None); 357 adapter_controllers_status.fill(ControllerTypes::None);
358 get_origin.fill(true);
347 current_status = NO_ADAPTER_DETECTED; 359 current_status = NO_ADAPTER_DETECTED;
348 360
349 if (usb_adapter_handle) { 361 if (usb_adapter_handle) {
@@ -357,15 +369,16 @@ void Adapter::Reset() {
357 } 369 }
358} 370}
359 371
360bool Adapter::DeviceConnected(int port) { 372bool Adapter::DeviceConnected(std::size_t port) {
361 return adapter_controllers_status[port] != ControllerTypes::None; 373 return adapter_controllers_status[port] != ControllerTypes::None;
362} 374}
363 375
364void Adapter::ResetDeviceType(int port) { 376void Adapter::ResetDeviceType(std::size_t port) {
365 adapter_controllers_status[port] = ControllerTypes::None; 377 adapter_controllers_status[port] = ControllerTypes::None;
366} 378}
367 379
368void Adapter::BeginConfiguration() { 380void Adapter::BeginConfiguration() {
381 get_origin.fill(true);
369 for (auto& pq : pad_queue) { 382 for (auto& pq : pad_queue) {
370 pq.Clear(); 383 pq.Clear();
371 } 384 }
@@ -395,4 +408,25 @@ const std::array<GCState, 4>& Adapter::GetPadState() const {
395 return state; 408 return state;
396} 409}
397 410
411int Adapter::GetOriginValue(int port, int axis) const {
412 const auto& status = origin_status[port];
413
414 switch (static_cast<PadAxes>(axis)) {
415 case PadAxes::StickX:
416 return status.stick_x;
417 case PadAxes::StickY:
418 return status.stick_y;
419 case PadAxes::SubstickX:
420 return status.substick_x;
421 case PadAxes::SubstickY:
422 return status.substick_y;
423 case PadAxes::TriggerLeft:
424 return status.trigger_left;
425 case PadAxes::TriggerRight:
426 return status.trigger_right;
427 default:
428 return 0;
429 }
430}
431
398} // namespace GCAdapter 432} // namespace GCAdapter
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h
index b1c2a1958..3586c8bda 100644
--- a/src/input_common/gcadapter/gc_adapter.h
+++ b/src/input_common/gcadapter/gc_adapter.h
@@ -8,17 +8,14 @@
8#include <mutex> 8#include <mutex>
9#include <thread> 9#include <thread>
10#include <unordered_map> 10#include <unordered_map>
11#include <libusb.h>
12#include "common/common_types.h" 11#include "common/common_types.h"
13#include "common/threadsafe_queue.h" 12#include "common/threadsafe_queue.h"
14 13
15namespace GCAdapter { 14struct libusb_context;
15struct libusb_device;
16struct libusb_device_handle;
16 17
17enum { 18namespace GCAdapter {
18 PAD_USE_ORIGIN = 0x0080,
19 PAD_GET_ORIGIN = 0x2000,
20 PAD_ERR_STATUS = 0x8000,
21};
22 19
23enum class PadButton { 20enum class PadButton {
24 PAD_BUTTON_LEFT = 0x0001, 21 PAD_BUTTON_LEFT = 0x0001,
@@ -97,14 +94,19 @@ public:
97 void BeginConfiguration(); 94 void BeginConfiguration();
98 void EndConfiguration(); 95 void EndConfiguration();
99 96
97 /// Returns true if there is a device connected to port
98 bool DeviceConnected(std::size_t port);
99
100 std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue(); 100 std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue();
101 const std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue() const; 101 const std::array<Common::SPSCQueue<GCPadStatus>, 4>& GetPadQueue() const;
102 102
103 std::array<GCState, 4>& GetPadState(); 103 std::array<GCState, 4>& GetPadState();
104 const std::array<GCState, 4>& GetPadState() const; 104 const std::array<GCState, 4>& GetPadState() const;
105 105
106 int GetOriginValue(int port, int axis) const;
107
106private: 108private:
107 GCPadStatus GetPadStatus(int port, const std::array<u8, 37>& adapter_payload); 109 GCPadStatus GetPadStatus(std::size_t port, const std::array<u8, 37>& adapter_payload);
108 110
109 void PadToState(const GCPadStatus& pad, GCState& state); 111 void PadToState(const GCPadStatus& pad, GCState& state);
110 112
@@ -116,11 +118,8 @@ private:
116 /// Stop scanning for the adapter 118 /// Stop scanning for the adapter
117 void StopScanThread(); 119 void StopScanThread();
118 120
119 /// Returns true if there is a device connected to port
120 bool DeviceConnected(int port);
121
122 /// Resets status of device connected to port 121 /// Resets status of device connected to port
123 void ResetDeviceType(int port); 122 void ResetDeviceType(std::size_t port);
124 123
125 /// Returns true if we successfully gain access to GC Adapter 124 /// Returns true if we successfully gain access to GC Adapter
126 bool CheckDeviceAccess(libusb_device* device); 125 bool CheckDeviceAccess(libusb_device* device);
@@ -156,6 +155,8 @@ private:
156 155
157 std::array<Common::SPSCQueue<GCPadStatus>, 4> pad_queue; 156 std::array<Common::SPSCQueue<GCPadStatus>, 4> pad_queue;
158 std::array<GCState, 4> state; 157 std::array<GCState, 4> state;
158 std::array<bool, 4> get_origin;
159 std::array<GCPadStatus, 4> origin_status;
159}; 160};
160 161
161} // namespace GCAdapter 162} // namespace GCAdapter
diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp
index 385ce8430..96e22d3ad 100644
--- a/src/input_common/gcadapter/gc_poller.cpp
+++ b/src/input_common/gcadapter/gc_poller.cpp
@@ -6,6 +6,7 @@
6#include <list> 6#include <list>
7#include <mutex> 7#include <mutex>
8#include <utility> 8#include <utility>
9#include "common/assert.h"
9#include "common/threadsafe_queue.h" 10#include "common/threadsafe_queue.h"
10#include "input_common/gcadapter/gc_adapter.h" 11#include "input_common/gcadapter/gc_adapter.h"
11#include "input_common/gcadapter/gc_poller.h" 12#include "input_common/gcadapter/gc_poller.h"
@@ -20,7 +21,10 @@ public:
20 ~GCButton() override; 21 ~GCButton() override;
21 22
22 bool GetStatus() const override { 23 bool GetStatus() const override {
23 return gcadapter->GetPadState()[port].buttons.at(button); 24 if (gcadapter->DeviceConnected(port)) {
25 return gcadapter->GetPadState()[port].buttons.at(button);
26 }
27 return false;
24 } 28 }
25 29
26private: 30private:
@@ -34,22 +38,20 @@ public:
34 explicit GCAxisButton(int port_, int axis_, float threshold_, bool trigger_if_greater_, 38 explicit GCAxisButton(int port_, int axis_, float threshold_, bool trigger_if_greater_,
35 GCAdapter::Adapter* adapter) 39 GCAdapter::Adapter* adapter)
36 : port(port_), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_), 40 : port(port_), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_),
37 gcadapter(adapter) { 41 gcadapter(adapter), origin_value(adapter->GetOriginValue(port_, axis_)) {}
38 // L/R triggers range is only in positive direction beginning near 0
39 // 0.0 threshold equates to near half trigger press, but threshold accounts for variability.
40 if (axis > 3) {
41 threshold *= -0.5;
42 }
43 }
44 42
45 bool GetStatus() const override { 43 bool GetStatus() const override {
46 const float axis_value = (gcadapter->GetPadState()[port].axes.at(axis) - 128.0f) / 128.0f; 44 if (gcadapter->DeviceConnected(port)) {
47 if (trigger_if_greater) { 45 const float current_axis_value = gcadapter->GetPadState()[port].axes.at(axis);
48 // TODO: Might be worthwile to set a slider for the trigger threshold. It is currently 46 const float axis_value = (current_axis_value - origin_value) / 128.0f;
49 // always set to 0.5 in configure_input_player.cpp ZL/ZR HandleClick 47 if (trigger_if_greater) {
50 return axis_value > threshold; 48 // TODO: Might be worthwile to set a slider for the trigger threshold. It is
49 // currently always set to 0.5 in configure_input_player.cpp ZL/ZR HandleClick
50 return axis_value > threshold;
51 }
52 return axis_value < -threshold;
51 } 53 }
52 return axis_value < -threshold; 54 return false;
53 } 55 }
54 56
55private: 57private:
@@ -58,6 +60,7 @@ private:
58 float threshold; 60 float threshold;
59 bool trigger_if_greater; 61 bool trigger_if_greater;
60 GCAdapter::Adapter* gcadapter; 62 GCAdapter::Adapter* gcadapter;
63 const float origin_value;
61}; 64};
62 65
63GCButtonFactory::GCButtonFactory(std::shared_ptr<GCAdapter::Adapter> adapter_) 66GCButtonFactory::GCButtonFactory(std::shared_ptr<GCAdapter::Adapter> adapter_)
@@ -94,9 +97,12 @@ std::unique_ptr<Input::ButtonDevice> GCButtonFactory::Create(const Common::Param
94 return std::make_unique<GCAxisButton>(port, axis, threshold, trigger_if_greater, 97 return std::make_unique<GCAxisButton>(port, axis, threshold, trigger_if_greater,
95 adapter.get()); 98 adapter.get());
96 } 99 }
100
101 UNREACHABLE();
102 return nullptr;
97} 103}
98 104
99Common::ParamPackage GCButtonFactory::GetNextInput() { 105Common::ParamPackage GCButtonFactory::GetNextInput() const {
100 Common::ParamPackage params; 106 Common::ParamPackage params;
101 GCAdapter::GCPadStatus pad; 107 GCAdapter::GCPadStatus pad;
102 auto& queue = adapter->GetPadQueue(); 108 auto& queue = adapter->GetPadQueue();
@@ -144,14 +150,20 @@ void GCButtonFactory::EndConfiguration() {
144class GCAnalog final : public Input::AnalogDevice { 150class GCAnalog final : public Input::AnalogDevice {
145public: 151public:
146 GCAnalog(int port_, int axis_x_, int axis_y_, float deadzone_, GCAdapter::Adapter* adapter) 152 GCAnalog(int port_, int axis_x_, int axis_y_, float deadzone_, GCAdapter::Adapter* adapter)
147 : port(port_), axis_x(axis_x_), axis_y(axis_y_), deadzone(deadzone_), gcadapter(adapter) {} 153 : port(port_), axis_x(axis_x_), axis_y(axis_y_), deadzone(deadzone_), gcadapter(adapter),
154 origin_value_x(adapter->GetOriginValue(port_, axis_x_)),
155 origin_value_y(adapter->GetOriginValue(port_, axis_y_)) {}
148 156
149 float GetAxis(int axis) const { 157 float GetAxis(int axis) const {
150 std::lock_guard lock{mutex}; 158 if (gcadapter->DeviceConnected(port)) {
151 // division is not by a perfect 128 to account for some variance in center location 159 std::lock_guard lock{mutex};
152 // e.g. my device idled at 131 in X, 120 in Y, and full range of motion was in range 160 const auto origin_value = axis % 2 == 0 ? origin_value_x : origin_value_y;
153 // [20-230] 161 // division is not by a perfect 128 to account for some variance in center location
154 return (gcadapter->GetPadState()[port].axes.at(axis) - 128.0f) / 95.0f; 162 // e.g. my device idled at 131 in X, 120 in Y, and full range of motion was in range
163 // [20-230]
164 return (gcadapter->GetPadState()[port].axes.at(axis) - origin_value) / 95.0f;
165 }
166 return 0.0f;
155 } 167 }
156 168
157 std::pair<float, float> GetAnalog(int axis_x, int axis_y) const { 169 std::pair<float, float> GetAnalog(int axis_x, int axis_y) const {
@@ -201,8 +213,10 @@ private:
201 const int axis_x; 213 const int axis_x;
202 const int axis_y; 214 const int axis_y;
203 const float deadzone; 215 const float deadzone;
204 mutable std::mutex mutex;
205 GCAdapter::Adapter* gcadapter; 216 GCAdapter::Adapter* gcadapter;
217 const float origin_value_x;
218 const float origin_value_y;
219 mutable std::mutex mutex;
206}; 220};
207 221
208/// An analog device factory that creates analog devices from GC Adapter 222/// An analog device factory that creates analog devices from GC Adapter
@@ -249,7 +263,7 @@ Common::ParamPackage GCAnalogFactory::GetNextInput() {
249 const u8 axis = static_cast<u8>(pad.axis); 263 const u8 axis = static_cast<u8>(pad.axis);
250 if (analog_x_axis == -1) { 264 if (analog_x_axis == -1) {
251 analog_x_axis = axis; 265 analog_x_axis = axis;
252 controller_number = port; 266 controller_number = static_cast<int>(port);
253 } else if (analog_y_axis == -1 && analog_x_axis != axis && controller_number == port) { 267 } else if (analog_y_axis == -1 && analog_x_axis != axis && controller_number == port) {
254 analog_y_axis = axis; 268 analog_y_axis = axis;
255 } 269 }
diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h
index e96af7d51..0527f328f 100644
--- a/src/input_common/gcadapter/gc_poller.h
+++ b/src/input_common/gcadapter/gc_poller.h
@@ -25,7 +25,7 @@ public:
25 */ 25 */
26 std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override; 26 std::unique_ptr<Input::ButtonDevice> Create(const Common::ParamPackage& params) override;
27 27
28 Common::ParamPackage GetNextInput(); 28 Common::ParamPackage GetNextInput() const;
29 29
30 /// For device input configuration/polling 30 /// For device input configuration/polling
31 void BeginConfiguration(); 31 void BeginConfiguration();
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index fd0af1019..b9d5d0ec3 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -4,7 +4,6 @@
4 4
5#include <memory> 5#include <memory>
6#include <thread> 6#include <thread>
7#include <libusb.h>
8#include "common/param_package.h" 7#include "common/param_package.h"
9#include "input_common/analog_from_button.h" 8#include "input_common/analog_from_button.h"
10#include "input_common/gcadapter/gc_adapter.h" 9#include "input_common/gcadapter/gc_adapter.h"
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index da5227058..e63c73c4f 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -234,7 +234,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob(
234 std::function<void(Status)> status_callback, 234 std::function<void(Status)> status_callback,
235 std::function<void(u16, u16, u16, u16)> data_callback) { 235 std::function<void(u16, u16, u16, u16)> data_callback) {
236 236
237 std::thread([=] { 237 std::thread([=, this] {
238 constexpr u16 CALIBRATION_THRESHOLD = 100; 238 constexpr u16 CALIBRATION_THRESHOLD = 100;
239 239
240 u16 min_x{UINT16_MAX}; 240 u16 min_x{UINT16_MAX};