From b483f2d010bf745ab873e8f8bfaca5515e56d39f Mon Sep 17 00:00:00 2001 From: german Date: Sun, 10 Jan 2021 08:36:31 -0600 Subject: Always initialize keyboard input --- src/input_common/udp/client.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/input_common/udp/client.cpp') 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(touch_param.Get("min_y", 50)); const u16 max_x = static_cast(touch_param.Get("max_x", 1800)); const u16 max_y = static_cast(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(std::clamp(static_cast(touch_pad.x), min_x, max_x) - min_x) / static_cast(max_x - min_x); y = static_cast(std::clamp(static_cast(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; } } -- cgit v1.2.3