From 4d4210a4193a695ac8b480969fde635503628102 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 23 May 2021 19:12:31 +0200 Subject: [PATCH] Added support for selecting between different controller types. --- es-app/src/guis/GuiMenu.cpp | 24 +++ es-app/src/guis/GuiSettings.cpp | 5 + es-app/src/guis/GuiSettings.h | 2 + es-core/src/Settings.cpp | 1 + es-core/src/Window.cpp | 8 + es-core/src/Window.h | 1 + es-core/src/components/HelpComponent.cpp | 80 +++++++-- es-core/src/components/HelpComponent.h | 2 + es-core/src/guis/GuiInputConfig.cpp | 169 ++++++++++++++---- es-core/src/guis/GuiInputConfig.h | 2 + .../{button_cross.svg => button_a_PS.svg} | 0 .../help/{button_b.svg => button_a_SNES.svg} | 0 .../help/{button_a.svg => button_a_XBOX.svg} | 0 .../{button_circle.svg => button_b_PS.svg} | 0 resources/help/button_b_SNES.svg | 5 + resources/help/button_b_XBOX.svg | 5 + resources/help/button_back_PS4.svg | 88 +++++++++ resources/help/button_back_PS5.svg | 62 +++++++ resources/help/button_back_SNES.svg | 89 +++++++++ resources/help/button_back_XBOX.svg | 56 ++++++ resources/help/button_back_XBOX360.svg | 57 ++++++ resources/help/button_select.svg | 12 -- resources/help/button_start.svg | 11 -- resources/help/button_start_PS4.svg | 98 ++++++++++ resources/help/button_start_PS5.svg | 56 ++++++ resources/help/button_start_SNES.svg | 85 +++++++++ resources/help/button_start_XBOX.svg | 56 ++++++ resources/help/button_start_XBOX360.svg | 56 ++++++ .../{button_square.svg => button_x_PS.svg} | 0 .../help/{button_y.svg => button_x_SNES.svg} | 0 .../help/{button_x.svg => button_x_XBOX.svg} | 0 .../{button_triangle.svg => button_y_PS.svg} | 0 resources/help/button_y_SNES.svg | 5 + resources/help/button_y_XBOX.svg | 5 + ...buttons_south_PS.svg => mbuttons_a_PS.svg} | 0 ...ons_south_SNES.svg => mbuttons_a_SNES.svg} | 0 ...ons_south_XBOX.svg => mbuttons_a_XBOX.svg} | 0 ...{buttons_east_PS.svg => mbuttons_b_PS.svg} | 0 ...tons_east_SNES.svg => mbuttons_b_SNES.svg} | 0 ...tons_east_XBOX.svg => mbuttons_b_XBOX.svg} | 0 ...{buttons_west_PS.svg => mbuttons_x_PS.svg} | 0 ...tons_west_SNES.svg => mbuttons_x_SNES.svg} | 0 ...tons_west_XBOX.svg => mbuttons_x_XBOX.svg} | 0 ...buttons_north_PS.svg => mbuttons_y_PS.svg} | 0 ...ons_north_SNES.svg => mbuttons_y_SNES.svg} | 0 ...ons_north_XBOX.svg => mbuttons_y_XBOX.svg} | 0 46 files changed, 961 insertions(+), 79 deletions(-) rename resources/help/{button_cross.svg => button_a_PS.svg} (100%) rename resources/help/{button_b.svg => button_a_SNES.svg} (100%) rename resources/help/{button_a.svg => button_a_XBOX.svg} (100%) rename resources/help/{button_circle.svg => button_b_PS.svg} (100%) create mode 100644 resources/help/button_b_SNES.svg create mode 100644 resources/help/button_b_XBOX.svg create mode 100644 resources/help/button_back_PS4.svg create mode 100644 resources/help/button_back_PS5.svg create mode 100644 resources/help/button_back_SNES.svg create mode 100644 resources/help/button_back_XBOX.svg create mode 100644 resources/help/button_back_XBOX360.svg delete mode 100644 resources/help/button_select.svg delete mode 100644 resources/help/button_start.svg create mode 100644 resources/help/button_start_PS4.svg create mode 100644 resources/help/button_start_PS5.svg create mode 100644 resources/help/button_start_SNES.svg create mode 100644 resources/help/button_start_XBOX.svg create mode 100644 resources/help/button_start_XBOX360.svg rename resources/help/{button_square.svg => button_x_PS.svg} (100%) rename resources/help/{button_y.svg => button_x_SNES.svg} (100%) rename resources/help/{button_x.svg => button_x_XBOX.svg} (100%) rename resources/help/{button_triangle.svg => button_y_PS.svg} (100%) create mode 100644 resources/help/button_y_SNES.svg create mode 100644 resources/help/button_y_XBOX.svg rename resources/help/{buttons_south_PS.svg => mbuttons_a_PS.svg} (100%) rename resources/help/{buttons_south_SNES.svg => mbuttons_a_SNES.svg} (100%) rename resources/help/{buttons_south_XBOX.svg => mbuttons_a_XBOX.svg} (100%) rename resources/help/{buttons_east_PS.svg => mbuttons_b_PS.svg} (100%) rename resources/help/{buttons_east_SNES.svg => mbuttons_b_SNES.svg} (100%) rename resources/help/{buttons_east_XBOX.svg => mbuttons_b_XBOX.svg} (100%) rename resources/help/{buttons_west_PS.svg => mbuttons_x_PS.svg} (100%) rename resources/help/{buttons_west_SNES.svg => mbuttons_x_SNES.svg} (100%) rename resources/help/{buttons_west_XBOX.svg => mbuttons_x_XBOX.svg} (100%) rename resources/help/{buttons_north_PS.svg => mbuttons_y_PS.svg} (100%) rename resources/help/{buttons_north_SNES.svg => mbuttons_y_SNES.svg} (100%) rename resources/help/{buttons_north_XBOX.svg => mbuttons_y_XBOX.svg} (100%) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index e1f295598..b810ae04a 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -759,6 +759,30 @@ void GuiMenu::openInputDeviceOptions() { auto s = new GuiSettings(mWindow, "INPUT DEVICE SETTINGS"); + // Controller type. + auto input_controller_type = std::make_shared> + (mWindow, getHelpStyle(), "CONTROLLER TYPE", false); + std::string selectedPlayer = Settings::getInstance()->getString("InputControllerType"); + input_controller_type->add("XBOX", "xbox", selectedPlayer == "xbox"); + input_controller_type->add("XBOX360", "xbox360", selectedPlayer == "xbox360"); + input_controller_type->add("PLAYSTATION4", "ps4", selectedPlayer == "ps4"); + input_controller_type->add("PLAYSTATION5", "ps5", selectedPlayer == "ps5"); + input_controller_type->add("SNES", "snes", selectedPlayer == "snes"); + // If there are no objects returned, then there must be a manually modified entry in the + // configuration file. Simply set the controller type to "xbox" in this case. + if (input_controller_type->getSelectedObjects().size() == 0) + input_controller_type->selectEntry(0); + s->addWithLabel("CONTROLLER TYPE", input_controller_type); + s->addSaveFunc([input_controller_type, s] { + if (input_controller_type->getSelected() != + Settings::getInstance()->getString("InputControllerType")) { + Settings::getInstance()->setString("InputControllerType", + input_controller_type->getSelected()); + s->setNeedsReloadHelpPrompts(); + s->setNeedsSaving(); + } + }); + // Whether to only accept input from the first controller. auto input_only_first_controller = std::make_shared(mWindow); input_only_first_controller->setState(Settings::getInstance()-> diff --git a/es-app/src/guis/GuiSettings.cpp b/es-app/src/guis/GuiSettings.cpp index bb8b7a8d7..0ac329774 100644 --- a/es-app/src/guis/GuiSettings.cpp +++ b/es-app/src/guis/GuiSettings.cpp @@ -10,6 +10,7 @@ #include "guis/GuiSettings.h" +#include "components/HelpComponent.h" #include "guis/GuiTextEditPopup.h" #include "views/gamelist/IGameListView.h" #include "views/ViewController.h" @@ -25,6 +26,7 @@ GuiSettings::GuiSettings( : GuiComponent(window), mMenu(window, title), mNeedsSaving(false), + mNeedsReloadHelpPrompts(false), mNeedsCollectionsUpdate(false), mNeedsSorting(false), mNeedsSortingCollections(false), @@ -61,6 +63,9 @@ void GuiSettings::save() if (mNeedsSaving) Settings::getInstance()->saveFile(); + if (mNeedsReloadHelpPrompts) + mWindow->reloadHelpPrompts(); + if (mNeedsCollectionsUpdate) { CollectionSystemsManager::get()->loadEnabledListFromSettings(); CollectionSystemsManager::get()->updateSystemsList(); diff --git a/es-app/src/guis/GuiSettings.h b/es-app/src/guis/GuiSettings.h index 980313936..b303789c6 100644 --- a/es-app/src/guis/GuiSettings.h +++ b/es-app/src/guis/GuiSettings.h @@ -34,6 +34,7 @@ public: inline void addSaveFunc(const std::function& func) { mSaveFuncs.push_back(func); }; void setNeedsSaving() { mNeedsSaving = true; }; + void setNeedsReloadHelpPrompts() { mNeedsReloadHelpPrompts = true; }; void setNeedsCollectionsUpdate() { mNeedsCollectionsUpdate = true; }; void setNeedsSorting() { mNeedsSorting = true; }; void setNeedsSortingCollections() { mNeedsSortingCollections = true; }; @@ -53,6 +54,7 @@ private: MenuComponent mMenu; std::vector> mSaveFuncs; bool mNeedsSaving; + bool mNeedsReloadHelpPrompts; bool mNeedsCollectionsUpdate; bool mNeedsSorting; bool mNeedsSortingCollections; diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 2cbb10ea5..03009cbba 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -197,6 +197,7 @@ void Settings::setDefaults() mBoolMap["NavigationSounds"] = { true, true }; // Input device settings. + mStringMap["InputControllerType"] = { "xbox", "xbox" }; mBoolMap["InputOnlyFirstController"] = { false, false }; // Game collection settings. diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 043a141ae..ceb73e3e1 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -650,6 +650,14 @@ void Window::setHelpPrompts(const std::vector& prompts, const HelpSt mHelp->setPrompts(addPrompts); } +void Window::reloadHelpPrompts() +{ + if (mHelp) { + delete mHelp; + mHelp = new HelpComponent(this); + } +} + void Window::setInfoPopup(InfoPopup* infoPopup) { delete mInfoPopup; diff --git a/es-core/src/Window.h b/es-core/src/Window.h index dd452da32..274e221a8 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -100,6 +100,7 @@ public: void renderHelpPromptsEarly(); // Used to render HelpPrompts before a fade. void setHelpPrompts(const std::vector& prompts, const HelpStyle& style); + void reloadHelpPrompts(); void setScreensaver(Screensaver* screensaver) { mScreensaver = screensaver; } void setInfoPopup(InfoPopup* infoPopup); diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 25308e546..5350dce40 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -22,24 +22,70 @@ #define ICON_TEXT_SPACING 8 // Space between [icon] and [text] (px). #define ENTRY_SPACING 16 // Space between [text] and next [icon] (px). -static const std::map ICON_PATH_MAP { - { "up/down", ":/help/dpad_updown.svg" }, - { "left/right", ":/help/dpad_leftright.svg" }, - { "up/down/left/right", ":/help/dpad_all.svg" }, - { "thumbstickclick", ":/help/thumbstick_click.svg" }, - { "a", ":/help/button_a.svg" }, - { "b", ":/help/button_b.svg" }, - { "x", ":/help/button_x.svg" }, - { "y", ":/help/button_y.svg" }, - { "l", ":/help/button_l.svg" }, - { "r", ":/help/button_r.svg" }, - { "lr", ":/help/button_lr.svg" }, - { "start", ":/help/button_start.svg" }, - { "select", ":/help/button_select.svg" } -}; +static std::map sIconPathMap {}; HelpComponent::HelpComponent(Window* window) : GuiComponent(window) { + assignIcons(); +} + +void HelpComponent::assignIcons() +{ + std::string controllerType = Settings::getInstance()->getString("InputControllerType"); + + sIconPathMap.clear(); + + // These graphics files are common between all controller types. + sIconPathMap["up/down"] = ":/help/dpad_updown.svg"; + sIconPathMap["left/right"] = ":/help/dpad_leftright.svg"; + sIconPathMap["up/down/left/right"] = ":/help/dpad_all.svg"; + sIconPathMap["thumbstickclick"] = ":/help/thumbstick_click.svg"; + sIconPathMap["l"] = ":/help/button_l.svg"; + sIconPathMap["r"] = ":/help/button_r.svg"; + sIconPathMap["lr"] = ":/help/button_lr.svg"; + + // These graphics files are custom per controller type. + if (controllerType == "snes") { + sIconPathMap["a"] = ":/help/button_a_SNES.svg"; + sIconPathMap["b"] = ":/help/button_b_SNES.svg"; + sIconPathMap["x"] = ":/help/button_x_SNES.svg"; + sIconPathMap["y"] = ":/help/button_y_SNES.svg"; + sIconPathMap["start"] = ":/help/button_start_SNES.svg"; + sIconPathMap["select"] = ":/help/button_back_SNES.svg"; + } + else if (controllerType == "ps4") { + sIconPathMap["a"] = ":/help/button_a_PS.svg"; + sIconPathMap["b"] = ":/help/button_b_PS.svg"; + sIconPathMap["x"] = ":/help/button_x_PS.svg"; + sIconPathMap["y"] = ":/help/button_y_PS.svg"; + sIconPathMap["start"] = ":/help/button_start_PS4.svg"; + sIconPathMap["select"] = ":/help/button_back_PS4.svg"; + } + else if (controllerType == "ps5") { + sIconPathMap["a"] = ":/help/button_a_PS.svg"; + sIconPathMap["b"] = ":/help/button_b_PS.svg"; + sIconPathMap["x"] = ":/help/button_x_PS.svg"; + sIconPathMap["y"] = ":/help/button_y_PS.svg"; + sIconPathMap["start"] = ":/help/button_start_PS5.svg"; + sIconPathMap["select"] = ":/help/button_back_PS5.svg"; + } + else if (controllerType == "xbox360") { + sIconPathMap["a"] = ":/help/button_a_XBOX.svg"; + sIconPathMap["b"] = ":/help/button_b_XBOX.svg"; + sIconPathMap["x"] = ":/help/button_x_XBOX.svg"; + sIconPathMap["y"] = ":/help/button_y_XBOX.svg"; + sIconPathMap["start"] = ":/help/button_start_XBOX360.svg"; + sIconPathMap["select"] = ":/help/button_back_XBOX360.svg"; + } + else { + // Xbox One and later. + sIconPathMap["a"] = ":/help/button_a_XBOX.svg"; + sIconPathMap["b"] = ":/help/button_b_XBOX.svg"; + sIconPathMap["x"] = ":/help/button_x_XBOX.svg"; + sIconPathMap["y"] = ":/help/button_y_XBOX.svg"; + sIconPathMap["start"] = ":/help/button_start_XBOX.svg"; + sIconPathMap["select"] = ":/help/button_back_XBOX.svg"; + } } void HelpComponent::clearPrompts() @@ -119,8 +165,8 @@ std::shared_ptr HelpComponent::getIconTexture(const char* name) if (it != mIconCache.cend()) return it->second; - auto pathLookup = ICON_PATH_MAP.find(name); - if (pathLookup == ICON_PATH_MAP.cend()) { + auto pathLookup = sIconPathMap.find(name); + if (pathLookup == sIconPathMap.cend()) { LOG(LogError) << "Unknown help icon \"" << name << "\""; return nullptr; } diff --git a/es-core/src/components/HelpComponent.h b/es-core/src/components/HelpComponent.h index 36f726af7..19bd61aed 100644 --- a/es-core/src/components/HelpComponent.h +++ b/es-core/src/components/HelpComponent.h @@ -21,6 +21,8 @@ class HelpComponent : public GuiComponent public: HelpComponent(Window* window); + void assignIcons(); + void clearPrompts(); void setPrompts(const std::vector& prompts); diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index bde82a71d..b6ca90728 100644 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -19,41 +19,13 @@ struct InputConfigStructure { std::string name; - const bool skippable; + bool skippable; std::string dispName; std::string icon; }; static const int inputCount = 24; - -static const InputConfigStructure GUI_INPUT_CONFIG_LIST[inputCount] = -{ - { "Up", false, "D-PAD UP", ":/help/dpad_up.svg" }, - { "Down", false, "D-PAD DOWN", ":/help/dpad_down.svg" }, - { "Left", false, "D-PAD LEFT", ":/help/dpad_left.svg" }, - { "Right", false, "D-PAD RIGHT", ":/help/dpad_right.svg" }, - { "Start", false, "START", ":/help/button_start.svg" }, - { "Select", false, "SELECT", ":/help/button_select.svg" }, - { "A", false, "BUTTON A", ":/help/buttons_south_XBOX.svg" }, - { "B", false, "BUTTON B", ":/help/buttons_east_XBOX.svg" }, - { "X", true, "BUTTON X", ":/help/buttons_west_XBOX.svg" }, - { "Y", true, "BUTTON Y", ":/help/buttons_north_XBOX.svg" }, - { "LeftShoulder", true, "LEFT SHOULDER", ":/help/button_l.svg" }, - { "RightShoulder", true, "RIGHT SHOULDER", ":/help/button_r.svg" }, - { "LeftTrigger", true, "LEFT TRIGGER", ":/help/button_lt.svg" }, - { "RightTrigger", true, "RIGHT TRIGGER", ":/help/button_rt.svg" }, - { "LeftThumbstickUp", true, "LEFT THUMBSTICK UP", ":/help/thumbstick_up.svg" }, - { "LeftThumbstickDown", true, "LEFT THUMBSTICK DOWN", ":/help/thumbstick_down.svg" }, - { "LeftThumbstickLeft", true, "LEFT THUMBSTICK LEFT", ":/help/thumbstick_left.svg" }, - { "LeftThumbstickRight", true, "LEFT THUMBSTICK RIGHT", ":/help/thumbstick_right.svg" }, - { "LeftThumbstickClick", true, "LEFT THUMBSTICK CLICK", ":/help/thumbstick_click.svg" }, - { "RightThumbstickUp", true, "RIGHT THUMBSTICK UP", ":/help/thumbstick_up.svg" }, - { "RightThumbstickDown", true, "RIGHT THUMBSTICK DOWN", ":/help/thumbstick_down.svg" }, - { "RightThumbstickLeft", true, "RIGHT THUMBSTICK LEFT", ":/help/thumbstick_left.svg" }, - { "RightThumbstickRight", true, "RIGHT THUMBSTICK RIGHT", ":/help/thumbstick_right.svg" }, - { "RightThumbstickClick", true, "RIGHT THUMBSTICK CLICK", ":/help/thumbstick_click.svg" }, -// { "HotKeyEnable", true, "HOTKEY ENABLE", ":/help/button_hotkey.svg" } -}; +static InputConfigStructure sGuiInputConfigList[inputCount]; GuiInputConfig::GuiInputConfig( Window* window, @@ -66,6 +38,10 @@ GuiInputConfig::GuiInputConfig( mTargetConfig(target), mHoldingInput(false) { + // Populate the configuration list with the text and icons applicable to the + // configured controller type. + populateConfigList(); + LOG(LogInfo) << "Configuring device " << target->getDeviceId() << " (" << target->getDeviceName() << ")."; @@ -112,7 +88,7 @@ GuiInputConfig::GuiInputConfig( // Icon. auto icon = std::make_shared(mWindow); - icon->setImage(GUI_INPUT_CONFIG_LIST[i].icon); + icon->setImage(sGuiInputConfigList[i].icon); icon->setColorShift(0x777777FF); icon->setResize(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 1.25f); row.addElement(icon, false); @@ -123,7 +99,7 @@ GuiInputConfig::GuiInputConfig( row.addElement(spacer, false); auto text = std::make_shared(mWindow, - GUI_INPUT_CONFIG_LIST[i].dispName, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + sGuiInputConfigList[i].dispName, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); row.addElement(text, true); auto mapping = std::make_shared(mWindow, "-NOT DEFINED-", @@ -184,7 +160,7 @@ GuiInputConfig::GuiInputConfig( // Only show "HOLD TO SKIP" if this input is skippable. mList->setCursorChangedCallback([this](CursorState) { - bool skippable = GUI_INPUT_CONFIG_LIST[mList->getCursorId()].skippable; + bool skippable = sGuiInputConfigList[mList->getCursorId()].skippable; mSubtitle2->setOpacity(skippable * 255); }); @@ -248,9 +224,124 @@ GuiInputConfig::GuiInputConfig( (Renderer::getScreenHeight() - mSize.y()) / 2.0f); } +void GuiInputConfig::populateConfigList() +{ + std::string controllerType = Settings::getInstance()->getString("InputControllerType"); + + sGuiInputConfigList[0] = + { "Up", false, "D-PAD UP", ":/help/dpad_up.svg" }; + sGuiInputConfigList[1] = + { "Down", false, "D-PAD DOWN", ":/help/dpad_down.svg" }; + sGuiInputConfigList[2] = + { "Left", false, "D-PAD LEFT", ":/help/dpad_left.svg" }; + sGuiInputConfigList[3] = + { "Right", false, "D-PAD RIGHT", ":/help/dpad_right.svg" }; + + if (controllerType == "snes") { + sGuiInputConfigList[4] = + { "Start", false, "START", ":/help/button_start_SNES.svg" }; + sGuiInputConfigList[5] = + { "Select", false, "SELECT", ":/help/button_back_SNES.svg" }; + sGuiInputConfigList[6] = + { "A", false, "B", ":/help/mbuttons_a_SNES.svg" }; + sGuiInputConfigList[7] = + { "B", false, "A", ":/help/mbuttons_b_SNES.svg" }; + sGuiInputConfigList[8] = + { "X", true, "Y", ":/help/mbuttons_x_SNES.svg" }; + sGuiInputConfigList[9] = + { "Y", true, "X", ":/help/mbuttons_y_SNES.svg" }; + } + else if (controllerType == "ps4") { + sGuiInputConfigList[4] = + { "Start", false, "OPTIONS", ":/help/button_start_PS4.svg" }; + sGuiInputConfigList[5] = + { "Select", false, "SHARE", ":/help/button_back_PS4.svg" }; + sGuiInputConfigList[6] = + { "A", false, "CROSS", ":/help/mbuttons_a_PS.svg" }; + sGuiInputConfigList[7] = + { "B", false, "CIRCLE", ":/help/mbuttons_b_PS.svg" }; + sGuiInputConfigList[8] = + { "X", true, "SQUARE", ":/help/mbuttons_x_PS.svg" }; + sGuiInputConfigList[9] = + { "Y", true, "TRIANGLE", ":/help/mbuttons_y_PS.svg" }; + } + else if (controllerType == "ps5") { + sGuiInputConfigList[4] = + { "Start", false, "OPTIONS", ":/help/button_start_PS5.svg" }; + sGuiInputConfigList[5] = + { "Select", false, "CREATE", ":/help/button_back_PS5.svg" }; + sGuiInputConfigList[6] = + { "A", false, "CROSS", ":/help/mbuttons_a_PS.svg" }; + sGuiInputConfigList[7] = + { "B", false, "CIRCLE", ":/help/mbuttons_b_PS.svg" }; + sGuiInputConfigList[8] = + { "X", true, "SQUARE", ":/help/mbuttons_x_PS.svg" }; + sGuiInputConfigList[9] = + { "Y", true, "TRIANGLE", ":/help/mbuttons_y_PS.svg" }; + } + else if (controllerType == "xbox360") { + sGuiInputConfigList[4] = + { "Start", false, "START", ":/help/button_start_XBOX360.svg" }; + sGuiInputConfigList[5] = + { "Select", false, "BACK", ":/help/button_back_XBOX360.svg" }; + sGuiInputConfigList[6] = + { "A", false, "A", ":/help/mbuttons_a_XBOX.svg" }; + sGuiInputConfigList[7] = + { "B", false, "B", ":/help/mbuttons_b_XBOX.svg" }; + sGuiInputConfigList[8] = + { "X", true, "X", ":/help/mbuttons_x_XBOX.svg" }; + sGuiInputConfigList[9] = + { "Y", true, "Y", ":/help/mbuttons_y_XBOX.svg" }; + } + else { + // Xbox One and later. + sGuiInputConfigList[4] = + { "Start", false, "MENU", ":/help/button_start_XBOX.svg" }; + sGuiInputConfigList[5] = + { "Select", false, "VIEW", ":/help/button_back_XBOX.svg" }; + sGuiInputConfigList[6] = + { "A", false, "A", ":/help/mbuttons_a_XBOX.svg" }; + sGuiInputConfigList[7] = + { "B", false, "B", ":/help/mbuttons_b_XBOX.svg" }; + sGuiInputConfigList[8] = + { "X", true, "X", ":/help/mbuttons_x_XBOX.svg" }; + sGuiInputConfigList[9] = + { "Y", true, "Y", ":/help/mbuttons_y_XBOX.svg" }; + } + + sGuiInputConfigList[10] = + { "LeftShoulder", true, "LEFT SHOULDER", ":/help/button_l.svg" }; + sGuiInputConfigList[11] = + { "RightShoulder", true, "RIGHT SHOULDER", ":/help/button_r.svg" }; + sGuiInputConfigList[12] = + { "LeftTrigger", true, "LEFT TRIGGER", ":/help/button_lt.svg" }; + sGuiInputConfigList[13] = + { "RightTrigger", true, "RIGHT TRIGGER", ":/help/button_rt.svg" }; + sGuiInputConfigList[14] = + { "LeftThumbstickUp", true, "LEFT THUMBSTICK UP", ":/help/thumbstick_up.svg" }; + sGuiInputConfigList[15] = + { "LeftThumbstickDown", true, "LEFT THUMBSTICK DOWN", ":/help/thumbstick_down.svg" }; + sGuiInputConfigList[16] = + { "LeftThumbstickLeft", true, "LEFT THUMBSTICK LEFT", ":/help/thumbstick_left.svg" }; + sGuiInputConfigList[17] = + { "LeftThumbstickRight", true, "LEFT THUMBSTICK RIGHT", ":/help/thumbstick_right.svg" }; + sGuiInputConfigList[18] = + { "LeftThumbstickClick", true, "LEFT THUMBSTICK CLICK", ":/help/thumbstick_click.svg" }; + sGuiInputConfigList[19] = + { "RightThumbstickUp", true, "RIGHT THUMBSTICK UP", ":/help/thumbstick_up.svg" }; + sGuiInputConfigList[20] = + { "RightThumbstickDown", true, "RIGHT THUMBSTICK DOWN", ":/help/thumbstick_down.svg" }; + sGuiInputConfigList[21] = + { "RightThumbstickLeft", true, "RIGHT THUMBSTICK LEFT", ":/help/thumbstick_left.svg" }; + sGuiInputConfigList[22] = + { "RightThumbstickRight", true, "RIGHT THUMBSTICK RIGHT", ":/help/thumbstick_right.svg" }; + sGuiInputConfigList[23] = + { "RightThumbstickClick", true, "RIGHT THUMBSTICK CLICK", ":/help/thumbstick_click.svg" }; +} + void GuiInputConfig::update(int deltaTime) { - if (mConfiguringRow && mHoldingInput && GUI_INPUT_CONFIG_LIST[mHeldInputId].skippable) { + if (mConfiguringRow && mHoldingInput && sGuiInputConfigList[mHeldInputId].skippable) { int prevSec = mHeldTime / 1000; mHeldTime += deltaTime; int curSec = mHeldTime / 1000; @@ -340,8 +431,8 @@ bool GuiInputConfig::assign(Input input, int inputId) // If this input is mapped to something other than "nothing" or the current row, // generate an error. (If it's the same as what it was before, allow it.) if (mTargetConfig->getMappedTo(input).size() > 0 && - !mTargetConfig->isMappedTo(GUI_INPUT_CONFIG_LIST[inputId].name, input) && - GUI_INPUT_CONFIG_LIST[inputId].name != "HotKeyEnable") { + !mTargetConfig->isMappedTo(sGuiInputConfigList[inputId].name, input) && + sGuiInputConfigList[inputId].name != "HotKeyEnable") { error(mMappings.at(inputId), "Already mapped!"); return false; } @@ -349,15 +440,15 @@ bool GuiInputConfig::assign(Input input, int inputId) setAssignedTo(mMappings.at(inputId), input); input.configured = true; - mTargetConfig->mapInput(GUI_INPUT_CONFIG_LIST[inputId].name, input); + mTargetConfig->mapInput(sGuiInputConfigList[inputId].name, input); LOG(LogInfo) << "Mapping [" << input.string() << "] to [" << - GUI_INPUT_CONFIG_LIST[inputId].name << "]"; + sGuiInputConfigList[inputId].name << "]"; return true; } void GuiInputConfig::clearAssignment(int inputId) { - mTargetConfig->unmapInput(GUI_INPUT_CONFIG_LIST[inputId].name); + mTargetConfig->unmapInput(sGuiInputConfigList[inputId].name); } diff --git a/es-core/src/guis/GuiInputConfig.h b/es-core/src/guis/GuiInputConfig.h index d05111af6..97c31b31e 100644 --- a/es-core/src/guis/GuiInputConfig.h +++ b/es-core/src/guis/GuiInputConfig.h @@ -22,6 +22,8 @@ public: GuiInputConfig(Window* window, InputConfig* target, bool reconfigureAll, const std::function& okCallback); + void populateConfigList(); + void update(int deltaTime) override; void onSizeChanged() override; diff --git a/resources/help/button_cross.svg b/resources/help/button_a_PS.svg similarity index 100% rename from resources/help/button_cross.svg rename to resources/help/button_a_PS.svg diff --git a/resources/help/button_b.svg b/resources/help/button_a_SNES.svg similarity index 100% rename from resources/help/button_b.svg rename to resources/help/button_a_SNES.svg diff --git a/resources/help/button_a.svg b/resources/help/button_a_XBOX.svg similarity index 100% rename from resources/help/button_a.svg rename to resources/help/button_a_XBOX.svg diff --git a/resources/help/button_circle.svg b/resources/help/button_b_PS.svg similarity index 100% rename from resources/help/button_circle.svg rename to resources/help/button_b_PS.svg diff --git a/resources/help/button_b_SNES.svg b/resources/help/button_b_SNES.svg new file mode 100644 index 000000000..c88ad1a3c --- /dev/null +++ b/resources/help/button_b_SNES.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/help/button_b_XBOX.svg b/resources/help/button_b_XBOX.svg new file mode 100644 index 000000000..115fd1919 --- /dev/null +++ b/resources/help/button_b_XBOX.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/help/button_back_PS4.svg b/resources/help/button_back_PS4.svg new file mode 100644 index 000000000..512e19d0f --- /dev/null +++ b/resources/help/button_back_PS4.svg @@ -0,0 +1,88 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/resources/help/button_back_PS5.svg b/resources/help/button_back_PS5.svg new file mode 100644 index 000000000..06a7d6ba6 --- /dev/null +++ b/resources/help/button_back_PS5.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/resources/help/button_back_SNES.svg b/resources/help/button_back_SNES.svg new file mode 100644 index 000000000..dead678c0 --- /dev/null +++ b/resources/help/button_back_SNES.svg @@ -0,0 +1,89 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/resources/help/button_back_XBOX.svg b/resources/help/button_back_XBOX.svg new file mode 100644 index 000000000..d82c9658f --- /dev/null +++ b/resources/help/button_back_XBOX.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/resources/help/button_back_XBOX360.svg b/resources/help/button_back_XBOX360.svg new file mode 100644 index 000000000..1b1e097ab --- /dev/null +++ b/resources/help/button_back_XBOX360.svg @@ -0,0 +1,57 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/resources/help/button_select.svg b/resources/help/button_select.svg deleted file mode 100644 index eba861d6c..000000000 --- a/resources/help/button_select.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/resources/help/button_start.svg b/resources/help/button_start.svg deleted file mode 100644 index 78fb5632e..000000000 --- a/resources/help/button_start.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/resources/help/button_start_PS4.svg b/resources/help/button_start_PS4.svg new file mode 100644 index 000000000..4378d292c --- /dev/null +++ b/resources/help/button_start_PS4.svg @@ -0,0 +1,98 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/resources/help/button_start_PS5.svg b/resources/help/button_start_PS5.svg new file mode 100644 index 000000000..d6239c885 --- /dev/null +++ b/resources/help/button_start_PS5.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/resources/help/button_start_SNES.svg b/resources/help/button_start_SNES.svg new file mode 100644 index 000000000..0ff66cc20 --- /dev/null +++ b/resources/help/button_start_SNES.svg @@ -0,0 +1,85 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/resources/help/button_start_XBOX.svg b/resources/help/button_start_XBOX.svg new file mode 100644 index 000000000..d6239c885 --- /dev/null +++ b/resources/help/button_start_XBOX.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/resources/help/button_start_XBOX360.svg b/resources/help/button_start_XBOX360.svg new file mode 100644 index 000000000..656deb9d2 --- /dev/null +++ b/resources/help/button_start_XBOX360.svg @@ -0,0 +1,56 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/resources/help/button_square.svg b/resources/help/button_x_PS.svg similarity index 100% rename from resources/help/button_square.svg rename to resources/help/button_x_PS.svg diff --git a/resources/help/button_y.svg b/resources/help/button_x_SNES.svg similarity index 100% rename from resources/help/button_y.svg rename to resources/help/button_x_SNES.svg diff --git a/resources/help/button_x.svg b/resources/help/button_x_XBOX.svg similarity index 100% rename from resources/help/button_x.svg rename to resources/help/button_x_XBOX.svg diff --git a/resources/help/button_triangle.svg b/resources/help/button_y_PS.svg similarity index 100% rename from resources/help/button_triangle.svg rename to resources/help/button_y_PS.svg diff --git a/resources/help/button_y_SNES.svg b/resources/help/button_y_SNES.svg new file mode 100644 index 000000000..c0898eb23 --- /dev/null +++ b/resources/help/button_y_SNES.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/help/button_y_XBOX.svg b/resources/help/button_y_XBOX.svg new file mode 100644 index 000000000..11ef2d2b8 --- /dev/null +++ b/resources/help/button_y_XBOX.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/help/buttons_south_PS.svg b/resources/help/mbuttons_a_PS.svg similarity index 100% rename from resources/help/buttons_south_PS.svg rename to resources/help/mbuttons_a_PS.svg diff --git a/resources/help/buttons_south_SNES.svg b/resources/help/mbuttons_a_SNES.svg similarity index 100% rename from resources/help/buttons_south_SNES.svg rename to resources/help/mbuttons_a_SNES.svg diff --git a/resources/help/buttons_south_XBOX.svg b/resources/help/mbuttons_a_XBOX.svg similarity index 100% rename from resources/help/buttons_south_XBOX.svg rename to resources/help/mbuttons_a_XBOX.svg diff --git a/resources/help/buttons_east_PS.svg b/resources/help/mbuttons_b_PS.svg similarity index 100% rename from resources/help/buttons_east_PS.svg rename to resources/help/mbuttons_b_PS.svg diff --git a/resources/help/buttons_east_SNES.svg b/resources/help/mbuttons_b_SNES.svg similarity index 100% rename from resources/help/buttons_east_SNES.svg rename to resources/help/mbuttons_b_SNES.svg diff --git a/resources/help/buttons_east_XBOX.svg b/resources/help/mbuttons_b_XBOX.svg similarity index 100% rename from resources/help/buttons_east_XBOX.svg rename to resources/help/mbuttons_b_XBOX.svg diff --git a/resources/help/buttons_west_PS.svg b/resources/help/mbuttons_x_PS.svg similarity index 100% rename from resources/help/buttons_west_PS.svg rename to resources/help/mbuttons_x_PS.svg diff --git a/resources/help/buttons_west_SNES.svg b/resources/help/mbuttons_x_SNES.svg similarity index 100% rename from resources/help/buttons_west_SNES.svg rename to resources/help/mbuttons_x_SNES.svg diff --git a/resources/help/buttons_west_XBOX.svg b/resources/help/mbuttons_x_XBOX.svg similarity index 100% rename from resources/help/buttons_west_XBOX.svg rename to resources/help/mbuttons_x_XBOX.svg diff --git a/resources/help/buttons_north_PS.svg b/resources/help/mbuttons_y_PS.svg similarity index 100% rename from resources/help/buttons_north_PS.svg rename to resources/help/mbuttons_y_PS.svg diff --git a/resources/help/buttons_north_SNES.svg b/resources/help/mbuttons_y_SNES.svg similarity index 100% rename from resources/help/buttons_north_SNES.svg rename to resources/help/mbuttons_y_SNES.svg diff --git a/resources/help/buttons_north_XBOX.svg b/resources/help/mbuttons_y_XBOX.svg similarity index 100% rename from resources/help/buttons_north_XBOX.svg rename to resources/help/mbuttons_y_XBOX.svg