From 0ee7c35877722b331ce78b5126d2f184441c74aa Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 4 Jan 2022 01:09:50 +0100 Subject: [PATCH] early-access version 2368 --- README.md | 2 +- src/core/hid/emulated_controller.cpp | 34 ++++++++++++++++++++++++---- src/core/hid/emulated_controller.h | 6 +++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6802a2c90..f1e67f423 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2367. +This is the source code for early-access 2368. ## Legal Notice diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 04124a421..6209c707e 100755 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -901,10 +901,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 75926fe2c..a63a83cce 100755 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h @@ -337,6 +337,12 @@ private: /// Set the params for TAS devices 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