diff options
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 24 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 2 |
2 files changed, 8 insertions, 18 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 352300e88..a64e63a39 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -401,12 +401,6 @@ qreal GRenderWindow::windowPixelRatio() const { | |||
| 401 | return devicePixelRatioF(); | 401 | return devicePixelRatioF(); |
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | std::pair<u32, u32> GRenderWindow::ScaleTouch(const QPointF& pos) const { | ||
| 405 | const qreal pixel_ratio = windowPixelRatio(); | ||
| 406 | return {static_cast<u32>(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})), | ||
| 407 | static_cast<u32>(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))}; | ||
| 408 | } | ||
| 409 | |||
| 410 | void GRenderWindow::closeEvent(QCloseEvent* event) { | 404 | void GRenderWindow::closeEvent(QCloseEvent* event) { |
| 411 | emit Closed(); | 405 | emit Closed(); |
| 412 | QWidget::closeEvent(event); | 406 | QWidget::closeEvent(event); |
| @@ -649,10 +643,9 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { | |||
| 649 | // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse | 643 | // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse |
| 650 | // coordinates and map them to the current render area | 644 | // coordinates and map them to the current render area |
| 651 | const auto pos = mapFromGlobal(QCursor::pos()); | 645 | const auto pos = mapFromGlobal(QCursor::pos()); |
| 652 | const auto [x, y] = ScaleTouch(pos); | 646 | const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); |
| 653 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); | ||
| 654 | const auto button = QtButtonToMouseButton(event->button()); | 647 | const auto button = QtButtonToMouseButton(event->button()); |
| 655 | input_subsystem->GetMouse()->PressButton(x, y, touch_x, touch_y, button); | 648 | input_subsystem->GetMouse()->PressButton(pos.x(), pos.y(), touch_x, touch_y, button); |
| 656 | 649 | ||
| 657 | emit MouseActivity(); | 650 | emit MouseActivity(); |
| 658 | } | 651 | } |
| @@ -665,11 +658,10 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | |||
| 665 | // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse | 658 | // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse |
| 666 | // coordinates and map them to the current render area | 659 | // coordinates and map them to the current render area |
| 667 | const auto pos = mapFromGlobal(QCursor::pos()); | 660 | const auto pos = mapFromGlobal(QCursor::pos()); |
| 668 | const auto [x, y] = ScaleTouch(pos); | 661 | const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); |
| 669 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); | ||
| 670 | const int center_x = width() / 2; | 662 | const int center_x = width() / 2; |
| 671 | const int center_y = height() / 2; | 663 | const int center_y = height() / 2; |
| 672 | input_subsystem->GetMouse()->MouseMove(x, y, touch_x, touch_y, center_x, center_y); | 664 | input_subsystem->GetMouse()->MouseMove(pos.x(), pos.y(), touch_x, touch_y, center_x, center_y); |
| 673 | 665 | ||
| 674 | if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) { | 666 | if (Settings::values.mouse_panning && !Settings::values.mouse_enabled) { |
| 675 | QCursor::setPos(mapToGlobal(QPoint{center_x, center_y})); | 667 | QCursor::setPos(mapToGlobal(QPoint{center_x, center_y})); |
| @@ -697,8 +689,8 @@ void GRenderWindow::wheelEvent(QWheelEvent* event) { | |||
| 697 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { | 689 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { |
| 698 | QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); | 690 | QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); |
| 699 | for (const auto& touch_point : touch_points) { | 691 | for (const auto& touch_point : touch_points) { |
| 700 | const auto [x, y] = ScaleTouch(touch_point.pos()); | 692 | const auto pos = touch_point.pos(); |
| 701 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); | 693 | const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); |
| 702 | input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, touch_point.id()); | 694 | input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, touch_point.id()); |
| 703 | } | 695 | } |
| 704 | } | 696 | } |
| @@ -707,8 +699,8 @@ void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) { | |||
| 707 | QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); | 699 | QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); |
| 708 | input_subsystem->GetTouchScreen()->ClearActiveFlag(); | 700 | input_subsystem->GetTouchScreen()->ClearActiveFlag(); |
| 709 | for (const auto& touch_point : touch_points) { | 701 | for (const auto& touch_point : touch_points) { |
| 710 | const auto [x, y] = ScaleTouch(touch_point.pos()); | 702 | const auto pos = touch_point.pos(); |
| 711 | const auto [touch_x, touch_y] = MapToTouchScreen(x, y); | 703 | const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); |
| 712 | input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, touch_point.id()); | 704 | input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, touch_point.id()); |
| 713 | } | 705 | } |
| 714 | input_subsystem->GetTouchScreen()->ReleaseInactiveTouch(); | 706 | input_subsystem->GetTouchScreen()->ReleaseInactiveTouch(); |
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 092c6206f..627e19f42 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -184,8 +184,6 @@ public: | |||
| 184 | 184 | ||
| 185 | void CaptureScreenshot(const QString& screenshot_path); | 185 | void CaptureScreenshot(const QString& screenshot_path); |
| 186 | 186 | ||
| 187 | std::pair<u32, u32> ScaleTouch(const QPointF& pos) const; | ||
| 188 | |||
| 189 | /** | 187 | /** |
| 190 | * Instructs the window to re-launch the application using the specified program_index. | 188 | * Instructs the window to re-launch the application using the specified program_index. |
| 191 | * @param program_index Specifies the index within the application of the program to launch. | 189 | * @param program_index Specifies the index within the application of the program to launch. |