diff options
| author | 2022-01-03 15:04:37 -0800 | |
|---|---|---|
| committer | 2022-01-03 15:04:37 -0800 | |
| commit | abbbdc2bc027ed7af236625ae8427a46df63f7e7 (patch) | |
| tree | 38f9f01b22cb2bc4cd1c012725094133b7587d22 | |
| parent | Merge pull request #7662 from german77/uistatus (diff) | |
| parent | core/hid: Add fallback to fullkey controllers (diff) | |
| download | yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar.gz yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar.xz yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.zip | |
Merge pull request #7664 from german77/fallback
core/hid: Add fallback to fullkey controllers
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 34 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 6 |
2 files changed, 36 insertions, 4 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 2d3fce276..71fc05807 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -879,10 +879,36 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles) | |||
| 879 | if (!is_connected) { | 879 | if (!is_connected) { |
| 880 | return; | 880 | return; |
| 881 | } | 881 | } |
| 882 | if (!IsControllerSupported()) { | 882 | if (IsControllerSupported()) { |
| 883 | LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", | 883 | return; |
| 884 | npad_type); | 884 | } |
| 885 | Disconnect(); | 885 | |
| 886 | Disconnect(); | ||
| 887 | |||
| 888 | // Fallback fullkey controllers to Pro controllers | ||
| 889 | if (IsControllerFullkey() && supported_style_tag.fullkey) { | ||
| 890 | LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type); | ||
| 891 | SetNpadStyleIndex(NpadStyleIndex::ProController); | ||
| 892 | Connect(); | ||
| 893 | return; | ||
| 894 | } | ||
| 895 | |||
| 896 | LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", | ||
| 897 | npad_type); | ||
| 898 | } | ||
| 899 | |||
| 900 | bool EmulatedController::IsControllerFullkey(bool use_temporary_value) const { | ||
| 901 | const auto type = is_configuring && use_temporary_value ? tmp_npad_type : npad_type; | ||
| 902 | switch (type) { | ||
| 903 | case NpadStyleIndex::ProController: | ||
| 904 | case NpadStyleIndex::GameCube: | ||
| 905 | case NpadStyleIndex::NES: | ||
| 906 | case NpadStyleIndex::SNES: | ||
| 907 | case NpadStyleIndex::N64: | ||
| 908 | case NpadStyleIndex::SegaGenesis: | ||
| 909 | return true; | ||
| 910 | default: | ||
| 911 | return false; | ||
| 886 | } | 912 | } |
| 887 | } | 913 | } |
| 888 | 914 | ||
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index d887eca87..c0994ab4d 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -321,6 +321,12 @@ private: | |||
| 321 | void LoadTASParams(); | 321 | void LoadTASParams(); |
| 322 | 322 | ||
| 323 | /** | 323 | /** |
| 324 | * @param use_temporary_value If true tmp_npad_type will be used | ||
| 325 | * @return true if the controller style is fullkey | ||
| 326 | */ | ||
| 327 | bool IsControllerFullkey(bool use_temporary_value = false) const; | ||
| 328 | |||
| 329 | /** | ||
| 324 | * Checks the current controller type against the supported_style_tag | 330 | * Checks the current controller type against the supported_style_tag |
| 325 | * @param use_temporary_value If true tmp_npad_type will be used | 331 | * @param use_temporary_value If true tmp_npad_type will be used |
| 326 | * @return true if the controller is supported | 332 | * @return true if the controller is supported |