summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hid/emulated_controller.cpp35
-rw-r--r--src/core/hid/emulated_controller.h1
2 files changed, 35 insertions, 1 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 049602e7d..f9f902c2d 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -101,8 +101,10 @@ void EmulatedController::ReloadFromSettings() {
101 // Other or debug controller should always be a pro controller 101 // Other or debug controller should always be a pro controller
102 if (npad_id_type != NpadIdType::Other) { 102 if (npad_id_type != NpadIdType::Other) {
103 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); 103 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
104 original_npad_type = npad_type;
104 } else { 105 } else {
105 SetNpadStyleIndex(NpadStyleIndex::ProController); 106 SetNpadStyleIndex(NpadStyleIndex::ProController);
107 original_npad_type = npad_type;
106 } 108 }
107 109
108 if (player.connected) { 110 if (player.connected) {
@@ -354,6 +356,7 @@ void EmulatedController::DisableConfiguration() {
354 Disconnect(); 356 Disconnect();
355 } 357 }
356 SetNpadStyleIndex(tmp_npad_type); 358 SetNpadStyleIndex(tmp_npad_type);
359 original_npad_type = tmp_npad_type;
357 } 360 }
358 361
359 // Apply temporary connected status to the real controller 362 // Apply temporary connected status to the real controller
@@ -1004,13 +1007,27 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
1004 if (!is_connected) { 1007 if (!is_connected) {
1005 return; 1008 return;
1006 } 1009 }
1010
1011 // Attempt to reconnect with the original type
1012 if (npad_type != original_npad_type) {
1013 Disconnect();
1014 const auto current_npad_type = npad_type;
1015 SetNpadStyleIndex(original_npad_type);
1016 if (IsControllerSupported()) {
1017 Connect();
1018 return;
1019 }
1020 SetNpadStyleIndex(current_npad_type);
1021 Connect();
1022 }
1023
1007 if (IsControllerSupported()) { 1024 if (IsControllerSupported()) {
1008 return; 1025 return;
1009 } 1026 }
1010 1027
1011 Disconnect(); 1028 Disconnect();
1012 1029
1013 // Fallback fullkey controllers to Pro controllers 1030 // Fallback Fullkey controllers to Pro controllers
1014 if (IsControllerFullkey() && supported_style_tag.fullkey) { 1031 if (IsControllerFullkey() && supported_style_tag.fullkey) {
1015 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type); 1032 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
1016 SetNpadStyleIndex(NpadStyleIndex::ProController); 1033 SetNpadStyleIndex(NpadStyleIndex::ProController);
@@ -1018,6 +1035,22 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
1018 return; 1035 return;
1019 } 1036 }
1020 1037
1038 // Fallback Dual joycon controllers to Pro controllers
1039 if (npad_type == NpadStyleIndex::JoyconDual && supported_style_tag.fullkey) {
1040 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
1041 SetNpadStyleIndex(NpadStyleIndex::ProController);
1042 Connect();
1043 return;
1044 }
1045
1046 // Fallback Pro controllers to Dual joycon
1047 if (npad_type == NpadStyleIndex::ProController && supported_style_tag.joycon_dual) {
1048 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Dual Joycons", npad_type);
1049 SetNpadStyleIndex(NpadStyleIndex::JoyconDual);
1050 Connect();
1051 return;
1052 }
1053
1021 LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", 1054 LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller",
1022 npad_type); 1055 npad_type);
1023} 1056}
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index cbd7c26d3..c3aa8f9d3 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -440,6 +440,7 @@ private:
440 440
441 const NpadIdType npad_id_type; 441 const NpadIdType npad_id_type;
442 NpadStyleIndex npad_type{NpadStyleIndex::None}; 442 NpadStyleIndex npad_type{NpadStyleIndex::None};
443 NpadStyleIndex original_npad_type{NpadStyleIndex::None};
443 NpadStyleTag supported_style_tag{NpadStyleSet::All}; 444 NpadStyleTag supported_style_tag{NpadStyleSet::All};
444 bool is_connected{false}; 445 bool is_connected{false};
445 bool is_configuring{false}; 446 bool is_configuring{false};