summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/touch_from_button.cpp4
-rw-r--r--src/input_common/udp/client.cpp19
-rw-r--r--src/input_common/udp/client.h8
3 files changed, 14 insertions, 17 deletions
diff --git a/src/input_common/touch_from_button.cpp b/src/input_common/touch_from_button.cpp
index 5226e70df..ffbe4f2ed 100644
--- a/src/input_common/touch_from_button.cpp
+++ b/src/input_common/touch_from_button.cpp
@@ -26,8 +26,8 @@ public:
26 } 26 }
27 27
28 Input::TouchStatus GetStatus() const override { 28 Input::TouchStatus GetStatus() const override {
29 Input::TouchStatus touch_status = {}; 29 Input::TouchStatus touch_status{};
30 for (size_t id = 0; id < map.size() && id < touch_status.size(); id++) { 30 for (std::size_t id = 0; id < map.size() && id < touch_status.size(); ++id) {
31 const bool state = std::get<0>(map[id])->GetStatus(); 31 const bool state = std::get<0>(map[id])->GetStatus();
32 if (state) { 32 if (state) {
33 const float x = static_cast<float>(std::get<1>(map[id])) / 33 const float x = static_cast<float>(std::get<1>(map[id])) /
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index 53648cb53..5e39fdce2 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -136,8 +136,8 @@ static void SocketLoop(Socket* socket) {
136 136
137Client::Client() { 137Client::Client() {
138 LOG_INFO(Input, "Udp Initialization started"); 138 LOG_INFO(Input, "Udp Initialization started");
139 for (size_t id = 0; id < MAX_TOUCH_FINGERS; id++) { 139 for (std::size_t id = 0; id < MAX_TOUCH_FINGERS; ++id) {
140 finger_id[id] = MAX_UDP_CLIENTS * 2; 140 finger_id[id] = MAX_TOUCH_FINGERS;
141 } 141 }
142 ReloadSockets(); 142 ReloadSockets();
143} 143}
@@ -262,7 +262,7 @@ void Client::OnPadData(Response::PadData data, std::size_t client) {
262 std::lock_guard guard(clients[client].status.update_mutex); 262 std::lock_guard guard(clients[client].status.update_mutex);
263 clients[client].status.motion_status = clients[client].motion.GetMotion(); 263 clients[client].status.motion_status = clients[client].motion.GetMotion();
264 264
265 for (size_t id = 0; id < data.touch.size(); id++) { 265 for (std::size_t id = 0; id < data.touch.size(); ++id) {
266 UpdateTouchInput(data.touch[id], client, id); 266 UpdateTouchInput(data.touch[id], client, id);
267 } 267 }
268 268
@@ -314,7 +314,7 @@ void Client::UpdateYuzuSettings(std::size_t client, const Common::Vec3<float>& a
314 .port = clients[client].port, 314 .port = clients[client].port,
315 .pad_index = clients[client].pad_index, 315 .pad_index = clients[client].pad_index,
316 }; 316 };
317 for (size_t i = 0; i < 3; ++i) { 317 for (std::size_t i = 0; i < 3; ++i) {
318 if (gyro[i] > 5.0f || gyro[i] < -5.0f) { 318 if (gyro[i] > 5.0f || gyro[i] < -5.0f) {
319 pad.motion = static_cast<PadMotion>(i); 319 pad.motion = static_cast<PadMotion>(i);
320 pad.motion_value = gyro[i]; 320 pad.motion_value = gyro[i];
@@ -328,8 +328,8 @@ void Client::UpdateYuzuSettings(std::size_t client, const Common::Vec3<float>& a
328 } 328 }
329} 329}
330 330
331std::optional<size_t> Client::GetUnusedFingerID() const { 331std::optional<std::size_t> Client::GetUnusedFingerID() const {
332 size_t first_free_id = 0; 332 std::size_t first_free_id = 0;
333 while (first_free_id < MAX_TOUCH_FINGERS) { 333 while (first_free_id < MAX_TOUCH_FINGERS) {
334 if (!std::get<2>(touch_status[first_free_id])) { 334 if (!std::get<2>(touch_status[first_free_id])) {
335 return first_free_id; 335 return first_free_id;
@@ -340,7 +340,7 @@ std::optional<size_t> Client::GetUnusedFingerID() const {
340 return std::nullopt; 340 return std::nullopt;
341} 341}
342 342
343void Client::UpdateTouchInput(Response::TouchPad& touch_pad, size_t client, size_t id) { 343void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, std::size_t id) {
344 // TODO: Use custom calibration per device 344 // TODO: Use custom calibration per device
345 const Common::ParamPackage touch_param(Settings::values.touch_device); 345 const Common::ParamPackage touch_param(Settings::values.touch_device);
346 const u16 min_x = static_cast<u16>(touch_param.Get("min_x", 100)); 346 const u16 min_x = static_cast<u16>(touch_param.Get("min_x", 100));
@@ -367,10 +367,7 @@ void Client::UpdateTouchInput(Response::TouchPad& touch_pad, size_t client, size
367 } 367 }
368 368
369 if (finger_id[client * 2 + id] != MAX_TOUCH_FINGERS) { 369 if (finger_id[client * 2 + id] != MAX_TOUCH_FINGERS) {
370 auto& [x, y, pressed] = touch_status[finger_id[client * 2 + id]]; 370 touch_status[finger_id[client * 2 + id]] = {};
371 x = 0;
372 y = 0;
373 pressed = false;
374 finger_id[client * 2 + id] = MAX_TOUCH_FINGERS; 371 finger_id[client * 2 + id] = MAX_TOUCH_FINGERS;
375 } 372 }
376} 373}
diff --git a/src/input_common/udp/client.h b/src/input_common/udp/client.h
index 1cd251ec8..822f9c550 100644
--- a/src/input_common/udp/client.h
+++ b/src/input_common/udp/client.h
@@ -28,8 +28,8 @@ class Socket;
28namespace Response { 28namespace Response {
29struct PadData; 29struct PadData;
30struct PortInfo; 30struct PortInfo;
31struct Version;
32struct TouchPad; 31struct TouchPad;
32struct Version;
33} // namespace Response 33} // namespace Response
34 34
35enum class PadMotion { 35enum class PadMotion {
@@ -129,10 +129,10 @@ private:
129 129
130 // Returns an unused finger id, if there is no fingers available std::nullopt will be 130 // Returns an unused finger id, if there is no fingers available std::nullopt will be
131 // returned 131 // returned
132 std::optional<size_t> GetUnusedFingerID() const; 132 std::optional<std::size_t> GetUnusedFingerID() const;
133 133
134 // Merges and updates all touch inputs into the touch_status array 134 // Merges and updates all touch inputs into the touch_status array
135 void UpdateTouchInput(Response::TouchPad& touch_pad, size_t client, size_t id); 135 void UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, std::size_t id);
136 136
137 bool configuring = false; 137 bool configuring = false;
138 138
@@ -143,7 +143,7 @@ private:
143 std::array<ClientData, MAX_UDP_CLIENTS> clients{}; 143 std::array<ClientData, MAX_UDP_CLIENTS> clients{};
144 Common::SPSCQueue<UDPPadStatus> pad_queue{}; 144 Common::SPSCQueue<UDPPadStatus> pad_queue{};
145 Input::TouchStatus touch_status{}; 145 Input::TouchStatus touch_status{};
146 std::array<size_t, MAX_TOUCH_FINGERS> finger_id{}; 146 std::array<std::size_t, MAX_TOUCH_FINGERS> finger_id{};
147}; 147};
148 148
149/// An async job allowing configuration of the touchpad calibration. 149/// An async job allowing configuration of the touchpad calibration.