From c5507f5f80c8f4666d3c5aeeaaad9acb4334458c Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 21 Jan 2023 11:02:32 +0100 Subject: [PATCH] Added a PlayStation 3 controller type. --- es-app/src/guis/GuiMenu.cpp | 1 + es-core/src/HelpStyle.cpp | 4 ++ es-core/src/HelpStyle.h | 2 + es-core/src/components/HelpComponent.cpp | 23 +++++++- resources/graphics/help/button_back_PS3.svg | 60 ++++++++++++++++++++ resources/graphics/help/button_start_PS3.svg | 60 ++++++++++++++++++++ 6 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 resources/graphics/help/button_back_PS3.svg create mode 100644 resources/graphics/help/button_start_PS3.svg diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 032a8e4cb..6412e1aa8 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -1087,6 +1087,7 @@ void GuiMenu::openInputDeviceOptions() std::string selectedPlayer {Settings::getInstance()->getString("InputControllerType")}; inputControllerType->add("XBOX", "xbox", selectedPlayer == "xbox"); inputControllerType->add("XBOX 360", "xbox360", selectedPlayer == "xbox360"); + inputControllerType->add("PLAYSTATION 3", "ps3", selectedPlayer == "ps3"); inputControllerType->add("PLAYSTATION 4", "ps4", selectedPlayer == "ps4"); inputControllerType->add("PLAYSTATION 5", "ps5", selectedPlayer == "ps5"); inputControllerType->add("SNES", "snes", selectedPlayer == "snes"); diff --git a/es-core/src/HelpStyle.cpp b/es-core/src/HelpStyle.cpp index 92291384d..c756a74a7 100644 --- a/es-core/src/HelpStyle.cpp +++ b/es-core/src/HelpStyle.cpp @@ -126,6 +126,10 @@ void HelpStyle::applyTheme(const std::shared_ptr& theme, const std::s mCustomButtons.button_x_PS = elem->get(PREFIX "button_x_PS"); if (elem->has(PREFIX "button_y_PS")) mCustomButtons.button_y_PS = elem->get(PREFIX "button_y_PS"); + if (elem->has(PREFIX "button_start_PS3")) + mCustomButtons.button_start_PS3 = elem->get(PREFIX "button_start_PS3"); + if (elem->has(PREFIX "button_back_PS3")) + mCustomButtons.button_back_PS3 = elem->get(PREFIX "button_back_PS3"); if (elem->has(PREFIX "button_start_PS4")) mCustomButtons.button_start_PS4 = elem->get(PREFIX "button_start_PS4"); if (elem->has(PREFIX "button_back_PS4")) diff --git a/es-core/src/HelpStyle.h b/es-core/src/HelpStyle.h index 6ebd49d32..b629a81ef 100644 --- a/es-core/src/HelpStyle.h +++ b/es-core/src/HelpStyle.h @@ -57,6 +57,8 @@ struct HelpStyle { std::string button_b_PS; std::string button_x_PS; std::string button_y_PS; + std::string button_start_PS3; + std::string button_back_PS3; std::string button_start_PS4; std::string button_back_PS4; std::string button_start_PS5; diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 138520435..7f9030a00 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -81,6 +81,26 @@ void HelpComponent::assignIcons() ":/graphics/help/button_back_SNES.svg" : mStyle.mCustomButtons.button_back_SNES; } + else if (controllerType == "ps3") { + sIconPathMap["a"] = mStyle.mCustomButtons.button_a_PS.empty() ? + ":/graphics/help/button_a_PS.svg" : + mStyle.mCustomButtons.button_a_PS; + sIconPathMap["b"] = mStyle.mCustomButtons.button_b_PS.empty() ? + ":/graphics/help/button_b_PS.svg" : + mStyle.mCustomButtons.button_b_PS; + sIconPathMap["x"] = mStyle.mCustomButtons.button_x_PS.empty() ? + ":/graphics/help/button_x_PS.svg" : + mStyle.mCustomButtons.button_x_PS; + sIconPathMap["y"] = mStyle.mCustomButtons.button_y_PS.empty() ? + ":/graphics/help/button_y_PS.svg" : + mStyle.mCustomButtons.button_y_PS; + sIconPathMap["start"] = mStyle.mCustomButtons.button_start_PS3.empty() ? + ":/graphics/help/button_start_PS3.svg" : + mStyle.mCustomButtons.button_start_PS3; + sIconPathMap["back"] = mStyle.mCustomButtons.button_back_PS3.empty() ? + ":/graphics/help/button_back_PS3.svg" : + mStyle.mCustomButtons.button_back_PS3; + } else if (controllerType == "ps4") { sIconPathMap["a"] = mStyle.mCustomButtons.button_a_PS.empty() ? ":/graphics/help/button_a_PS.svg" : @@ -169,9 +189,8 @@ void HelpComponent::assignIcons() while (it != sIconPathMap.end()) { if (sIconPathMapOld.find(it->first) != sIconPathMapOld.end()) { if (sIconPathMapOld[it->first] != sIconPathMap[it->first]) { - if (mIconCache.find(it->first) != mIconCache.end()) { + if (mIconCache.find(it->first) != mIconCache.end()) mIconCache.erase(mIconCache.find(it->first)); - } } } ++it; diff --git a/resources/graphics/help/button_back_PS3.svg b/resources/graphics/help/button_back_PS3.svg new file mode 100644 index 000000000..265dc829d --- /dev/null +++ b/resources/graphics/help/button_back_PS3.svg @@ -0,0 +1,60 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/resources/graphics/help/button_start_PS3.svg b/resources/graphics/help/button_start_PS3.svg new file mode 100644 index 000000000..7f7881d98 --- /dev/null +++ b/resources/graphics/help/button_start_PS3.svg @@ -0,0 +1,60 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + +