diff options
author | german77 <juangerman-13@hotmail.com> | 2022-05-22 20:34:32 -0500 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2022-05-23 11:01:14 -0500 |
commit | c82806f9cb88f390ae3fb048ba7ff2bb138fa3ec (patch) | |
tree | 60f52dfd3e59f1424d03ab71a8cb28b9b845d486 /src/yuzu/bootmanager.cpp | |
parent | 4eb7f6c04473e3f90e2622ee00b822febe1ccef9 (diff) |
input_common: touch: Rewrite touch driver to support multiple touch points
Diffstat (limited to 'src/yuzu/bootmanager.cpp')
-rw-r--r-- | src/yuzu/bootmanager.cpp | 58 |
1 files changed, 9 insertions, 49 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index a1b819ae0c..8f0a6bbb8b 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -772,65 +772,25 @@ void GRenderWindow::wheelEvent(QWheelEvent* event) { void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); for (const auto& touch_point : touch_points) { - if (!TouchUpdate(touch_point)) { - TouchStart(touch_point); - } + const auto [x, y] = ScaleTouch(touch_point.pos()); + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); + input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, touch_point.id()); } } void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) { QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); + input_subsystem->GetTouchScreen()->ClearActiveFlag(); for (const auto& touch_point : touch_points) { - if (!TouchUpdate(touch_point)) { - TouchStart(touch_point); - } - } - // Release all inactive points - for (std::size_t id = 0; id < touch_ids.size(); ++id) { - if (!TouchExist(touch_ids[id], touch_points)) { - touch_ids[id] = 0; - input_subsystem->GetTouchScreen()->TouchReleased(id); - } + const auto [x, y] = ScaleTouch(touch_point.pos()); + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); + input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, touch_point.id()); } + input_subsystem->GetTouchScreen()->ReleaseInactiveTouch(); } void GRenderWindow::TouchEndEvent() { - for (std::size_t id = 0; id < touch_ids.size(); ++id) { - if (touch_ids[id] != 0) { - touch_ids[id] = 0; - input_subsystem->GetTouchScreen()->TouchReleased(id); - } - } -} - -void GRenderWindow::TouchStart(const QTouchEvent::TouchPoint& touch_point) { - for (std::size_t id = 0; id < touch_ids.size(); ++id) { - if (touch_ids[id] == 0) { - touch_ids[id] = touch_point.id() + 1; - const auto [x, y] = ScaleTouch(touch_point.pos()); - const auto [touch_x, touch_y] = MapToTouchScreen(x, y); - input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, id); - } - } -} - -bool GRenderWindow::TouchUpdate(const QTouchEvent::TouchPoint& touch_point) { - for (std::size_t id = 0; id < touch_ids.size(); ++id) { - if (touch_ids[id] == static_cast<std::size_t>(touch_point.id() + 1)) { - const auto [x, y] = ScaleTouch(touch_point.pos()); - const auto [touch_x, touch_y] = MapToTouchScreen(x, y); - input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, id); - return true; - } - } - return false; -} - -bool GRenderWindow::TouchExist(std::size_t id, - const QList<QTouchEvent::TouchPoint>& touch_points) const { - return std::any_of(touch_points.begin(), touch_points.end(), [id](const auto& point) { - return id == static_cast<std::size_t>(point.id() + 1); - }); + input_subsystem->GetTouchScreen()->ReleaseAllTouch(); } bool GRenderWindow::event(QEvent* event) { |