diff options
| author | 2021-01-02 22:04:50 -0600 | |
|---|---|---|
| committer | 2021-01-15 09:05:17 -0600 | |
| commit | 8495e1bd8373fed993975e40c360c87409455e9e (patch) | |
| tree | fffff1304673212280dc0e927b69efa3ca4fc8b3 /src/input_common/udp/client.cpp | |
| parent | Allow to return up to 16 touch inputs per engine (diff) | |
| download | yuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar.gz yuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar.xz yuzu-8495e1bd8373fed993975e40c360c87409455e9e.zip | |
Add mutitouch support for touch screens
Diffstat (limited to 'src/input_common/udp/client.cpp')
| -rw-r--r-- | src/input_common/udp/client.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
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 | ||
| 137 | Client::Client() { | 137 | Client::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 | ||
| 331 | std::optional<size_t> Client::GetUnusedFingerID() const { | 331 | std::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 | ||
| 343 | void Client::UpdateTouchInput(Response::TouchPad& touch_pad, size_t client, size_t id) { | 343 | void 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 | } |