From 2eb8240211b01a1df87fe2a25d709c711896ec19 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 1 Jul 2021 17:48:14 +0200 Subject: [PATCH] Made the UI mode unlock symbols reflect the selected controller type. --- es-app/src/views/UIModeController.cpp | 38 +++++++++++++++++++++++---- es-app/src/views/UIModeController.h | 9 ++++--- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/es-app/src/views/UIModeController.cpp b/es-app/src/views/UIModeController.cpp index 46d1c6a6c..aebc63f48 100644 --- a/es-app/src/views/UIModeController.cpp +++ b/es-app/src/views/UIModeController.cpp @@ -124,7 +124,35 @@ std::string UIModeController::getFormattedPassKeyStr() std::string out = ""; for (auto c : mPassKeySequence) { - out += (out == "") ? "" : ", "; // Add a comma after the first entry. + out += (out == "") ? "" : " , "; // Add commas between the entries. + + std::string controllerType = Settings::getInstance()->getString("InputControllerType"); + std::string symbolA; + std::string symbolB; + std::string symbolX; + std::string symbolY; + + if (controllerType == "snes") { + symbolA = "B"; + symbolB = "A"; + symbolX = "Y"; + symbolY = "X"; + } + else if (controllerType == "ps4" || controllerType == "ps5") { + // These symbols are far from perfect but you can at least understand what + // they are supposed to depict. + symbolA = "\uF00D"; // Cross. + symbolB = "\uF111"; // Circle + symbolX = "\uF04D"; // Square. + symbolY = "\uF0D8"; // Triangle. + } + else { + // Xbox controller. + symbolA = "A"; + symbolB = "B"; + symbolX = "X"; + symbolY = "Y"; + } switch (c) { case 'u': @@ -140,16 +168,16 @@ std::string UIModeController::getFormattedPassKeyStr() out += Utils::String::unicode2Chars(0x2192); // Arrow pointing right. break; case 'a': - out += "A"; + out += symbolA; break; case 'b': - out += "B"; + out += symbolB; break; case 'x': - out += "X"; + out += symbolX; break; case 'y': - out += "Y"; + out += symbolY; break; } } diff --git a/es-app/src/views/UIModeController.h b/es-app/src/views/UIModeController.h index 438339683..9c6a4f3a2 100644 --- a/es-app/src/views/UIModeController.h +++ b/es-app/src/views/UIModeController.h @@ -43,8 +43,8 @@ public: private: UIModeController(); - bool inputIsMatch(InputConfig * config, Input input); - bool isValidInput(InputConfig * config, Input input); + bool inputIsMatch(InputConfig* config, Input input); + bool isValidInput(InputConfig* config, Input input); // Return UI mode to 'full'. void unlockUIMode(); @@ -53,10 +53,13 @@ private: // Default passkeyseq = "uuddlrlrba", as defined in the setting 'UIMode_passkey'. std::string mPassKeySequence; + + std::string mCurrentUIMode; int mPassKeyCounter; + + // These are Xbox button names, so they may be different in pracise on non-Xbox controllers. const std::vector mInputVals = { "up", "down", "left", "right", "a", "b", "x", "y" }; - std::string mCurrentUIMode; }; #endif // ES_APP_VIEWS_UI_MODE_CONTROLLER_H