diff options
| author | bunnei <bunneidev@gmail.com> | 2022-01-03 15:04:37 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-03 15:04:37 -0800 |
| commit | 2e61bc3d5160b31005831bd936dfdc8ddf3722f7 (patch) | |
| tree | 38f9f01b22cb2bc4cd1c012725094133b7587d22 /src/core/hid/emulated_controller.cpp | |
| parent | ac2684af9fd74b70ea3504ff70aefa9f56493a4b (diff) | |
| parent | 0e9f010ed6cb1fd594fa4b6c5ff2097de046e9f5 (diff) | |
Merge pull request #7664 from german77/fallback
core/hid: Add fallback to fullkey controllers
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 2d3fce2761..71fc058074 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; } } |
