VERY experimental Nintendo Switch 2 emulator
C++
input_common: Fix issue where ring and irs are enabled at the same time
german774b7ad51ce345
diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cppindex 3c1fa2274f..1a6fa2a44c 100644--- a/src/core/hle/service/hid/irs.cpp+++ b/src/core/hle/service/hid/irs.cpp@@ -74,8 +74,6 @@ void IRS::DeactivateIrsensor(Kernel::HLERequestContext& ctx) {LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",applet_resource_user_id);- npad_device->SetPollingMode(Common::Input::PollingMode::Active);-IPC::ResponseBuilder rb{ctx, 2};rb.Push(ResultSuccess);}@@ -514,7 +512,7 @@ void IRS::StopImageProcessorAsync(Kernel::HLERequestContext& ctx) {auto result = IsIrCameraHandleValid(parameters.camera_handle);if (result.IsSuccess()) {// TODO: Stop image processor async- npad_device->SetPollingMode(Common::Input::PollingMode::IR);+ npad_device->SetPollingMode(Common::Input::PollingMode::Active);result = ResultSuccess;}diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cppindex 040832a4ba..e8aef028af 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.hindex 61ecf4a6c2..e8e65e1331 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 configurationu8 leds{};diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.cpp b/src/input_common/helpers/joycon_protocol/common_protocol.cppindex a329db1070..153a3908c6 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);