diff options
author | bunnei <bunneidev@gmail.com> | 2022-01-04 00:04:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 00:04:37 +0100 |
commit | abbbdc2bc027ed7af236625ae8427a46df63f7e7 (patch) | |
tree | 38f9f01b22cb2bc4cd1c012725094133b7587d22 /src | |
parent | Merge pull request #7662 from german77/uistatus (diff) | |
parent | core/hid: Add fallback to fullkey controllers (diff) | |
download | yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar.gz yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar.bz2 yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar.lz yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar.xz yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.tar.zst yuzu-abbbdc2bc027ed7af236625ae8427a46df63f7e7.zip |
Diffstat (limited to 'src')
-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) if (!is_connected) { return; } - if (!IsControllerSupported()) { - LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", - npad_type); - Disconnect(); + if (IsControllerSupported()) { + return; + } + + Disconnect(); + + // Fallback fullkey controllers to Pro controllers + if (IsControllerFullkey() && supported_style_tag.fullkey) { + LOG_WARNING(Service_HID, "Reconnecting controller type {} as Pro controller", npad_type); + SetNpadStyleIndex(NpadStyleIndex::ProController); + Connect(); + return; + } + + LOG_ERROR(Service_HID, "Controller type {} is not supported. Disconnecting controller", + npad_type); +} + +bool EmulatedController::IsControllerFullkey(bool use_temporary_value) const { + const auto type = is_configuring && use_temporary_value ? tmp_npad_type : npad_type; + switch (type) { + case NpadStyleIndex::ProController: + case NpadStyleIndex::GameCube: + case NpadStyleIndex::NES: + case NpadStyleIndex::SNES: + case NpadStyleIndex::N64: + case NpadStyleIndex::SegaGenesis: + return true; + default: + return false; } } 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: void LoadTASParams(); /** + * @param use_temporary_value If true tmp_npad_type will be used + * @return true if the controller style is fullkey + */ + bool IsControllerFullkey(bool use_temporary_value = false) const; + + /** * Checks the current controller type against the supported_style_tag * @param use_temporary_value If true tmp_npad_type will be used * @return true if the controller is supported |