From ae246aa03de8f5d31d008785f64564dae4bf3138 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 13 Sep 2026 03:47:53 +0000 Subject: [PATCH] 2026-09-13 03:47:52 Signed-off-by: lizzie --- src/yuzu/bootmanager.cpp | 18 ++++++++++-------- src/yuzu/bootmanager.h | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 05ed5a437e..578258c906 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -73,6 +73,7 @@ class QPaintEngine; class QSurface; constexpr int default_mouse_constrain_timeout = 10; +constexpr int default_mouse_update_timeout = 10; class RenderWidget : public QWidget { public: @@ -138,6 +139,10 @@ GRenderWindow::GRenderWindow(MainWindow* parent, mouse_constrain_timer.setInterval(default_mouse_constrain_timeout); connect(&mouse_constrain_timer, &QTimer::timeout, this, &GRenderWindow::ConstrainMouse); + + mouse_update_timer.setInterval(default_mouse_update_timeout); + connect(&mouse_update_timer, &QTimer::timeout, this, &GRenderWindow::UpdateMouse); + mouse_update_timer.start(); } void GRenderWindow::ExecuteProgram(std::size_t program_index) { @@ -518,8 +523,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { // Constrain mouse for mouse emulation with mouse panning if (Settings::values.mouse_panning && Settings::values.mouse_enabled) { const auto [clamped_mouse_x, clamped_mouse_y] = ClipToTouchScreen(x, y); - QCursor::setPos(mapToGlobal( - QPoint{static_cast(clamped_mouse_x), static_cast(clamped_mouse_y)})); + QCursor::setPos(mapToGlobal(QPoint{int(clamped_mouse_x), int(clamped_mouse_y)})); } mouse_constrain_timer.stop(); @@ -538,12 +542,7 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { } void GRenderWindow::ConstrainMouse() { - if (QtCommon::emu_thread == nullptr || !Settings::values.mouse_panning) { - mouse_constrain_timer.stop(); - return; - } - - if (!this->isActiveWindow()) { + if (QtCommon::emu_thread == nullptr || Settings::values.mouse_panning || !this->isActiveWindow()) { mouse_constrain_timer.stop(); return; } @@ -558,6 +557,9 @@ void GRenderWindow::ConstrainMouse() { const int center_y = height() / 2; QCursor::setPos(mapToGlobal(QPoint{center_x, center_y})); } +} + +void GRenderWindow::UpdateMouse() { input_subsystem->GetMouse()->NotifyChanged(); // required to reset mouse once it's no longer moved } diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 1ed61a8191..bb18bbb3bb 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -144,6 +144,7 @@ private: void TouchUpdateEvent(const QTouchEvent* event); void TouchEndEvent(); void ConstrainMouse(); + void UpdateMouse(); void RequestCameraCapture(); void OnCameraCapture(int requestId, const QImage& img); @@ -184,6 +185,7 @@ private: #endif QTimer mouse_constrain_timer; + QTimer mouse_update_timer; protected: void showEvent(QShowEvent* event) override;