diff options
| author | 2020-06-21 21:50:58 -0400 | |
|---|---|---|
| committer | 2020-06-21 21:50:58 -0400 | |
| commit | 46b4461fbb0514dd50c096ef896b1752d81079d0 (patch) | |
| tree | 31245dd4ff76724295a20202cea9dba72635f3a0 /src/input_common/gcadapter/gc_adapter.cpp | |
| parent | std::arrays where appropriate, clear q in adapter class, other touch ups (diff) | |
| download | yuzu-46b4461fbb0514dd50c096ef896b1752d81079d0.tar.gz yuzu-46b4461fbb0514dd50c096ef896b1752d81079d0.tar.xz yuzu-46b4461fbb0514dd50c096ef896b1752d81079d0.zip | |
shared_ptr for the GC adapter class, constexpr constants
Diffstat (limited to 'src/input_common/gcadapter/gc_adapter.cpp')
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp index 498bd0d6e..db72d7633 100644 --- a/src/input_common/gcadapter/gc_adapter.cpp +++ b/src/input_common/gcadapter/gc_adapter.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include "input_common/gcadapter/gc_adapter.h" | 6 | #include "input_common/gcadapter/gc_adapter.h" |
| 7 | 7 | ||
| 8 | namespace GCAdapter { | 8 | namespace GCAdapter { |
| 9 | Adapter* Adapter::adapter_instance{nullptr}; | ||
| 10 | 9 | ||
| 11 | Adapter::Adapter() { | 10 | Adapter::Adapter() { |
| 12 | if (usb_adapter_handle != nullptr) { | 11 | if (usb_adapter_handle != nullptr) { |
| @@ -20,13 +19,6 @@ Adapter::Adapter() { | |||
| 20 | StartScanThread(); | 19 | StartScanThread(); |
| 21 | } | 20 | } |
| 22 | 21 | ||
| 23 | Adapter* Adapter::GetInstance() { | ||
| 24 | if (!adapter_instance) { | ||
| 25 | adapter_instance = new Adapter; | ||
| 26 | } | ||
| 27 | return adapter_instance; | ||
| 28 | } | ||
| 29 | |||
| 30 | GCPadStatus Adapter::CheckStatus(int port, u8 adapter_payload[37]) { | 22 | GCPadStatus Adapter::CheckStatus(int port, u8 adapter_payload[37]) { |
| 31 | GCPadStatus pad = {}; | 23 | GCPadStatus pad = {}; |
| 32 | bool get_origin = false; | 24 | bool get_origin = false; |
| @@ -151,34 +143,26 @@ void Adapter::Read() { | |||
| 151 | } | 143 | } |
| 152 | 144 | ||
| 153 | // Accounting for a threshold here because of some controller variance | 145 | // Accounting for a threshold here because of some controller variance |
| 154 | if (pad[port].stick_x > | 146 | if (pad[port].stick_x > pad[port].MAIN_STICK_CENTER_X + pad[port].THRESHOLD || |
| 155 | pad_constants.MAIN_STICK_CENTER_X + pad_constants.THRESHOLD || | 147 | pad[port].stick_x < pad[port].MAIN_STICK_CENTER_X - pad[port].THRESHOLD) { |
| 156 | pad[port].stick_x < | ||
| 157 | pad_constants.MAIN_STICK_CENTER_X - pad_constants.THRESHOLD) { | ||
| 158 | pad[port].axis = GCAdapter::PadAxes::StickX; | 148 | pad[port].axis = GCAdapter::PadAxes::StickX; |
| 159 | pad[port].axis_value = pad[port].stick_x; | 149 | pad[port].axis_value = pad[port].stick_x; |
| 160 | pad_queue[port].Push(pad[port]); | 150 | pad_queue[port].Push(pad[port]); |
| 161 | } | 151 | } |
| 162 | if (pad[port].stick_y > | 152 | if (pad[port].stick_y > pad[port].MAIN_STICK_CENTER_Y + pad[port].THRESHOLD || |
| 163 | pad_constants.MAIN_STICK_CENTER_Y + pad_constants.THRESHOLD || | 153 | pad[port].stick_y < pad[port].MAIN_STICK_CENTER_Y - pad[port].THRESHOLD) { |
| 164 | pad[port].stick_y < | ||
| 165 | pad_constants.MAIN_STICK_CENTER_Y - pad_constants.THRESHOLD) { | ||
| 166 | pad[port].axis = GCAdapter::PadAxes::StickY; | 154 | pad[port].axis = GCAdapter::PadAxes::StickY; |
| 167 | pad[port].axis_value = pad[port].stick_y; | 155 | pad[port].axis_value = pad[port].stick_y; |
| 168 | pad_queue[port].Push(pad[port]); | 156 | pad_queue[port].Push(pad[port]); |
| 169 | } | 157 | } |
| 170 | if (pad[port].substick_x > | 158 | if (pad[port].substick_x > pad[port].C_STICK_CENTER_X + pad[port].THRESHOLD || |
| 171 | pad_constants.C_STICK_CENTER_X + pad_constants.THRESHOLD || | 159 | pad[port].substick_x < pad[port].C_STICK_CENTER_X - pad[port].THRESHOLD) { |
| 172 | pad[port].substick_x < | ||
| 173 | pad_constants.C_STICK_CENTER_X - pad_constants.THRESHOLD) { | ||
| 174 | pad[port].axis = GCAdapter::PadAxes::SubstickX; | 160 | pad[port].axis = GCAdapter::PadAxes::SubstickX; |
| 175 | pad[port].axis_value = pad[port].substick_x; | 161 | pad[port].axis_value = pad[port].substick_x; |
| 176 | pad_queue[port].Push(pad[port]); | 162 | pad_queue[port].Push(pad[port]); |
| 177 | } | 163 | } |
| 178 | if (pad[port].substick_y > | 164 | if (pad[port].substick_y > pad[port].C_STICK_CENTER_Y + pad[port].THRESHOLD || |
| 179 | pad_constants.C_STICK_CENTER_Y + pad_constants.THRESHOLD || | 165 | pad[port].substick_y < pad[port].C_STICK_CENTER_Y - pad[port].THRESHOLD) { |
| 180 | pad[port].substick_y < | ||
| 181 | pad_constants.C_STICK_CENTER_Y - pad_constants.THRESHOLD) { | ||
| 182 | pad[port].axis = GCAdapter::PadAxes::SubstickY; | 166 | pad[port].axis = GCAdapter::PadAxes::SubstickY; |
| 183 | pad[port].axis_value = pad[port].substick_y; | 167 | pad[port].axis_value = pad[port].substick_y; |
| 184 | pad_queue[port].Push(pad[port]); | 168 | pad_queue[port].Push(pad[port]); |
| @@ -367,8 +351,16 @@ std::array<Common::SPSCQueue<GCPadStatus>, 4>& Adapter::GetPadQueue() { | |||
| 367 | return pad_queue; | 351 | return pad_queue; |
| 368 | } | 352 | } |
| 369 | 353 | ||
| 354 | const std::array<Common::SPSCQueue<GCPadStatus>, 4>& Adapter::GetPadQueue() const { | ||
| 355 | return pad_queue; | ||
| 356 | } | ||
| 357 | |||
| 370 | std::array<GCState, 4>& Adapter::GetPadState() { | 358 | std::array<GCState, 4>& Adapter::GetPadState() { |
| 371 | return state; | 359 | return state; |
| 372 | } | 360 | } |
| 373 | 361 | ||
| 362 | const std::array<GCState, 4>& Adapter::GetPadState() const { | ||
| 363 | return state; | ||
| 364 | } | ||
| 365 | |||
| 374 | } // end of namespace GCAdapter | 366 | } // end of namespace GCAdapter |