diff options
| author | 2022-07-10 20:14:50 -0500 | |
|---|---|---|
| committer | 2022-07-10 20:27:40 -0500 | |
| commit | 18550b165b24e8670cd3a72178c7161e06f9841e (patch) | |
| tree | 166f76680bea8465fae8ece61dbbc3d51329bf4c /src/core/hid/emulated_controller.cpp | |
| parent | Merge pull request #8528 from Morph1984/astc10x6 (diff) | |
| download | yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar.gz yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.tar.xz yuzu-18550b165b24e8670cd3a72178c7161e06f9841e.zip | |
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 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 | } |