summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/aboutdialog.ui2
-rw-r--r--src/yuzu/main.cpp40
-rw-r--r--src/yuzu/main.h3
3 files changed, 42 insertions, 3 deletions
diff --git a/src/yuzu/aboutdialog.ui b/src/yuzu/aboutdialog.ui
index 27d81cd13..2f7ddc7f3 100644
--- a/src/yuzu/aboutdialog.ui
+++ b/src/yuzu/aboutdialog.ui
@@ -87,7 +87,7 @@
87<html><head><meta name="qrichtext" content="1" /><style type="text/css"> 87<html><head><meta name="qrichtext" content="1" /><style type="text/css">
88p, li { white-space: pre-wrap; } 88p, li { white-space: pre-wrap; }
89</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> 89</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
90<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt;">yuzu is an experimental open-source emulator for the Nintendo Switch licensed under GPLv2.0.</span></p> 90<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:12pt;">yuzu is an experimental open-source emulator for the Nintendo Switch licensed under GPLv3.0+.</span></p>
91<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p> 91<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"><br /></p>
92&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt;&quot;&gt;This software should not be used to play games you have not legally obtained.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> 92&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt;&quot;&gt;This software should not be used to play games you have not legally obtained.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
93 </property> 93 </property>
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 52879a989..5e26aad29 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -152,7 +152,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
152} 152}
153#endif 153#endif
154 154
155constexpr int default_mouse_timeout = 2500; 155constexpr int default_mouse_hide_timeout = 2500;
156constexpr int default_mouse_center_timeout = 10;
156 157
157/** 158/**
158 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there 159 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there
@@ -287,10 +288,13 @@ GMainWindow::GMainWindow()
287 ui->menubar->setCursor(QCursor()); 288 ui->menubar->setCursor(QCursor());
288 statusBar()->setCursor(QCursor()); 289 statusBar()->setCursor(QCursor());
289 290
290 mouse_hide_timer.setInterval(default_mouse_timeout); 291 mouse_hide_timer.setInterval(default_mouse_hide_timeout);
291 connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); 292 connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
292 connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); 293 connect(ui->menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
293 294
295 mouse_center_timer.setInterval(default_mouse_center_timeout);
296 connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor);
297
294 MigrateConfigFiles(); 298 MigrateConfigFiles();
295 299
296#if defined(HAVE_SDL2) && !defined(_WIN32) 300#if defined(HAVE_SDL2) && !defined(_WIN32)
@@ -3301,10 +3305,26 @@ void GMainWindow::ShowMouseCursor() {
3301 } 3305 }
3302} 3306}
3303 3307
3308void GMainWindow::CenterMouseCursor() {
3309 if (emu_thread == nullptr || !Settings::values.mouse_panning) {
3310 mouse_center_timer.stop();
3311 return;
3312 }
3313 if (!this->isActiveWindow()) {
3314 mouse_center_timer.stop();
3315 return;
3316 }
3317 const int center_x = render_window->width() / 2;
3318 const int center_y = render_window->height() / 2;
3319
3320 QCursor::setPos(mapToGlobal({center_x, center_y}));
3321}
3322
3304void GMainWindow::OnMouseActivity() { 3323void GMainWindow::OnMouseActivity() {
3305 if (!Settings::values.mouse_panning) { 3324 if (!Settings::values.mouse_panning) {
3306 ShowMouseCursor(); 3325 ShowMouseCursor();
3307 } 3326 }
3327 mouse_center_timer.stop();
3308} 3328}
3309 3329
3310void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) { 3330void GMainWindow::OnCoreError(Core::SystemResultStatus result, std::string details) {
@@ -3577,6 +3597,22 @@ void GMainWindow::dragMoveEvent(QDragMoveEvent* event) {
3577 AcceptDropEvent(event); 3597 AcceptDropEvent(event);
3578} 3598}
3579 3599
3600void GMainWindow::leaveEvent(QEvent* event) {
3601 if (Settings::values.mouse_panning) {
3602 const QRect& rect = geometry();
3603 QPoint position = QCursor::pos();
3604
3605 qint32 x = qBound(rect.left(), position.x(), rect.right());
3606 qint32 y = qBound(rect.top(), position.y(), rect.bottom());
3607 // Only start the timer if the mouse has left the window bound.
3608 // The leave event is also triggered when the window looses focus.
3609 if (x != position.x() || y != position.y()) {
3610 mouse_center_timer.start();
3611 }
3612 event->accept();
3613 }
3614}
3615
3580bool GMainWindow::ConfirmChangeGame() { 3616bool GMainWindow::ConfirmChangeGame() {
3581 if (emu_thread == nullptr) 3617 if (emu_thread == nullptr)
3582 return true; 3618 return true;
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index ab95a7518..b399e9b01 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -328,6 +328,7 @@ private:
328 void UpdateUISettings(); 328 void UpdateUISettings();
329 void HideMouseCursor(); 329 void HideMouseCursor();
330 void ShowMouseCursor(); 330 void ShowMouseCursor();
331 void CenterMouseCursor();
331 void OpenURL(const QUrl& url); 332 void OpenURL(const QUrl& url);
332 void LoadTranslation(); 333 void LoadTranslation();
333 void OpenPerGameConfiguration(u64 title_id, const std::string& file_name); 334 void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
@@ -372,6 +373,7 @@ private:
372 bool auto_paused = false; 373 bool auto_paused = false;
373 bool auto_muted = false; 374 bool auto_muted = false;
374 QTimer mouse_hide_timer; 375 QTimer mouse_hide_timer;
376 QTimer mouse_center_timer;
375 377
376 // FS 378 // FS
377 std::shared_ptr<FileSys::VfsFilesystem> vfs; 379 std::shared_ptr<FileSys::VfsFilesystem> vfs;
@@ -418,4 +420,5 @@ protected:
418 void dropEvent(QDropEvent* event) override; 420 void dropEvent(QDropEvent* event) override;
419 void dragEnterEvent(QDragEnterEvent* event) override; 421 void dragEnterEvent(QDragEnterEvent* event) override;
420 void dragMoveEvent(QDragMoveEvent* event) override; 422 void dragMoveEvent(QDragMoveEvent* event) override;
423 void leaveEvent(QEvent* event) override;
421}; 424};