diff options
author | german77 <juangerman-13@hotmail.com> | 2022-07-11 03:14:50 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2022-07-11 03:27:40 +0200 |
commit | 18550b165b24e8670cd3a72178c7161e06f9841e (patch) | |
tree | 166f76680bea8465fae8ece61dbbc3d51329bf4c /src | |
parent | Merge pull request #8528 from Morph1984/astc10x6 (diff) | |
download | yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar.gz yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar.bz2 yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar.lz yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar.xz yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar.zst yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hid/emulated_controller.cpp | 35 | ||||
-rw-r--r-- | src/core/hid/emulated_controller.h | 1 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index bd2384515..62a7a1a19 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -99,8 +99,10 @@ void EmulatedController::ReloadFromSettings() { // Other or debug controller should always be a pro controller if (npad_id_type != NpadIdType::Other) { SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); + original_npad_type = npad_type; } else { SetNpadStyleIndex(NpadStyleIndex::ProController); + original_npad_type = npad_type; } if (player.connected) { @@ -339,6 +341,7 @@ void EmulatedController::DisableConfiguration() { Disconnect(); } SetNpadStyleIndex(tmp_npad_type); + original_npad_type = tmp_npad_type; } // Apply temporary connected status to the real controller @@ -950,13 +953,27 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles) if (!is_connected) { return; } + + // Attempt to reconnect with the original type + if (npad_type != original_npad_type) { + Disconnect(); + const auto current_npad_type = npad_type; + SetNpadStyleIndex(original_npad_type); + if (IsControllerSupported()) { + Connect(); + return; + } + SetNpadStyleIndex(current_npad_type); + Connect(); + } + if (IsControllerSupported()) { return; } Disconnect(); - // Fallback fullkey controllers to Pro controllers + // Fallback Fullkey controllers to Pro controllers if (IsControllerFullkey() && supported_style_tag.fullkey) { LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type); SetNpadStyleIndex(NpadStyleIndex::ProController); @@ -964,6 +981,22 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles) return; } + // Fallback Dual joycon controllers to Pro controllers + if (npad_type == NpadStyleIndex::JoyconDual && supported_style_tag.fullkey) { + LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type); + SetNpadStyleIndex(NpadStyleIndex::ProController); + Connect(); + return; + } + + // Fallback Pro controllers to Dual joycon + if (npad_type == NpadStyleIndex::ProController && supported_style_tag.joycon_dual) { + LOG_WARNING(Service_HID, "Reconnecting controller type {} as Dual Joycons", npad_type); + SetNpadStyleIndex(NpadStyleIndex::JoyconDual); + Connect(); + return; + } + LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", npad_type); } diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 3f02ed3c0..1469fb95a 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h @@ -401,6 +401,7 @@ private: const NpadIdType npad_id_type; NpadStyleIndex npad_type{NpadStyleIndex::None}; + NpadStyleIndex original_npad_type{NpadStyleIndex::None}; NpadStyleTag supported_style_tag{NpadStyleSet::All}; bool is_connected{false}; bool is_configuring{false}; |