summaryrefslogtreecommitdiff
path: root/src/input_common/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers')
-rw-r--r--src/input_common/helpers/joycon_driver.cpp30
-rw-r--r--src/input_common/helpers/joycon_driver.h1
-rw-r--r--src/input_common/helpers/joycon_protocol/common_protocol.cpp4
3 files changed, 23 insertions, 12 deletions
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp
index 040832a4b..e8aef028a 100644
--- a/src/input_common/helpers/joycon_driver.cpp
+++ b/src/input_common/helpers/joycon_driver.cpp
@@ -262,6 +262,16 @@ DriverResult JoyconDriver::SetPollingMode() {
262 irs_protocol->DisableIrs(); 262 irs_protocol->DisableIrs();
263 } 263 }
264 264
265 if (nfc_protocol->IsEnabled()) {
266 amiibo_detected = false;
267 nfc_protocol->DisableNfc();
268 }
269
270 if (ring_protocol->IsEnabled()) {
271 ring_connected = false;
272 ring_protocol->DisableRingCon();
273 }
274
265 if (irs_enabled && supported_features.irs) { 275 if (irs_enabled && supported_features.irs) {
266 auto result = irs_protocol->EnableIrs(); 276 auto result = irs_protocol->EnableIrs();
267 if (result == DriverResult::Success) { 277 if (result == DriverResult::Success) {
@@ -272,11 +282,6 @@ DriverResult JoyconDriver::SetPollingMode() {
272 LOG_ERROR(Input, "Error enabling IRS"); 282 LOG_ERROR(Input, "Error enabling IRS");
273 } 283 }
274 284
275 if (nfc_protocol->IsEnabled()) {
276 amiibo_detected = false;
277 nfc_protocol->DisableNfc();
278 }
279
280 if (nfc_enabled && supported_features.nfc) { 285 if (nfc_enabled && supported_features.nfc) {
281 auto result = nfc_protocol->EnableNfc(); 286 auto result = nfc_protocol->EnableNfc();
282 if (result == DriverResult::Success) { 287 if (result == DriverResult::Success) {
@@ -290,11 +295,6 @@ DriverResult JoyconDriver::SetPollingMode() {
290 LOG_ERROR(Input, "Error enabling NFC"); 295 LOG_ERROR(Input, "Error enabling NFC");
291 } 296 }
292 297
293 if (ring_protocol->IsEnabled()) {
294 ring_connected = false;
295 ring_protocol->DisableRingCon();
296 }
297
298 if (hidbus_enabled && supported_features.hidbus) { 298 if (hidbus_enabled && supported_features.hidbus) {
299 auto result = ring_protocol->EnableRingCon(); 299 auto result = ring_protocol->EnableRingCon();
300 if (result == DriverResult::Success) { 300 if (result == DriverResult::Success) {
@@ -418,6 +418,12 @@ DriverResult JoyconDriver::SetPasiveMode() {
418} 418}
419 419
420DriverResult JoyconDriver::SetActiveMode() { 420DriverResult JoyconDriver::SetActiveMode() {
421 if (is_ring_disabled_by_irs) {
422 is_ring_disabled_by_irs = false;
423 SetActiveMode();
424 return SetRingConMode();
425 }
426
421 std::scoped_lock lock{mutex}; 427 std::scoped_lock lock{mutex};
422 motion_enabled = true; 428 motion_enabled = true;
423 hidbus_enabled = false; 429 hidbus_enabled = false;
@@ -434,6 +440,10 @@ DriverResult JoyconDriver::SetIrMode() {
434 return DriverResult::NotSupported; 440 return DriverResult::NotSupported;
435 } 441 }
436 442
443 if (ring_connected) {
444 is_ring_disabled_by_irs = true;
445 }
446
437 motion_enabled = false; 447 motion_enabled = false;
438 hidbus_enabled = false; 448 hidbus_enabled = false;
439 nfc_enabled = false; 449 nfc_enabled = false;
diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h
index 61ecf4a6c..e8e65e133 100644
--- a/src/input_common/helpers/joycon_driver.h
+++ b/src/input_common/helpers/joycon_driver.h
@@ -107,6 +107,7 @@ private:
107 bool starlink_connected{}; 107 bool starlink_connected{};
108 bool ring_connected{}; 108 bool ring_connected{};
109 bool amiibo_detected{}; 109 bool amiibo_detected{};
110 bool is_ring_disabled_by_irs{};
110 111
111 // Harware configuration 112 // Harware configuration
112 u8 leds{}; 113 u8 leds{};
diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.cpp b/src/input_common/helpers/joycon_protocol/common_protocol.cpp
index a329db107..153a3908c 100644
--- a/src/input_common/helpers/joycon_protocol/common_protocol.cpp
+++ b/src/input_common/helpers/joycon_protocol/common_protocol.cpp
@@ -74,8 +74,8 @@ DriverResult JoyconCommonProtocol::SendData(std::span<const u8> buffer) {
74} 74}
75 75
76DriverResult JoyconCommonProtocol::GetSubCommandResponse(SubCommand sc, std::vector<u8>& output) { 76DriverResult JoyconCommonProtocol::GetSubCommandResponse(SubCommand sc, std::vector<u8>& output) {
77 constexpr int timeout_mili = 100; 77 constexpr int timeout_mili = 66;
78 constexpr int MaxTries = 10; 78 constexpr int MaxTries = 15;
79 int tries = 0; 79 int tries = 0;
80 output.resize(MaxSubCommandResponseSize); 80 output.resize(MaxSubCommandResponseSize);
81 81