diff --git a/src/input_common/touch_from_button.cpp b/src/input_common/touch_from_button.cpp index 3f731f624..7d17b9081 100644 --- a/src/input_common/touch_from_button.cpp +++ b/src/input_common/touch_from_button.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/string_util.h" #include "core/3ds.h" #include "core/settings.h" #include "input_common/touch_from_button.h" @@ -17,8 +18,21 @@ public: .touch_from_button_map_index] .buttons) { + std::vector buttons{config_entry}; + if (config_entry.find("[") != std::string::npos) { + Common::SplitString( + config_entry.substr(config_entry.find("[") + 1, + config_entry.find("]") - (config_entry.find("[") + 1)), + '|', buttons); + } + + std::vector> devices{}; + for (auto& button : buttons) { + devices.emplace_back(Input::CreateDevice(button)); + } + const Common::ParamPackage package{config_entry}; - map.emplace_back(Input::CreateDevice(config_entry), + map.emplace_back(std::move(devices), std::clamp(package.Get("x", 0), 0, Core::kScreenBottomWidth), std::clamp(package.Get("y", 0), 0, Core::kScreenBottomHeight)); } @@ -26,7 +40,13 @@ public: std::tuple GetStatus() const override { for (const auto& m : map) { - const bool state = std::get<0>(m)->GetStatus(); + bool state = true; + for (const auto& device : std::get<0>(m)) { + state &= device->GetStatus(); + if (!state) { + break; + } + } if (state) { const float x = static_cast(std::get<1>(m)) / Core::kScreenBottomWidth; const float y = static_cast(std::get<2>(m)) / Core::kScreenBottomHeight; @@ -37,7 +57,8 @@ public: } private: - std::vector, int, int>> map; // button, x, y + std::vector>, int, int>> + map; // buttons, x, y }; std::unique_ptr TouchFromButtonFactory::Create(