summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/touch_screen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers/touch_screen.cpp')
-rw-r--r--src/input_common/drivers/touch_screen.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/input_common/drivers/touch_screen.cpp b/src/input_common/drivers/touch_screen.cpp
new file mode 100644
index 000000000..e13835e9f
--- /dev/null
+++ b/src/input_common/drivers/touch_screen.cpp
@@ -0,0 +1,47 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included
4
5#include "common/param_package.h"
6#include "input_common/drivers/touch_screen.h"
7
8namespace InputCommon {
9
10TouchScreen::TouchScreen(const std::string input_engine_) : InputEngine(input_engine_) {
11 PreSetController(identifier);
12}
13
14void TouchScreen::TouchMoved(float x, float y, std::size_t finger) {
15 if (finger >= 16) {
16 return;
17 }
18 TouchPressed(x, y, finger);
19}
20
21void TouchScreen::TouchPressed(float x, float y, std::size_t finger) {
22 if (finger >= 16) {
23 return;
24 }
25 SetButton(identifier, static_cast<int>(finger), true);
26 SetAxis(identifier, static_cast<int>(finger * 2), x);
27 SetAxis(identifier, static_cast<int>(finger * 2 + 1), y);
28}
29
30void TouchScreen::TouchReleased(std::size_t finger) {
31 if (finger >= 16) {
32 return;
33 }
34 SetButton(identifier, static_cast<int>(finger), false);
35 SetAxis(identifier, static_cast<int>(finger * 2), 0.0f);
36 SetAxis(identifier, static_cast<int>(finger * 2 + 1), 0.0f);
37}
38
39void TouchScreen::ReleaseAllTouch() {
40 for (int index = 0; index < 16; ++index) {
41 SetButton(identifier, index, false);
42 SetAxis(identifier, index * 2, 0.0f);
43 SetAxis(identifier, index * 2 + 1, 0.0f);
44 }
45}
46
47} // namespace InputCommon