diff options
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/udp/client.cpp | 18 |
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) { | |||
| 136 | 136 | ||
| 137 | Client::Client() { | 137 | Client::Client() { |
| 138 | LOG_INFO(Input, "Udp Initialization started"); | 138 | LOG_INFO(Input, "Udp Initialization started"); |
| 139 | for (std::size_t id = 0; id < MAX_TOUCH_FINGERS; ++id) { | 139 | finger_id.fill(MAX_TOUCH_FINGERS); |
| 140 | finger_id[id] = MAX_TOUCH_FINGERS; | ||
| 141 | } | ||
| 142 | ReloadSockets(); | 140 | ReloadSockets(); |
| 143 | } | 141 | } |
| 144 | 142 | ||
| @@ -347,17 +345,17 @@ void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, | |||
| 347 | const u16 min_y = static_cast<u16>(touch_param.Get("min_y", 50)); | 345 | const u16 min_y = static_cast<u16>(touch_param.Get("min_y", 50)); |
| 348 | const u16 max_x = static_cast<u16>(touch_param.Get("max_x", 1800)); | 346 | const u16 max_x = static_cast<u16>(touch_param.Get("max_x", 1800)); |
| 349 | const u16 max_y = static_cast<u16>(touch_param.Get("max_y", 850)); | 347 | const u16 max_y = static_cast<u16>(touch_param.Get("max_y", 850)); |
| 350 | 348 | const std::size_t touch_id = client * 2 + id; | |
| 351 | if (touch_pad.is_active) { | 349 | if (touch_pad.is_active) { |
| 352 | if (finger_id[client * 2 + id] == MAX_TOUCH_FINGERS) { | 350 | if (finger_id[touch_id] == MAX_TOUCH_FINGERS) { |
| 353 | const auto first_free_id = GetUnusedFingerID(); | 351 | const auto first_free_id = GetUnusedFingerID(); |
| 354 | if (!first_free_id) { | 352 | if (!first_free_id) { |
| 355 | // Invalid finger id skip to next input | 353 | // Invalid finger id skip to next input |
| 356 | return; | 354 | return; |
| 357 | } | 355 | } |
| 358 | finger_id[client * 2 + id] = first_free_id.value(); | 356 | finger_id[touch_id] = *first_free_id; |
| 359 | } | 357 | } |
| 360 | auto& [x, y, pressed] = touch_status[finger_id[client * 2 + id]]; | 358 | auto& [x, y, pressed] = touch_status[finger_id[touch_id]]; |
| 361 | x = static_cast<float>(std::clamp(static_cast<u16>(touch_pad.x), min_x, max_x) - min_x) / | 359 | x = static_cast<float>(std::clamp(static_cast<u16>(touch_pad.x), min_x, max_x) - min_x) / |
| 362 | static_cast<float>(max_x - min_x); | 360 | static_cast<float>(max_x - min_x); |
| 363 | y = static_cast<float>(std::clamp(static_cast<u16>(touch_pad.y), min_y, max_y) - min_y) / | 361 | 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, | |||
| 366 | return; | 364 | return; |
| 367 | } | 365 | } |
| 368 | 366 | ||
| 369 | if (finger_id[client * 2 + id] != MAX_TOUCH_FINGERS) { | 367 | if (finger_id[touch_id] != MAX_TOUCH_FINGERS) { |
| 370 | touch_status[finger_id[client * 2 + id]] = {}; | 368 | touch_status[finger_id[touch_id]] = {}; |
| 371 | finger_id[client * 2 + id] = MAX_TOUCH_FINGERS; | 369 | finger_id[touch_id] = MAX_TOUCH_FINGERS; |
| 372 | } | 370 | } |
| 373 | } | 371 | } |
| 374 | 372 | ||