diff options
| author | 2022-08-26 16:23:41 -0700 | |
|---|---|---|
| committer | 2022-08-26 16:23:41 -0700 | |
| commit | d1ef4b2b8604c65f6cdc9a1727ed05b634b95fb1 (patch) | |
| tree | 0f881afc2d00ea1b4ae2e054c52780d3f596c7c1 /src/core/hid/emulated_controller.cpp | |
| parent | Merge pull request #8485 from nezd5553/master (diff) | |
| parent | core: hid: Add fallback for dualjoycon and pro controllers (diff) | |
| download | yuzu-d1ef4b2b8604c65f6cdc9a1727ed05b634b95fb1.tar.gz yuzu-d1ef4b2b8604c65f6cdc9a1727ed05b634b95fb1.tar.xz yuzu-d1ef4b2b8604c65f6cdc9a1727ed05b634b95fb1.zip | |
Merge pull request #8566 from german77/galaxy
core: hid: Add fallback for dualjoycon and pro controllers
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 35 |
1 files changed, 34 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 | } |