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 bd2384515..62a7a1a19 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -99,8 +99,10 @@ void EmulatedController::ReloadFromSettings() {
99 // Other or debug controller should always be a pro controller 99 // Other or debug controller should always be a pro controller
100 if (npad_id_type != NpadIdType::Other) { 100 if (npad_id_type != NpadIdType::Other) {
101 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type)); 101 SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
102 original_npad_type = npad_type;
102 } else { 103 } else {
103 SetNpadStyleIndex(NpadStyleIndex::ProController); 104 SetNpadStyleIndex(NpadStyleIndex::ProController);
105 original_npad_type = npad_type;
104 } 106 }
105 107
106 if (player.connected) { 108 if (player.connected) {
@@ -339,6 +341,7 @@ void EmulatedController::DisableConfiguration() {
339 Disconnect(); 341 Disconnect();
340 } 342 }
341 SetNpadStyleIndex(tmp_npad_type); 343 SetNpadStyleIndex(tmp_npad_type);
344 original_npad_type = tmp_npad_type;
342 } 345 }
343 346
344 // Apply temporary connected status to the real controller 347 // Apply temporary connected status to the real controller
@@ -950,13 +953,27 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
950 if (!is_connected) { 953 if (!is_connected) {
951 return; 954 return;
952 } 955 }
956
957 // Attempt to reconnect with the original type
958 if (npad_type != original_npad_type) {
959 Disconnect();
960 const auto current_npad_type = npad_type;
961 SetNpadStyleIndex(original_npad_type);
962 if (IsControllerSupported()) {
963 Connect();
964 return;
965 }
966 SetNpadStyleIndex(current_npad_type);
967 Connect();
968 }
969
953 if (IsControllerSupported()) { 970 if (IsControllerSupported()) {
954 return; 971 return;
955 } 972 }
956 973
957 Disconnect(); 974 Disconnect();
958 975
959 // Fallback fullkey controllers to Pro controllers 976 // Fallback Fullkey controllers to Pro controllers
960 if (IsControllerFullkey() && supported_style_tag.fullkey) { 977 if (IsControllerFullkey() && supported_style_tag.fullkey) {
961 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type); 978 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
962 SetNpadStyleIndex(NpadStyleIndex::ProController); 979 SetNpadStyleIndex(NpadStyleIndex::ProController);
@@ -964,6 +981,22 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
964 return; 981 return;
965 } 982 }
966 983
984 // Fallback Dual joycon controllers to Pro controllers
985 if (npad_type == NpadStyleIndex::JoyconDual && supported_style_tag.fullkey) {
986 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type);
987 SetNpadStyleIndex(NpadStyleIndex::ProController);
988 Connect();
989 return;
990 }
991
992 // Fallback Pro controllers to Dual joycon
993 if (npad_type == NpadStyleIndex::ProController && supported_style_tag.joycon_dual) {
994 LOG_WARNING(Service_HID, "Reconnecting controller type {} as Dual Joycons", npad_type);
995 SetNpadStyleIndex(NpadStyleIndex::JoyconDual);
996 Connect();
997 return;
998 }
999
967 LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", 1000 LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller",
968 npad_type); 1001 npad_type);
969} 1002}
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:
401 401
402 const NpadIdType npad_id_type; 402 const NpadIdType npad_id_type;
403 NpadStyleIndex npad_type{NpadStyleIndex::None}; 403 NpadStyleIndex npad_type{NpadStyleIndex::None};
404 NpadStyleIndex original_npad_type{NpadStyleIndex::None};
404 NpadStyleTag supported_style_tag{NpadStyleSet::All}; 405 NpadStyleTag supported_style_tag{NpadStyleSet::All};
405 bool is_connected{false}; 406 bool is_connected{false};
406 bool is_configuring{false}; 407 bool is_configuring{false};