summaryrefslogtreecommitdiffstats
path: root/src/input_common/udp
diff options
context:
space:
mode:
authorgerman <german@thesoftwareartisans.com>2021-01-10 15:36:31 +0100
committergerman <german@thesoftwareartisans.com>2021-01-15 16:05:17 +0100
commitb483f2d010bf745ab873e8f8bfaca5515e56d39f (patch)
treed14bc19b4ca1c60460a941db612195be12f16b0d /src/input_common/udp
parentAdd mutitouch support for touch screens (diff)
downloadyuzu-b483f2d010bf745ab873e8f8bfaca5515e56d39f.tar
yuzu-b483f2d010bf745ab873e8f8bfaca5515e56d39f.tar.gz
yuzu-b483f2d010bf745ab873e8f8bfaca5515e56d39f.tar.bz2
yuzu-b483f2d010bf745ab873e8f8bfaca5515e56d39f.tar.lz
yuzu-b483f2d010bf745ab873e8f8bfaca5515e56d39f.tar.xz
yuzu-b483f2d010bf745ab873e8f8bfaca5515e56d39f.tar.zst
yuzu-b483f2d010bf745ab873e8f8bfaca5515e56d39f.zip
Diffstat (limited to 'src/input_common/udp')
-rw-r--r--src/input_common/udp/client.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index 5e39fdce2..e7e50d789 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -136,9 +136,7 @@ static void SocketLoop(Socket* socket) {
Client::Client() {
LOG_INFO(Input, "Udp Initialization started");
- for (std::size_t id = 0; id < MAX_TOUCH_FINGERS; ++id) {
- finger_id[id] = MAX_TOUCH_FINGERS;
- }
+ finger_id.fill(MAX_TOUCH_FINGERS);
ReloadSockets();
}
@@ -347,17 +345,17 @@ void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client,
const u16 min_y = static_cast<u16>(touch_param.Get("min_y", 50));
const u16 max_x = static_cast<u16>(touch_param.Get("max_x", 1800));
const u16 max_y = static_cast<u16>(touch_param.Get("max_y", 850));
-
+ const std::size_t touch_id = client * 2 + id;
if (touch_pad.is_active) {
- if (finger_id[client * 2 + id] == MAX_TOUCH_FINGERS) {
+ if (finger_id[touch_id] == MAX_TOUCH_FINGERS) {
const auto first_free_id = GetUnusedFingerID();
if (!first_free_id) {
// Invalid finger id skip to next input
return;
}
- finger_id[client * 2 + id] = first_free_id.value();
+ finger_id[touch_id] = *first_free_id;
}
- auto& [x, y, pressed] = touch_status[finger_id[client * 2 + id]];
+ auto& [x, y, pressed] = touch_status[finger_id[touch_id]];
x = static_cast<float>(std::clamp(static_cast<u16>(touch_pad.x), min_x, max_x) - min_x) /
static_cast<float>(max_x - min_x);
y = static_cast<float>(std::clamp(static_cast<u16>(touch_pad.y), min_y, max_y) - min_y) /
@@ -366,9 +364,9 @@ void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client,
return;
}
- if (finger_id[client * 2 + id] != MAX_TOUCH_FINGERS) {
- touch_status[finger_id[client * 2 + id]] = {};
- finger_id[client * 2 + id] = MAX_TOUCH_FINGERS;
+ if (finger_id[touch_id] != MAX_TOUCH_FINGERS) {
+ touch_status[finger_id[touch_id]] = {};
+ finger_id[touch_id] = MAX_TOUCH_FINGERS;
}
}