summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ameer2020-06-21 15:31:57 -0400
committerGravatar Ameer2020-06-21 15:31:57 -0400
commitc94583d867fd909d8731ba50e085352aae0e6885 (patch)
tree9c691c1382d3317f45ad09cb43a93f9223fe379b
parentCleanup after linter (diff)
downloadyuzu-c94583d867fd909d8731ba50e085352aae0e6885.tar.gz
yuzu-c94583d867fd909d8731ba50e085352aae0e6885.tar.xz
yuzu-c94583d867fd909d8731ba50e085352aae0e6885.zip
Clang Formatting
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp42
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp90
-rw-r--r--src/input_common/gcadapter/gc_adapter.h16
-rw-r--r--src/input_common/gcadapter/gc_poller.cpp56
-rw-r--r--src/input_common/gcadapter/gc_poller.h5
-rw-r--r--src/input_common/main.h3
-rw-r--r--src/input_common/udp/client.cpp6
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp140
-rw-r--r--src/yuzu/configuration/configure_input_player.h8
9 files changed, 184 insertions, 182 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index d92325cb5..c55d900e2 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -44,7 +44,7 @@ static Controller_NPad::NPadControllerType MapSettingsTypeToNPad(Settings::Contr
44 case Settings::ControllerType::RightJoycon: 44 case Settings::ControllerType::RightJoycon:
45 return Controller_NPad::NPadControllerType::JoyRight; 45 return Controller_NPad::NPadControllerType::JoyRight;
46 default: 46 default:
47 UNREACHABLE(); 47 UNREACHABLE();
48 return Controller_NPad::NPadControllerType::JoyDual; 48 return Controller_NPad::NPadControllerType::JoyDual;
49 } 49 }
50} 50}
@@ -93,10 +93,7 @@ u32 Controller_NPad::IndexToNPad(std::size_t index) {
93 }; 93 };
94} 94}
95 95
96Controller_NPad::Controller_NPad(Core::System& system) 96Controller_NPad::Controller_NPad(Core::System& system) : ControllerBase(system), system(system) {}
97 : ControllerBase(system), system(system) {
98}
99
100Controller_NPad::~Controller_NPad() = default; 97Controller_NPad::~Controller_NPad() = default;
101 98
102void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) { 99void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
@@ -109,7 +106,7 @@ void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
109 controller.device_type.raw = 0; 106 controller.device_type.raw = 0;
110 switch (controller_type) { 107 switch (controller_type) {
111 case NPadControllerType::None: 108 case NPadControllerType::None:
112 UNREACHABLE(); 109 UNREACHABLE();
113 break; 110 break;
114 case NPadControllerType::Handheld: 111 case NPadControllerType::Handheld:
115 controller.joy_styles.handheld.Assign(1); 112 controller.joy_styles.handheld.Assign(1);
@@ -197,8 +194,7 @@ void Controller_NPad::OnInit() {
197 194
198 std::transform( 195 std::transform(
199 Settings::values.players.begin(), Settings::values.players.end(), 196 Settings::values.players.begin(), Settings::values.players.end(),
200 connected_controllers.begin(), [](const Settings::PlayerInput& player) 197 connected_controllers.begin(), [](const Settings::PlayerInput& player) {
201 {
202 return ControllerHolder{MapSettingsTypeToNPad(player.type), player.connected}; 198 return ControllerHolder{MapSettingsTypeToNPad(player.type), player.connected};
203 }); 199 });
204 200
@@ -242,8 +238,7 @@ void Controller_NPad::OnLoadInputDevices() {
242 } 238 }
243} 239}
244 240
245void Controller_NPad::OnRelease() { 241void Controller_NPad::OnRelease() {}
246}
247 242
248void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { 243void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
249 const auto controller_idx = NPadIdToIndex(npad_id); 244 const auto controller_idx = NPadIdToIndex(npad_id);
@@ -281,31 +276,27 @@ void Controller_NPad::RequestPadStateUpdate(u32 npad_id) {
281 pad_state.d_down.Assign(button_state[DDown - BUTTON_HID_BEGIN]->GetStatus()); 276 pad_state.d_down.Assign(button_state[DDown - BUTTON_HID_BEGIN]->GetStatus());
282 277
283 pad_state.l_stick_right.Assign( 278 pad_state.l_stick_right.Assign(
284 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]-> 279 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
285 GetAnalogDirectionStatus(
286 Input::AnalogDirection::RIGHT)); 280 Input::AnalogDirection::RIGHT));
287 pad_state.l_stick_left.Assign( 281 pad_state.l_stick_left.Assign(
288 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]-> 282 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
289 GetAnalogDirectionStatus(
290 Input::AnalogDirection::LEFT)); 283 Input::AnalogDirection::LEFT));
291 pad_state.l_stick_up.Assign( 284 pad_state.l_stick_up.Assign(
292 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]-> 285 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
293 GetAnalogDirectionStatus(
294 Input::AnalogDirection::UP)); 286 Input::AnalogDirection::UP));
295 pad_state.l_stick_down.Assign( 287 pad_state.l_stick_down.Assign(
296 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]-> 288 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetAnalogDirectionStatus(
297 GetAnalogDirectionStatus(
298 Input::AnalogDirection::DOWN)); 289 Input::AnalogDirection::DOWN));
299 290
300 pad_state.r_stick_right.Assign( 291 pad_state.r_stick_right.Assign(
301 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] 292 analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
302 ->GetAnalogDirectionStatus(Input::AnalogDirection::RIGHT)); 293 ->GetAnalogDirectionStatus(Input::AnalogDirection::RIGHT));
303 pad_state.r_stick_left.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] 294 pad_state.r_stick_left.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
304 ->GetAnalogDirectionStatus(Input::AnalogDirection::LEFT)); 295 ->GetAnalogDirectionStatus(Input::AnalogDirection::LEFT));
305 pad_state.r_stick_up.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] 296 pad_state.r_stick_up.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
306 ->GetAnalogDirectionStatus(Input::AnalogDirection::UP)); 297 ->GetAnalogDirectionStatus(Input::AnalogDirection::UP));
307 pad_state.r_stick_down.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)] 298 pad_state.r_stick_down.Assign(analog_state[static_cast<std::size_t>(JoystickId::Joystick_Right)]
308 ->GetAnalogDirectionStatus(Input::AnalogDirection::DOWN)); 299 ->GetAnalogDirectionStatus(Input::AnalogDirection::DOWN));
309 300
310 pad_state.left_sl.Assign(button_state[SL - BUTTON_HID_BEGIN]->GetStatus()); 301 pad_state.left_sl.Assign(button_state[SL - BUTTON_HID_BEGIN]->GetStatus());
311 pad_state.left_sr.Assign(button_state[SR - BUTTON_HID_BEGIN]->GetStatus()); 302 pad_state.left_sr.Assign(button_state[SR - BUTTON_HID_BEGIN]->GetStatus());
@@ -372,7 +363,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
372 363
373 switch (controller_type) { 364 switch (controller_type) {
374 case NPadControllerType::None: 365 case NPadControllerType::None:
375 UNREACHABLE(); 366 UNREACHABLE();
376 break; 367 break;
377 case NPadControllerType::Handheld: 368 case NPadControllerType::Handheld:
378 handheld_entry.connection_status.raw = 0; 369 handheld_entry.connection_status.raw = 0;
@@ -468,9 +459,8 @@ void Controller_NPad::SetSupportedNPadIdTypes(u8* data, std::size_t length) {
468 continue; 459 continue;
469 } 460 }
470 const auto requested_controller = 461 const auto requested_controller =
471 i <= MAX_NPAD_ID 462 i <= MAX_NPAD_ID ? MapSettingsTypeToNPad(Settings::values.players[i].type)
472 ? MapSettingsTypeToNPad(Settings::values.players[i].type) 463 : NPadControllerType::Handheld;
473 : NPadControllerType::Handheld;
474 if (!IsControllerSupported(requested_controller)) { 464 if (!IsControllerSupported(requested_controller)) {
475 const auto is_handheld = requested_controller == NPadControllerType::Handheld; 465 const auto is_handheld = requested_controller == NPadControllerType::Handheld;
476 if (is_handheld) { 466 if (is_handheld) {
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp
index d42261d61..dc04116ce 100644
--- a/src/input_common/gcadapter/gc_adapter.cpp
+++ b/src/input_common/gcadapter/gc_adapter.cpp
@@ -1,7 +1,7 @@
1// Copyright 2014 Dolphin Emulator Project 1// Copyright 2014 Dolphin Emulator Project
2// Licensed under GPLv2+ 2// Licensed under GPLv2+
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4//* 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "common/threadsafe_queue.h" 6#include "common/threadsafe_queue.h"
7#include "input_common/gcadapter/gc_adapter.h" 7#include "input_common/gcadapter/gc_adapter.h"
@@ -45,35 +45,48 @@ GCPadStatus CheckStatus(int port, u8 adapter_payload[37]) {
45 u8 b1 = adapter_payload[1 + (9 * port) + 1]; 45 u8 b1 = adapter_payload[1 + (9 * port) + 1];
46 u8 b2 = adapter_payload[1 + (9 * port) + 2]; 46 u8 b2 = adapter_payload[1 + (9 * port) + 2];
47 47
48 if (b1 & (1 << 0)) 48 if (b1 & (1 << 0)) {
49 pad.button |= PAD_BUTTON_A; 49 pad.button |= PAD_BUTTON_A;
50 if (b1 & (1 << 1)) 50 }
51 if (b1 & (1 << 1)) {
51 pad.button |= PAD_BUTTON_B; 52 pad.button |= PAD_BUTTON_B;
52 if (b1 & (1 << 2)) 53 }
54 if (b1 & (1 << 2)) {
53 pad.button |= PAD_BUTTON_X; 55 pad.button |= PAD_BUTTON_X;
54 if (b1 & (1 << 3)) 56 }
57 if (b1 & (1 << 3)) {
55 pad.button |= PAD_BUTTON_Y; 58 pad.button |= PAD_BUTTON_Y;
59 }
56 60
57 if (b1 & (1 << 4)) 61 if (b1 & (1 << 4)) {
58 pad.button |= PAD_BUTTON_LEFT; 62 pad.button |= PAD_BUTTON_LEFT;
59 if (b1 & (1 << 5)) 63 }
64 if (b1 & (1 << 5)) {
60 pad.button |= PAD_BUTTON_RIGHT; 65 pad.button |= PAD_BUTTON_RIGHT;
61 if (b1 & (1 << 6)) 66 }
67 if (b1 & (1 << 6)) {
62 pad.button |= PAD_BUTTON_DOWN; 68 pad.button |= PAD_BUTTON_DOWN;
63 if (b1 & (1 << 7)) 69 }
70 if (b1 & (1 << 7)) {
64 pad.button |= PAD_BUTTON_UP; 71 pad.button |= PAD_BUTTON_UP;
72 }
65 73
66 if (b2 & (1 << 0)) 74 if (b2 & (1 << 0)) {
67 pad.button |= PAD_BUTTON_START; 75 pad.button |= PAD_BUTTON_START;
68 if (b2 & (1 << 1)) 76 }
77 if (b2 & (1 << 1)) {
69 pad.button |= PAD_TRIGGER_Z; 78 pad.button |= PAD_TRIGGER_Z;
70 if (b2 & (1 << 2)) 79 }
80 if (b2 & (1 << 2)) {
71 pad.button |= PAD_TRIGGER_R; 81 pad.button |= PAD_TRIGGER_R;
72 if (b2 & (1 << 3)) 82 }
83 if (b2 & (1 << 3)) {
73 pad.button |= PAD_TRIGGER_L; 84 pad.button |= PAD_TRIGGER_L;
85 }
74 86
75 if (get_origin) 87 if (get_origin) {
76 pad.button |= PAD_GET_ORIGIN; 88 pad.button |= PAD_GET_ORIGIN;
89 }
77 90
78 pad.stickX = adapter_payload[1 + (9 * port) + 3]; 91 pad.stickX = adapter_payload[1 + (9 * port) + 3];
79 pad.stickY = adapter_payload[1 + (9 * port) + 4]; 92 pad.stickY = adapter_payload[1 + (9 * port) + 4];
@@ -86,7 +99,7 @@ GCPadStatus CheckStatus(int port, u8 adapter_payload[37]) {
86} 99}
87 100
88void PadToState(GCPadStatus pad, GCState& state) { 101void PadToState(GCPadStatus pad, GCState& state) {
89 //std::lock_guard lock{s_mutex}; 102 // std::lock_guard lock{s_mutex};
90 state.buttons.insert_or_assign(PAD_BUTTON_A, pad.button & PAD_BUTTON_A); 103 state.buttons.insert_or_assign(PAD_BUTTON_A, pad.button & PAD_BUTTON_A);
91 state.buttons.insert_or_assign(PAD_BUTTON_B, pad.button & PAD_BUTTON_B); 104 state.buttons.insert_or_assign(PAD_BUTTON_B, pad.button & PAD_BUTTON_B);
92 state.buttons.insert_or_assign(PAD_BUTTON_X, pad.button & PAD_BUTTON_X); 105 state.buttons.insert_or_assign(PAD_BUTTON_X, pad.button & PAD_BUTTON_X);
@@ -125,7 +138,7 @@ static void Read() {
125 std::begin(controller_payload_copy)); 138 std::begin(controller_payload_copy));
126 payload_size = payload_size_in; 139 payload_size = payload_size_in;
127 } 140 }
128 141
129 GCPadStatus pad[4]; 142 GCPadStatus pad[4];
130 if (payload_size != sizeof(controller_payload_copy) || 143 if (payload_size != sizeof(controller_payload_copy) ||
131 controller_payload_copy[0] != LIBUSB_DT_HID) { 144 controller_payload_copy[0] != LIBUSB_DT_HID) {
@@ -137,8 +150,9 @@ static void Read() {
137 } 150 }
138 for (int port = 0; port < 4; port++) { 151 for (int port = 0; port < 4; port++) {
139 if (DeviceConnected(port) && configuring) { 152 if (DeviceConnected(port) && configuring) {
140 if (pad[port].button != PAD_GET_ORIGIN) 153 if (pad[port].button != PAD_GET_ORIGIN) {
141 pad_queue[port].Push(pad[port]); 154 pad_queue[port].Push(pad[port]);
155 }
142 156
143 // Accounting for a threshold here because of some controller variance 157 // Accounting for a threshold here because of some controller variance
144 if (pad[port].stickX > pad[port].MAIN_STICK_CENTER_X + pad[port].THRESHOLD || 158 if (pad[port].stickX > pad[port].MAIN_STICK_CENTER_X + pad[port].THRESHOLD ||
@@ -186,8 +200,9 @@ static void ScanThreadFunc() {
186 200
187void Init() { 201void Init() {
188 202
189 if (usb_adapter_handle != nullptr) 203 if (usb_adapter_handle != nullptr) {
190 return; 204 return;
205 }
191 LOG_INFO(Input, "GC Adapter Initialization started"); 206 LOG_INFO(Input, "GC Adapter Initialization started");
192 207
193 current_status = NO_ADAPTER_DETECTED; 208 current_status = NO_ADAPTER_DETECTED;
@@ -197,10 +212,12 @@ void Init() {
197} 212}
198 213
199void StartScanThread() { 214void StartScanThread() {
200 if (detect_thread_running) 215 if (detect_thread_running) {
201 return; 216 return;
202 if (!libusb_ctx) 217 }
218 if (!libusb_ctx) {
203 return; 219 return;
220 }
204 221
205 detect_thread_running = true; 222 detect_thread_running = true;
206 detect_thread = std::thread(ScanThreadFunc); 223 detect_thread = std::thread(ScanThreadFunc);
@@ -212,15 +229,17 @@ void StopScanThread() {
212 229
213static void Setup() { 230static void Setup() {
214 // Reset the error status in case the adapter gets unplugged 231 // Reset the error status in case the adapter gets unplugged
215 if (current_status < 0) 232 if (current_status < 0) {
216 current_status = NO_ADAPTER_DETECTED; 233 current_status = NO_ADAPTER_DETECTED;
234 }
217 235
218 for (int i = 0; i < 4; i++) 236 for (int i = 0; i < 4; i++) {
219 adapter_controllers_status[i] = ControllerTypes::CONTROLLER_NONE; 237 adapter_controllers_status[i] = ControllerTypes::CONTROLLER_NONE;
220 238 }
239
221 libusb_device** devs; // pointer to list of connected usb devices 240 libusb_device** devs; // pointer to list of connected usb devices
222 241
223 int cnt = libusb_get_device_list(libusb_ctx, &devs); //get the list of devices 242 int cnt = libusb_get_device_list(libusb_ctx, &devs); // get the list of devices
224 243
225 for (int i = 0; i < cnt; i++) { 244 for (int i = 0; i < cnt; i++) {
226 if (CheckDeviceAccess(devs[i])) { 245 if (CheckDeviceAccess(devs[i])) {
@@ -247,9 +266,8 @@ static bool CheckDeviceAccess(libusb_device* device) {
247 ret = libusb_open(device, &usb_adapter_handle); 266 ret = libusb_open(device, &usb_adapter_handle);
248 267
249 if (ret == LIBUSB_ERROR_ACCESS) { 268 if (ret == LIBUSB_ERROR_ACCESS) {
250 LOG_ERROR(Input, 269 LOG_ERROR(Input, "Yuzu can not gain access to this device: ID %04X:%04X.", desc.idVendor,
251 "Yuzu can not gain access to this device: ID %04X:%04X.", 270 desc.idProduct);
252 desc.idVendor, desc.idProduct);
253 return false; 271 return false;
254 } 272 }
255 if (ret) { 273 if (ret) {
@@ -260,8 +278,9 @@ static bool CheckDeviceAccess(libusb_device* device) {
260 ret = libusb_kernel_driver_active(usb_adapter_handle, 0); 278 ret = libusb_kernel_driver_active(usb_adapter_handle, 0);
261 if (ret == 1) { 279 if (ret == 1) {
262 ret = libusb_detach_kernel_driver(usb_adapter_handle, 0); 280 ret = libusb_detach_kernel_driver(usb_adapter_handle, 0);
263 if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) 281 if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) {
264 LOG_ERROR(Input, "libusb_detach_kernel_driver failed with error = %d", ret); 282 LOG_ERROR(Input, "libusb_detach_kernel_driver failed with error = %d", ret);
283 }
265 } 284 }
266 285
267 if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) { 286 if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) {
@@ -290,8 +309,9 @@ static void GetGCEndpoint(libusb_device* device) {
290 const libusb_interface_descriptor* interface = &interfaceContainer->altsetting[i]; 309 const libusb_interface_descriptor* interface = &interfaceContainer->altsetting[i];
291 for (u8 e = 0; e < interface->bNumEndpoints; e++) { 310 for (u8 e = 0; e < interface->bNumEndpoints; e++) {
292 const libusb_endpoint_descriptor* endpoint = &interface->endpoint[e]; 311 const libusb_endpoint_descriptor* endpoint = &interface->endpoint[e];
293 if (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) 312 if (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) {
294 input_endpoint = endpoint->bEndpointAddress; 313 input_endpoint = endpoint->bEndpointAddress;
314 }
295 } 315 }
296 } 316 }
297 } 317 }
@@ -311,16 +331,20 @@ void Shutdown() {
311 331
312static void Reset() { 332static void Reset() {
313 std::unique_lock<std::mutex> lock(initialization_mutex, std::defer_lock); 333 std::unique_lock<std::mutex> lock(initialization_mutex, std::defer_lock);
314 if (!lock.try_lock()) 334 if (!lock.try_lock()) {
315 return; 335 return;
316 if (current_status != ADAPTER_DETECTED) 336 }
337 if (current_status != ADAPTER_DETECTED) {
317 return; 338 return;
339 }
318 340
319 if (adapter_thread_running) 341 if (adapter_thread_running) {
320 adapter_input_thread.join(); 342 adapter_input_thread.join();
343 }
321 344
322 for (int i = 0; i < 4; i++) 345 for (int i = 0; i < 4; i++) {
323 adapter_controllers_status[i] = ControllerTypes::CONTROLLER_NONE; 346 adapter_controllers_status[i] = ControllerTypes::CONTROLLER_NONE;
347 }
324 348
325 current_status = NO_ADAPTER_DETECTED; 349 current_status = NO_ADAPTER_DETECTED;
326 350
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h
index 9b02d1382..05ee73c65 100644
--- a/src/input_common/gcadapter/gc_adapter.h
+++ b/src/input_common/gcadapter/gc_adapter.h
@@ -1,11 +1,14 @@
1// Copyright 2014 Dolphin Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
1#pragma once 5#pragma once
2#include <algorithm> 6#include <algorithm>
3#include <libusb.h>
4#include <mutex>
5#include <functional> 7#include <functional>
8#include <mutex>
9#include <libusb.h>
6#include "common/common_types.h" 10#include "common/common_types.h"
7 11
8
9enum { 12enum {
10 PAD_USE_ORIGIN = 0x0080, 13 PAD_USE_ORIGIN = 0x0080,
11 PAD_GET_ORIGIN = 0x2000, 14 PAD_GET_ORIGIN = 0x2000,
@@ -61,13 +64,8 @@ struct GCState {
61 std::unordered_map<int, u16> axes; 64 std::unordered_map<int, u16> axes;
62}; 65};
63 66
64
65namespace GCAdapter { 67namespace GCAdapter {
66enum ControllerTypes { 68enum ControllerTypes { CONTROLLER_NONE = 0, CONTROLLER_WIRED = 1, CONTROLLER_WIRELESS = 2 };
67 CONTROLLER_NONE = 0,
68 CONTROLLER_WIRED = 1,
69 CONTROLLER_WIRELESS = 2
70};
71 69
72enum { 70enum {
73 NO_ADAPTER_DETECTED = 0, 71 NO_ADAPTER_DETECTED = 0,
diff --git a/src/input_common/gcadapter/gc_poller.cpp b/src/input_common/gcadapter/gc_poller.cpp
index 772bd8890..51b3362d6 100644
--- a/src/input_common/gcadapter/gc_poller.cpp
+++ b/src/input_common/gcadapter/gc_poller.cpp
@@ -1,10 +1,14 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
1#include <atomic> 5#include <atomic>
2#include <list> 6#include <list>
3#include <mutex> 7#include <mutex>
4#include <utility> 8#include <utility>
5#include "input_common/gcadapter/gc_poller.h"
6#include "input_common/gcadapter/gc_adapter.h"
7#include "common/threadsafe_queue.h" 9#include "common/threadsafe_queue.h"
10#include "input_common/gcadapter/gc_adapter.h"
11#include "input_common/gcadapter/gc_poller.h"
8 12
9// Using extern as to avoid multply defined symbols. 13// Using extern as to avoid multply defined symbols.
10extern Common::SPSCQueue<GCPadStatus> pad_queue[4]; 14extern Common::SPSCQueue<GCPadStatus> pad_queue[4];
@@ -14,9 +18,7 @@ namespace InputCommon {
14 18
15class GCButton final : public Input::ButtonDevice { 19class GCButton final : public Input::ButtonDevice {
16public: 20public:
17 explicit GCButton(int port_, int button_, int axis_) 21 explicit GCButton(int port_, int button_, int axis_) : port(port_), button(button_) {}
18 : port(port_), button(button_) {
19 }
20 22
21 ~GCButton() override; 23 ~GCButton() override;
22 24
@@ -31,17 +33,14 @@ private:
31 33
32class GCAxisButton final : public Input::ButtonDevice { 34class GCAxisButton final : public Input::ButtonDevice {
33public: 35public:
34 explicit GCAxisButton(int port_, int axis_, float threshold_, 36 explicit GCAxisButton(int port_, int axis_, float threshold_, bool trigger_if_greater_)
35 bool trigger_if_greater_) 37 : port(port_), axis(axis_), threshold(threshold_), trigger_if_greater(trigger_if_greater_) {
36 : port(port_), axis(axis_), threshold(threshold_),
37 trigger_if_greater(trigger_if_greater_) {
38 } 38 }
39 39
40
41 bool GetStatus() const override { 40 bool GetStatus() const override {
42 const float axis_value = (state[port].axes.at(axis) - 128.0f) / 128.0f; 41 const float axis_value = (state[port].axes.at(axis) - 128.0f) / 128.0f;
43 if (trigger_if_greater) { 42 if (trigger_if_greater) {
44 return axis_value > 0.10f; //TODO(ameerj) : Fix threshold. 43 return axis_value > 0.10f; // TODO(ameerj) : Fix threshold.
45 } 44 }
46 return axis_value < -0.10f; 45 return axis_value < -0.10f;
47 } 46 }
@@ -164,29 +163,30 @@ Common::ParamPackage GCButtonFactory::GetNextInput() {
164 163
165void GCButtonFactory::BeginConfiguration() { 164void GCButtonFactory::BeginConfiguration() {
166 polling = true; 165 polling = true;
167 for (int i = 0; i < 4; i++) 166 for (int i = 0; i < 4; i++) {
168 pad_queue[i].Clear(); 167 pad_queue[i].Clear();
168 }
169 GCAdapter::BeginConfiguration(); 169 GCAdapter::BeginConfiguration();
170} 170}
171 171
172void GCButtonFactory::EndConfiguration() { 172void GCButtonFactory::EndConfiguration() {
173 polling = false; 173 polling = false;
174 174 for (int i = 0; i < 4; i++) {
175 for (int i = 0; i < 4; i++)
176 pad_queue[i].Clear(); 175 pad_queue[i].Clear();
176 }
177 GCAdapter::EndConfiguration(); 177 GCAdapter::EndConfiguration();
178} 178}
179 179
180class GCAnalog final : public Input::AnalogDevice { 180class GCAnalog final : public Input::AnalogDevice {
181public: 181public:
182 GCAnalog(int port_, int axis_x_, int axis_y_, float deadzone_) 182 GCAnalog(int port_, int axis_x_, int axis_y_, float deadzone_)
183 : port(port_), axis_x(axis_x_), axis_y(axis_y_), deadzone(deadzone_) { 183 : port(port_), axis_x(axis_x_), axis_y(axis_y_), deadzone(deadzone_) {}
184 }
185 184
186 float GetAxis(int axis) const { 185 float GetAxis(int axis) const {
187 std::lock_guard lock{mutex}; 186 std::lock_guard lock{mutex};
188 // division is not by a perfect 128 to account for some variance in center location 187 // division is not by a perfect 128 to account for some variance in center location
189 // e.g. my device idled at 131 in X, 120 in Y, and full range of motion was in range [20-230] 188 // e.g. my device idled at 131 in X, 120 in Y, and full range of motion was in range
189 // [20-230]
190 return (state[port].axes.at(axis) - 128.0f) / 95.0f; 190 return (state[port].axes.at(axis) - 128.0f) / 95.0f;
191 } 191 }
192 192
@@ -240,18 +240,16 @@ private:
240 mutable std::mutex mutex; 240 mutable std::mutex mutex;
241}; 241};
242 242
243
244/// An analog device factory that creates analog devices from GC Adapter 243/// An analog device factory that creates analog devices from GC Adapter
245GCAnalogFactory::GCAnalogFactory() {}; 244GCAnalogFactory::GCAnalogFactory(){};
246
247 245
248/** 246/**
249* Creates analog device from joystick axes 247 * Creates analog device from joystick axes
250* @param params contains parameters for creating the device: 248 * @param params contains parameters for creating the device:
251* - "port": the nth gcpad on the adapter 249 * - "port": the nth gcpad on the adapter
252* - "axis_x": the index of the axis to be bind as x-axis 250 * - "axis_x": the index of the axis to be bind as x-axis
253* - "axis_y": the index of the axis to be bind as y-axis 251 * - "axis_y": the index of the axis to be bind as y-axis
254*/ 252 */
255std::unique_ptr<Input::AnalogDevice> GCAnalogFactory::Create(const Common::ParamPackage& params) { 253std::unique_ptr<Input::AnalogDevice> GCAnalogFactory::Create(const Common::ParamPackage& params) {
256 const std::string guid = params.Get("guid", "0"); 254 const std::string guid = params.Get("guid", "0");
257 const int port = params.Get("port", 0); 255 const int port = params.Get("port", 0);
@@ -264,15 +262,17 @@ std::unique_ptr<Input::AnalogDevice> GCAnalogFactory::Create(const Common::Param
264 262
265void GCAnalogFactory::BeginConfiguration() { 263void GCAnalogFactory::BeginConfiguration() {
266 polling = true; 264 polling = true;
267 for (int i = 0; i < 4; i++) 265 for (int i = 0; i < 4; i++) {
268 pad_queue[i].Clear(); 266 pad_queue[i].Clear();
267 }
269 GCAdapter::BeginConfiguration(); 268 GCAdapter::BeginConfiguration();
270} 269}
271 270
272void GCAnalogFactory::EndConfiguration() { 271void GCAnalogFactory::EndConfiguration() {
273 polling = false; 272 polling = false;
274 for (int i = 0; i < 4; i++) 273 for (int i = 0; i < 4; i++) {
275 pad_queue[i].Clear(); 274 pad_queue[i].Clear();
275 }
276 GCAdapter::EndConfiguration(); 276 GCAdapter::EndConfiguration();
277} 277}
278 278
diff --git a/src/input_common/gcadapter/gc_poller.h b/src/input_common/gcadapter/gc_poller.h
index d115b1d2a..43aa9e93a 100644
--- a/src/input_common/gcadapter/gc_poller.h
+++ b/src/input_common/gcadapter/gc_poller.h
@@ -1,3 +1,7 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
1#pragma once 5#pragma once
2 6
3#include <memory> 7#include <memory>
@@ -5,7 +9,6 @@
5 9
6namespace InputCommon { 10namespace InputCommon {
7 11
8
9/** 12/**
10 * A button device factory representing a gcpad. It receives gcpad events and forward them 13 * A button device factory representing a gcpad. It receives gcpad events and forward them
11 * to all button devices it created. 14 * to all button devices it created.
diff --git a/src/input_common/main.h b/src/input_common/main.h
index be2e7a6c4..9e1528c88 100644
--- a/src/input_common/main.h
+++ b/src/input_common/main.h
@@ -7,8 +7,8 @@
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9#include <vector> 9#include <vector>
10#include "input_common/gcadapter/gc_poller.h"
11#include "input_common/gcadapter/gc_adapter.h" 10#include "input_common/gcadapter/gc_adapter.h"
11#include "input_common/gcadapter/gc_poller.h"
12 12
13namespace Common { 13namespace Common {
14class ParamPackage; 14class ParamPackage;
@@ -38,7 +38,6 @@ class GCAnalogFactory;
38GCButtonFactory* GetGCButtons(); 38GCButtonFactory* GetGCButtons();
39GCAnalogFactory* GetGCAnalogs(); 39GCAnalogFactory* GetGCAnalogs();
40 40
41
42/// Generates a serialized param package for creating a keyboard button device 41/// Generates a serialized param package for creating a keyboard button device
43std::string GenerateKeyboardParam(int key_code); 42std::string GenerateKeyboardParam(int key_code);
44 43
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index da5227058..4c9794ce2 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -225,8 +225,7 @@ void TestCommunication(const std::string& host, u16 port, u8 pad_index, u32 clie
225 } else { 225 } else {
226 failure_callback(); 226 failure_callback();
227 } 227 }
228 }) 228 }).detach();
229 .detach();
230} 229}
231 230
232CalibrationConfigurationJob::CalibrationConfigurationJob( 231CalibrationConfigurationJob::CalibrationConfigurationJob(
@@ -280,8 +279,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob(
280 complete_event.Wait(); 279 complete_event.Wait();
281 socket.Stop(); 280 socket.Stop();
282 worker_thread.join(); 281 worker_thread.join();
283 }) 282 }).detach();
284 .detach();
285} 283}
286 284
287CalibrationConfigurationJob::~CalibrationConfigurationJob() { 285CalibrationConfigurationJob::~CalibrationConfigurationJob() {
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 81436af1b..c1a0c423b 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -19,13 +19,13 @@
19#include "yuzu/configuration/configure_input_player.h" 19#include "yuzu/configuration/configure_input_player.h"
20 20
21const std::array<std::string, ConfigureInputPlayer::ANALOG_SUB_BUTTONS_NUM> 21const std::array<std::string, ConfigureInputPlayer::ANALOG_SUB_BUTTONS_NUM>
22ConfigureInputPlayer::analog_sub_buttons{{ 22 ConfigureInputPlayer::analog_sub_buttons{{
23 "up", 23 "up",
24 "down", 24 "down",
25 "left", 25 "left",
26 "right", 26 "right",
27 "modifier", 27 "modifier",
28}}; 28 }};
29 29
30static void LayerGridElements(QGridLayout* grid, QWidget* item, QWidget* onTopOf) { 30static void LayerGridElements(QGridLayout* grid, QWidget* item, QWidget* onTopOf) {
31 const int index1 = grid->indexOf(item); 31 const int index1 = grid->indexOf(item);
@@ -151,13 +151,13 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
151 setFocusPolicy(Qt::ClickFocus); 151 setFocusPolicy(Qt::ClickFocus);
152 152
153 button_map = { 153 button_map = {
154 ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY, 154 ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY,
155 ui->buttonLStick, ui->buttonRStick, ui->buttonL, ui->buttonR, 155 ui->buttonLStick, ui->buttonRStick, ui->buttonL, ui->buttonR,
156 ui->buttonZL, ui->buttonZR, ui->buttonPlus, ui->buttonMinus, 156 ui->buttonZL, ui->buttonZR, ui->buttonPlus, ui->buttonMinus,
157 ui->buttonDpadLeft, ui->buttonDpadUp, ui->buttonDpadRight, ui->buttonDpadDown, 157 ui->buttonDpadLeft, ui->buttonDpadUp, ui->buttonDpadRight, ui->buttonDpadDown,
158 ui->buttonLStickLeft, ui->buttonLStickUp, ui->buttonLStickRight, ui->buttonLStickDown, 158 ui->buttonLStickLeft, ui->buttonLStickUp, ui->buttonLStickRight, ui->buttonLStickDown,
159 ui->buttonRStickLeft, ui->buttonRStickUp, ui->buttonRStickRight, ui->buttonRStickDown, 159 ui->buttonRStickLeft, ui->buttonRStickUp, ui->buttonRStickRight, ui->buttonRStickDown,
160 ui->buttonSL, ui->buttonSR, ui->buttonHome, ui->buttonScreenshot, 160 ui->buttonSL, ui->buttonSR, ui->buttonHome, ui->buttonScreenshot,
161 }; 161 };
162 162
163 analog_map_buttons = {{ 163 analog_map_buttons = {{
@@ -178,11 +178,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
178 }}; 178 }};
179 179
180 debug_hidden = { 180 debug_hidden = {
181 ui->buttonSL, ui->labelSL, 181 ui->buttonSL, ui->labelSL,
182 ui->buttonSR, ui->labelSR, 182 ui->buttonSR, ui->labelSR,
183 ui->buttonLStick, ui->labelLStickPressed, 183 ui->buttonLStick, ui->labelLStickPressed,
184 ui->buttonRStick, ui->labelRStickPressed, 184 ui->buttonRStick, ui->labelRStickPressed,
185 ui->buttonHome, ui->labelHome, 185 ui->buttonHome, ui->labelHome,
186 ui->buttonScreenshot, ui->labelScreenshot, 186 ui->buttonScreenshot, ui->labelScreenshot,
187 }; 187 };
188 188
@@ -221,12 +221,12 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
221 case Settings::ControllerType::RightJoycon: 221 case Settings::ControllerType::RightJoycon:
222 layout_hidden = { 222 layout_hidden = {
223 ui->left_body_button, ui->left_buttons_button, 223 ui->left_body_button, ui->left_buttons_button,
224 ui->left_body_label, ui->left_buttons_label, 224 ui->left_body_label, ui->left_buttons_label,
225 ui->buttonL, ui->labelL, 225 ui->buttonL, ui->labelL,
226 ui->buttonZL, ui->labelZL, 226 ui->buttonZL, ui->labelZL,
227 ui->labelScreenshot, ui->buttonScreenshot, 227 ui->labelScreenshot, ui->buttonScreenshot,
228 ui->buttonMinus, ui->labelMinus, 228 ui->buttonMinus, ui->labelMinus,
229 ui->LStick, ui->Dpad, 229 ui->LStick, ui->Dpad,
230 }; 230 };
231 break; 231 break;
232 } 232 }
@@ -261,38 +261,34 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
261 } 261 }
262 262
263 button->setContextMenuPolicy(Qt::CustomContextMenu); 263 button->setContextMenuPolicy(Qt::CustomContextMenu);
264 connect(button, &QPushButton::clicked, [=] 264 connect(button, &QPushButton::clicked, [=] {
265 { 265 HandleClick(
266 HandleClick(button_map[button_id], 266 button_map[button_id],
267 [=](Common::ParamPackage params) 267 [=](Common::ParamPackage params) {
268 { 268 // Workaround for ZL & ZR for analog triggers like on XBOX controllors.
269 // Workaround for ZL & ZR for analog triggers like on XBOX controllors. 269 // Analog triggers (from controllers like the XBOX controller) would not
270 // Analog triggers (from controllers like the XBOX controller) would not 270 // work due to a different range of their signals (from 0 to 255 on
271 // work due to a different range of their signals (from 0 to 255 on 271 // analog triggers instead of -32768 to 32768 on analog joysticks). The
272 // analog triggers instead of -32768 to 32768 on analog joysticks). The 272 // SDL driver misinterprets analog triggers as analog joysticks.
273 // SDL driver misinterprets analog triggers as analog joysticks. 273 // TODO: reinterpret the signal range for analog triggers to map the
274 // TODO: reinterpret the signal range for analog triggers to map the 274 // values correctly. This is required for the correct emulation of the
275 // values correctly. This is required for the correct emulation of the 275 // analog triggers of the GameCube controller.
276 // analog triggers of the GameCube controller. 276 if (button_id == Settings::NativeButton::ZL ||
277 if (button_id == Settings::NativeButton::ZL || 277 button_id == Settings::NativeButton::ZR) {
278 button_id == Settings::NativeButton::ZR) { 278 params.Set("direction", "+");
279 params.Set("direction", "+"); 279 params.Set("threshold", "0.5");
280 params.Set("threshold", "0.5"); 280 }
281 } 281 buttons_param[button_id] = std::move(params);
282 buttons_param[button_id] = std::move(params); 282 },
283 }, 283 InputCommon::Polling::DeviceType::Button);
284 InputCommon::Polling::DeviceType::Button);
285 }); 284 });
286 connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) 285 connect(button, &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
287 {
288 QMenu context_menu; 286 QMenu context_menu;
289 context_menu.addAction(tr("Clear"), [&] 287 context_menu.addAction(tr("Clear"), [&] {
290 {
291 buttons_param[button_id].Clear(); 288 buttons_param[button_id].Clear();
292 button_map[button_id]->setText(tr("[not set]")); 289 button_map[button_id]->setText(tr("[not set]"));
293 }); 290 });
294 context_menu.addAction(tr("Restore Default"), [&] 291 context_menu.addAction(tr("Restore Default"), [&] {
295 {
296 buttons_param[button_id] = Common::ParamPackage{ 292 buttons_param[button_id] = Common::ParamPackage{
297 InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])}; 293 InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
298 button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); 294 button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
@@ -309,27 +305,23 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
309 } 305 }
310 306
311 analog_button->setContextMenuPolicy(Qt::CustomContextMenu); 307 analog_button->setContextMenuPolicy(Qt::CustomContextMenu);
312 connect(analog_button, &QPushButton::clicked, [=]() 308 connect(analog_button, &QPushButton::clicked, [=]() {
313 { 309 HandleClick(
314 HandleClick(analog_map_buttons[analog_id][sub_button_id], 310 analog_map_buttons[analog_id][sub_button_id],
315 [=](const Common::ParamPackage& params) 311 [=](const Common::ParamPackage& params) {
316 { 312 SetAnalogButton(params, analogs_param[analog_id],
317 SetAnalogButton(params, analogs_param[analog_id], 313 analog_sub_buttons[sub_button_id]);
318 analog_sub_buttons[sub_button_id]); 314 },
319 }, 315 InputCommon::Polling::DeviceType::Button);
320 InputCommon::Polling::DeviceType::Button);
321 }); 316 });
322 connect(analog_button, &QPushButton::customContextMenuRequested, 317 connect(analog_button, &QPushButton::customContextMenuRequested,
323 [=](const QPoint& menu_location) 318 [=](const QPoint& menu_location) {
324 {
325 QMenu context_menu; 319 QMenu context_menu;
326 context_menu.addAction(tr("Clear"), [&] 320 context_menu.addAction(tr("Clear"), [&] {
327 {
328 analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); 321 analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
329 analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]")); 322 analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
330 }); 323 });
331 context_menu.addAction(tr("Restore Default"), [&] 324 context_menu.addAction(tr("Restore Default"), [&] {
332 {
333 Common::ParamPackage params{InputCommon::GenerateKeyboardParam( 325 Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
334 Config::default_analogs[analog_id][sub_button_id])}; 326 Config::default_analogs[analog_id][sub_button_id])};
335 SetAnalogButton(params, analogs_param[analog_id], 327 SetAnalogButton(params, analogs_param[analog_id],
@@ -341,12 +333,11 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
341 menu_location)); 333 menu_location));
342 }); 334 });
343 } 335 }
344 connect(analog_map_stick[analog_id], &QPushButton::clicked, [=] 336 connect(analog_map_stick[analog_id], &QPushButton::clicked, [=] {
345 {
346 if (QMessageBox::information( 337 if (QMessageBox::information(
347 this, tr("Information"), 338 this, tr("Information"),
348 tr("After pressing OK, first move your joystick horizontally, " 339 tr("After pressing OK, first move your joystick horizontally, "
349 "and then vertically."), 340 "and then vertically."),
350 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { 341 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
351 HandleClick( 342 HandleClick(
352 analog_map_stick[analog_id], 343 analog_map_stick[analog_id],
@@ -355,8 +346,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
355 } 346 }
356 }); 347 });
357 348
358 connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged, [=] 349 connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged, [=] {
359 {
360 const float slider_value = analog_map_deadzone_and_modifier_slider[analog_id]->value(); 350 const float slider_value = analog_map_deadzone_and_modifier_slider[analog_id]->value();
361 if (analogs_param[analog_id].Get("engine", "") == "sdl" || 351 if (analogs_param[analog_id].Get("engine", "") == "sdl" ||
362 analogs_param[analog_id].Get("engine", "") == "gcpad") { 352 analogs_param[analog_id].Get("engine", "") == "gcpad") {
@@ -377,8 +367,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
377 timeout_timer->setSingleShot(true); 367 timeout_timer->setSingleShot(true);
378 connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); }); 368 connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); });
379 369
380 connect(poll_timer.get(), &QTimer::timeout, [this] 370 connect(poll_timer.get(), &QTimer::timeout, [this] {
381 {
382 Common::ParamPackage params; 371 Common::ParamPackage params;
383 if (InputCommon::GetGCButtons()->IsPolling()) { 372 if (InputCommon::GetGCButtons()->IsPolling()) {
384 params = InputCommon::GetGCButtons()->GetNextInput(); 373 params = InputCommon::GetGCButtons()->GetNextInput();
@@ -505,7 +494,7 @@ void ConfigureInputPlayer::LoadConfiguration() {
505 for (std::size_t i = 0; i < colors.size(); ++i) { 494 for (std::size_t i = 0; i < colors.size(); ++i) {
506 controller_color_buttons[i]->setStyleSheet( 495 controller_color_buttons[i]->setStyleSheet(
507 QStringLiteral("QPushButton { background-color: %1 }") 496 QStringLiteral("QPushButton { background-color: %1 }")
508 .arg(controller_colors[i].name())); 497 .arg(controller_colors[i].name()));
509 } 498 }
510} 499}
511 500
@@ -625,10 +614,11 @@ void ConfigureInputPlayer::HandleClick(
625 614
626 grabKeyboard(); 615 grabKeyboard();
627 grabMouse(); 616 grabMouse();
628 if (type == InputCommon::Polling::DeviceType::Button) 617 if (type == InputCommon::Polling::DeviceType::Button) {
629 InputCommon::GetGCButtons()->BeginConfiguration(); 618 InputCommon::GetGCButtons()->BeginConfiguration();
630 else 619 } else {
631 InputCommon::GetGCAnalogs()->BeginConfiguration(); 620 InputCommon::GetGCAnalogs()->BeginConfiguration();
621 }
632 timeout_timer->start(5000); // Cancel after 5 seconds 622 timeout_timer->start(5000); // Cancel after 5 seconds
633 poll_timer->start(200); // Check for new inputs every 200ms 623 poll_timer->start(200); // Check for new inputs every 200ms
634} 624}
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h
index dad2a80ec..95afa5375 100644
--- a/src/yuzu/configuration/configure_input_player.h
+++ b/src/yuzu/configuration/configure_input_player.h
@@ -31,7 +31,7 @@ class ConfigureInputPlayer;
31} 31}
32 32
33class ConfigureInputPlayer : public QDialog { 33class ConfigureInputPlayer : public QDialog {
34Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37 explicit ConfigureInputPlayer(QWidget* parent, std::size_t player_index, bool debug = false); 37 explicit ConfigureInputPlayer(QWidget* parent, std::size_t player_index, bool debug = false);
@@ -92,15 +92,15 @@ private:
92 /// A group of five QPushButtons represent one analog input. The buttons each represent up, 92 /// A group of five QPushButtons represent one analog input. The buttons each represent up,
93 /// down, left, right, and modifier, respectively. 93 /// down, left, right, and modifier, respectively.
94 std::array<std::array<QPushButton*, ANALOG_SUB_BUTTONS_NUM>, Settings::NativeAnalog::NumAnalogs> 94 std::array<std::array<QPushButton*, ANALOG_SUB_BUTTONS_NUM>, Settings::NativeAnalog::NumAnalogs>
95 analog_map_buttons; 95 analog_map_buttons;
96 96
97 /// Analog inputs are also represented each with a single button, used to configure with an 97 /// Analog inputs are also represented each with a single button, used to configure with an
98 /// actual analog stick 98 /// actual analog stick
99 std::array<QPushButton*, Settings::NativeAnalog::NumAnalogs> analog_map_stick; 99 std::array<QPushButton*, Settings::NativeAnalog::NumAnalogs> analog_map_stick;
100 std::array<QSlider*, Settings::NativeAnalog::NumAnalogs> 100 std::array<QSlider*, Settings::NativeAnalog::NumAnalogs>
101 analog_map_deadzone_and_modifier_slider; 101 analog_map_deadzone_and_modifier_slider;
102 std::array<QLabel*, Settings::NativeAnalog::NumAnalogs> 102 std::array<QLabel*, Settings::NativeAnalog::NumAnalogs>
103 analog_map_deadzone_and_modifier_slider_label; 103 analog_map_deadzone_and_modifier_slider_label;
104 104
105 static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons; 105 static const std::array<std::string, ANALOG_SUB_BUTTONS_NUM> analog_sub_buttons;
106 106