summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/frontend/emu_window.cpp5
-rw-r--r--src/core/frontend/emu_window.h9
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp6
-rw-r--r--src/input_common/udp/client.cpp18
-rw-r--r--src/yuzu/bootmanager.cpp7
5 files changed, 20 insertions, 25 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp
index af6c1633a..ee7a58b1c 100644
--- a/src/core/frontend/emu_window.cpp
+++ b/src/core/frontend/emu_window.cpp
@@ -28,12 +28,11 @@ private:
28 public: 28 public:
29 explicit Device(std::weak_ptr<TouchState>&& touch_state) : touch_state(touch_state) {} 29 explicit Device(std::weak_ptr<TouchState>&& touch_state) : touch_state(touch_state) {}
30 Input::TouchStatus GetStatus() const override { 30 Input::TouchStatus GetStatus() const override {
31 Input::TouchStatus touch_status{};
32 if (auto state = touch_state.lock()) { 31 if (auto state = touch_state.lock()) {
33 std::lock_guard guard{state->mutex}; 32 std::lock_guard guard{state->mutex};
34 touch_status = state->status; 33 return state->status;
35 } 34 }
36 return touch_status; 35 return {};
37 } 36 }
38 37
39 private: 38 private:
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index f8db42ab4..2436c6580 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -117,12 +117,13 @@ public:
117 * Signal that a touch pressed event has occurred (e.g. mouse click pressed) 117 * Signal that a touch pressed event has occurred (e.g. mouse click pressed)
118 * @param framebuffer_x Framebuffer x-coordinate that was pressed 118 * @param framebuffer_x Framebuffer x-coordinate that was pressed
119 * @param framebuffer_y Framebuffer y-coordinate that was pressed 119 * @param framebuffer_y Framebuffer y-coordinate that was pressed
120 * @param id Touch event id 120 * @param id Touch event ID
121 */ 121 */
122 void TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id); 122 void TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id);
123 123
124 /** Signal that a touch released event has occurred (e.g. mouse click released) 124 /**
125 *@param id Touch event id 125 * Signal that a touch released event has occurred (e.g. mouse click released)
126 * @param id Touch event ID
126 */ 127 */
127 void TouchReleased(std::size_t id); 128 void TouchReleased(std::size_t id);
128 129
@@ -130,7 +131,7 @@ public:
130 * Signal that a touch movement event has occurred (e.g. mouse was moved over the emu window) 131 * Signal that a touch movement event has occurred (e.g. mouse was moved over the emu window)
131 * @param framebuffer_x Framebuffer x-coordinate 132 * @param framebuffer_x Framebuffer x-coordinate
132 * @param framebuffer_y Framebuffer y-coordinate 133 * @param framebuffer_y Framebuffer y-coordinate
133 * @param id Touch event id 134 * @param id Touch event ID
134 */ 135 */
135 void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id); 136 void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id);
136 137
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp
index cd318f25b..5219f2dad 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.cpp
+++ b/src/core/hle/service/hid/controllers/touchscreen.cpp
@@ -100,11 +100,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin
100void Controller_Touchscreen::OnLoadInputDevices() { 100void Controller_Touchscreen::OnLoadInputDevices() {
101 touch_mouse_device = Input::CreateDevice<Input::TouchDevice>("engine:emu_window"); 101 touch_mouse_device = Input::CreateDevice<Input::TouchDevice>("engine:emu_window");
102 touch_udp_device = Input::CreateDevice<Input::TouchDevice>("engine:cemuhookudp"); 102 touch_udp_device = Input::CreateDevice<Input::TouchDevice>("engine:cemuhookudp");
103 if (Settings::values.use_touch_from_button) { 103 touch_btn_device = Input::CreateDevice<Input::TouchDevice>("engine:touch_from_button");
104 touch_btn_device = Input::CreateDevice<Input::TouchDevice>("engine:touch_from_button");
105 } else {
106 touch_btn_device.reset();
107 }
108} 104}
109 105
110std::optional<std::size_t> Controller_Touchscreen::GetUnusedFingerID() const { 106std::optional<std::size_t> Controller_Touchscreen::GetUnusedFingerID() const {
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
137Client::Client() { 137Client::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
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 1f91514ef..4528eb196 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -475,7 +475,7 @@ bool GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) {
475 475
476bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) { 476bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) {
477 for (std::size_t id = 0; id < touch_ids.size(); ++id) { 477 for (std::size_t id = 0; id < touch_ids.size(); ++id) {
478 if (touch_ids[id] == touch_point.id() + 1) { 478 if (touch_ids[id] == static_cast<std::size_t>(touch_point.id() + 1)) {
479 const auto [x, y] = ScaleTouch(touch_point.pos()); 479 const auto [x, y] = ScaleTouch(touch_point.pos());
480 this->TouchMoved(x, y, id + 1); 480 this->TouchMoved(x, y, id + 1);
481 return true; 481 return true;
@@ -486,8 +486,9 @@ bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) {
486 486
487bool GRenderWindow::TouchExist(std::size_t id, 487bool GRenderWindow::TouchExist(std::size_t id,
488 const QList<QTouchEvent::TouchPoint>& touch_points) const { 488 const QList<QTouchEvent::TouchPoint>& touch_points) const {
489 return std::any_of(touch_points.begin(), touch_points.end(), 489 return std::any_of(touch_points.begin(), touch_points.end(), [id](const auto& point) {
490 [id](const auto& point) { return id == point.id() + 1; }); 490 return id == static_cast<std::size_t>(point.id() + 1);
491 });
491} 492}
492 493
493bool GRenderWindow::event(QEvent* event) { 494bool GRenderWindow::event(QEvent* event) {