summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2023-01-03 05:11:03 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-01-20 01:05:22 +0100
commitd05ea2f3ebdf62e328d2edbfc5b9bc01e3453569 (patch)
tree5863733770eb47f15aa528438e47a1cab2e794b4 /src/input_common
parentinput_common: Implement joycon ir camera (diff)
downloadyuzu-d05ea2f3ebdf62e328d2edbfc5b9bc01e3453569.tar
yuzu-d05ea2f3ebdf62e328d2edbfc5b9bc01e3453569.tar.gz
yuzu-d05ea2f3ebdf62e328d2edbfc5b9bc01e3453569.tar.bz2
yuzu-d05ea2f3ebdf62e328d2edbfc5b9bc01e3453569.tar.lz
yuzu-d05ea2f3ebdf62e328d2edbfc5b9bc01e3453569.tar.xz
yuzu-d05ea2f3ebdf62e328d2edbfc5b9bc01e3453569.tar.zst
yuzu-d05ea2f3ebdf62e328d2edbfc5b9bc01e3453569.zip
Diffstat (limited to 'src/input_common')
-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() {
irs_protocol->DisableIrs();
}
+ if (nfc_protocol->IsEnabled()) {
+ amiibo_detected = false;
+ nfc_protocol->DisableNfc();
+ }
+
+ if (ring_protocol->IsEnabled()) {
+ ring_connected = false;
+ ring_protocol->DisableRingCon();
+ }
+
if (irs_enabled && supported_features.irs) {
auto result = irs_protocol->EnableIrs();
if (result == DriverResult::Success) {
@@ -272,11 +282,6 @@ DriverResult JoyconDriver::SetPollingMode() {
LOG_ERROR(Input, "Error enabling IRS");
}
- if (nfc_protocol->IsEnabled()) {
- amiibo_detected = false;
- nfc_protocol->DisableNfc();
- }
-
if (nfc_enabled && supported_features.nfc) {
auto result = nfc_protocol->EnableNfc();
if (result == DriverResult::Success) {
@@ -290,11 +295,6 @@ DriverResult JoyconDriver::SetPollingMode() {
LOG_ERROR(Input, "Error enabling NFC");
}
- if (ring_protocol->IsEnabled()) {
- ring_connected = false;
- ring_protocol->DisableRingCon();
- }
-
if (hidbus_enabled && supported_features.hidbus) {
auto result = ring_protocol->EnableRingCon();
if (result == DriverResult::Success) {
@@ -418,6 +418,12 @@ DriverResult JoyconDriver::SetPasiveMode() {
}
DriverResult JoyconDriver::SetActiveMode() {
+ if (is_ring_disabled_by_irs) {
+ is_ring_disabled_by_irs = false;
+ SetActiveMode();
+ return SetRingConMode();
+ }
+
std::scoped_lock lock{mutex};
motion_enabled = true;
hidbus_enabled = false;
@@ -434,6 +440,10 @@ DriverResult JoyconDriver::SetIrMode() {
return DriverResult::NotSupported;
}
+ if (ring_connected) {
+ is_ring_disabled_by_irs = true;
+ }
+
motion_enabled = false;
hidbus_enabled = false;
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:
bool starlink_connected{};
bool ring_connected{};
bool amiibo_detected{};
+ bool is_ring_disabled_by_irs{};
// Harware configuration
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) {
}
DriverResult JoyconCommonProtocol::GetSubCommandResponse(SubCommand sc, std::vector<u8>& output) {
- constexpr int timeout_mili = 100;
- constexpr int MaxTries = 10;
+ constexpr int timeout_mili = 66;
+ constexpr int MaxTries = 15;
int tries = 0;
output.resize(MaxSubCommandResponseSize);