summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/touch_screen.cpp
diff options
context:
space:
mode:
authorGravatar german772021-09-20 17:20:56 -0500
committerGravatar Narr the Reg2021-11-24 20:30:22 -0600
commitfa8e23b84281022bf6b4e8916231a17e9997e5aa (patch)
treed74ffb84e5c2e391963db69bcdfb94be42edeac1 /src/input_common/drivers/touch_screen.cpp
parentinput_common: Rewrite mouse (diff)
downloadyuzu-fa8e23b84281022bf6b4e8916231a17e9997e5aa.tar.gz
yuzu-fa8e23b84281022bf6b4e8916231a17e9997e5aa.tar.xz
yuzu-fa8e23b84281022bf6b4e8916231a17e9997e5aa.zip
input_common: Rewrite touch
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