summaryrefslogtreecommitdiff
path: root/src/input_common/touch_from_button.cpp
diff options
context:
space:
mode:
authorGravatar german772021-09-20 16:57:55 -0500
committerGravatar Narr the Reg2021-11-24 20:30:22 -0600
commit4c6f2c2547e1d97f12ebe708fac693a6183bbc45 (patch)
tree0abcd35f56088bbf732a92838995a465bae0f0ee /src/input_common/touch_from_button.cpp
parentinput_common: Create input poller and mapping (diff)
downloadyuzu-4c6f2c2547e1d97f12ebe708fac693a6183bbc45.tar.gz
yuzu-4c6f2c2547e1d97f12ebe708fac693a6183bbc45.tar.xz
yuzu-4c6f2c2547e1d97f12ebe708fac693a6183bbc45.zip
input_common: Move touch and analog from button. Move udp protocol
Diffstat (limited to 'src/input_common/touch_from_button.cpp')
-rw-r--r--src/input_common/touch_from_button.cpp53
1 files changed, 0 insertions, 53 deletions
diff --git a/src/input_common/touch_from_button.cpp b/src/input_common/touch_from_button.cpp
deleted file mode 100644
index 7878a56d7..000000000
--- a/src/input_common/touch_from_button.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
1// Copyright 2020 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <algorithm>
6#include "common/settings.h"
7#include "core/frontend/framebuffer_layout.h"
8#include "input_common/touch_from_button.h"
9
10namespace InputCommon {
11
12class TouchFromButtonDevice final : public Input::TouchDevice {
13public:
14 TouchFromButtonDevice() {
15 const auto button_index =
16 static_cast<u64>(Settings::values.touch_from_button_map_index.GetValue());
17 const auto& buttons = Settings::values.touch_from_button_maps[button_index].buttons;
18
19 for (const auto& config_entry : buttons) {
20 const Common::ParamPackage package{config_entry};
21 map.emplace_back(
22 Input::CreateDevice<Input::ButtonDevice>(config_entry),
23 std::clamp(package.Get("x", 0), 0, static_cast<int>(Layout::ScreenUndocked::Width)),
24 std::clamp(package.Get("y", 0), 0,
25 static_cast<int>(Layout::ScreenUndocked::Height)));
26 }
27 }
28
29 Input::TouchStatus GetStatus() const override {
30 Input::TouchStatus touch_status{};
31 for (std::size_t id = 0; id < map.size() && id < touch_status.size(); ++id) {
32 const bool state = std::get<0>(map[id])->GetStatus();
33 if (state) {
34 const float x = static_cast<float>(std::get<1>(map[id])) /
35 static_cast<int>(Layout::ScreenUndocked::Width);
36 const float y = static_cast<float>(std::get<2>(map[id])) /
37 static_cast<int>(Layout::ScreenUndocked::Height);
38 touch_status[id] = {x, y, true};
39 }
40 }
41 return touch_status;
42 }
43
44private:
45 // A vector of the mapped button, its x and its y-coordinate
46 std::vector<std::tuple<std::unique_ptr<Input::ButtonDevice>, int, int>> map;
47};
48
49std::unique_ptr<Input::TouchDevice> TouchFromButtonFactory::Create(const Common::ParamPackage&) {
50 return std::make_unique<TouchFromButtonDevice>();
51}
52
53} // namespace InputCommon