From e6bd1fd1b8487e421f71d43b6073ee56de1a043d Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Tue, 14 Jul 2020 19:01:36 +0200 Subject: yuzu: Add motion and touch configuration --- src/input_common/touch_from_button.cpp | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/input_common/touch_from_button.cpp (limited to 'src/input_common/touch_from_button.cpp') diff --git a/src/input_common/touch_from_button.cpp b/src/input_common/touch_from_button.cpp new file mode 100644 index 000000000..8e7f90253 --- /dev/null +++ b/src/input_common/touch_from_button.cpp @@ -0,0 +1,49 @@ +// Copyright 2020 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/settings.h" +#include "input_common/touch_from_button.h" + +namespace InputCommon { + +class TouchFromButtonDevice final : public Input::TouchDevice { +public: + TouchFromButtonDevice() { + for (const auto& config_entry : + Settings::values.touch_from_button_maps[Settings::values.touch_from_button_map_index] + .buttons) { + const Common::ParamPackage package{config_entry}; + map.emplace_back( + Input::CreateDevice(config_entry), + std::clamp(package.Get("x", 0), 0, static_cast(Layout::ScreenUndocked::Width)), + std::clamp(package.Get("y", 0), 0, + static_cast(Layout::ScreenUndocked::Height))); + } + } + + std::tuple GetStatus() const override { + for (const auto& m : map) { + const bool state = std::get<0>(m)->GetStatus(); + if (state) { + const float x = static_cast(std::get<1>(m)) / + static_cast(Layout::ScreenUndocked::Width); + const float y = static_cast(std::get<2>(m)) / + static_cast(Layout::ScreenUndocked::Height); + return std::make_tuple(x, y, true); + } + } + return std::make_tuple(0.0f, 0.0f, false); + } + +private: + std::vector, int, int>> map; // button, x, y +}; + +std::unique_ptr TouchFromButtonFactory::Create( + const Common::ParamPackage& params) { + + return std::make_unique(); +} + +} // namespace InputCommon -- cgit v1.2.3 From d176feffad824bce20b694432ade28fe8273c8e4 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sat, 29 Aug 2020 20:56:51 +0200 Subject: Address review comments and fix code compilation --- src/input_common/touch_from_button.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/input_common/touch_from_button.cpp') diff --git a/src/input_common/touch_from_button.cpp b/src/input_common/touch_from_button.cpp index 8e7f90253..d028dfa0d 100644 --- a/src/input_common/touch_from_button.cpp +++ b/src/input_common/touch_from_button.cpp @@ -30,14 +30,15 @@ public: static_cast(Layout::ScreenUndocked::Width); const float y = static_cast(std::get<2>(m)) / static_cast(Layout::ScreenUndocked::Height); - return std::make_tuple(x, y, true); + return {x, y, true}; } } - return std::make_tuple(0.0f, 0.0f, false); + return {}; } private: - std::vector, int, int>> map; // button, x, y + // A vector of the mapped button, its x and its y-coordinate + std::vector, int, int>> map; }; std::unique_ptr TouchFromButtonFactory::Create( -- cgit v1.2.3 From d1e1ea0fef0ddfe914f14a2d547b922b71081695 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Sun, 30 Aug 2020 00:07:38 +0200 Subject: Address second batch of reviews --- src/input_common/touch_from_button.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/input_common/touch_from_button.cpp') diff --git a/src/input_common/touch_from_button.cpp b/src/input_common/touch_from_button.cpp index d028dfa0d..98da0ef1a 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 "core/frontend/framebuffer_layout.h" #include "core/settings.h" #include "input_common/touch_from_button.h" @@ -43,7 +44,6 @@ private: std::unique_ptr TouchFromButtonFactory::Create( const Common::ParamPackage& params) { - return std::make_unique(); } -- cgit v1.2.3