From 2dc56490ff27b0fd6fe61fae1ea801c99f71fc48 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 20 Feb 2023 16:29:21 +0100 Subject: [PATCH] early-access version 3411 --- README.md | 2 +- src/yuzu/bootmanager.cpp | 20 ++++++++++++++------ src/yuzu/bootmanager.h | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7e7804789..b420df375 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3410. +This is the source code for early-access 3411. ## Legal Notice diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 421ed6f4b..2e08e3bd4 100755 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -401,6 +401,12 @@ qreal GRenderWindow::windowPixelRatio() const { return devicePixelRatioF(); } +std::pair GRenderWindow::ScaleTouch(const QPointF& pos) const { + const qreal pixel_ratio = windowPixelRatio(); + return {static_cast(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})), + static_cast(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))}; +} + void GRenderWindow::closeEvent(QCloseEvent* event) { emit Closed(); QWidget::closeEvent(event); @@ -643,7 +649,8 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse // coordinates and map them to the current render area const auto pos = mapFromGlobal(QCursor::pos()); - const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); + const auto [x, y] = ScaleTouch(pos); + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); const auto button = QtButtonToMouseButton(event->button()); input_subsystem->GetMouse()->PressMouseButton(button); @@ -661,7 +668,8 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse // coordinates and map them to the current render area const auto pos = mapFromGlobal(QCursor::pos()); - const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); + const auto [x, y] = ScaleTouch(pos); + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); const int center_x = width() / 2; const int center_y = height() / 2; @@ -695,8 +703,8 @@ void GRenderWindow::wheelEvent(QWheelEvent* event) { void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { QList touch_points = event->touchPoints(); for (const auto& touch_point : touch_points) { - const auto pos = touch_point.pos(); - const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); + 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()); } } @@ -705,8 +713,8 @@ void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) { QList touch_points = event->touchPoints(); input_subsystem->GetTouchScreen()->ClearActiveFlag(); for (const auto& touch_point : touch_points) { - const auto pos = touch_point.pos(); - const auto [touch_x, touch_y] = MapToTouchScreen(pos.x(), pos.y()); + 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(); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index bd78e5e83..d91f94ccc 100755 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -147,6 +147,8 @@ public: qreal windowPixelRatio() const; + std::pair ScaleTouch(const QPointF& pos) const; + void closeEvent(QCloseEvent* event) override; void resizeEvent(QResizeEvent* event) override;