diff options
Diffstat (limited to '')
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_general.ui | 7 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 56 | ||||
| -rw-r--r-- | src/yuzu/main.h | 5 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 1 |
7 files changed, 78 insertions, 0 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1cac2f942..3d759f77b 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -292,6 +292,8 @@ GRenderWindow::GRenderWindow(GMainWindow* parent_, EmuThread* emu_thread_) | |||
| 292 | setLayout(layout); | 292 | setLayout(layout); |
| 293 | InputCommon::Init(); | 293 | InputCommon::Init(); |
| 294 | 294 | ||
| 295 | this->setMouseTracking(true); | ||
| 296 | |||
| 295 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete); | 297 | connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete); |
| 296 | } | 298 | } |
| 297 | 299 | ||
| @@ -385,6 +387,7 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { | |||
| 385 | } else if (event->button() == Qt::RightButton) { | 387 | } else if (event->button() == Qt::RightButton) { |
| 386 | InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); | 388 | InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); |
| 387 | } | 389 | } |
| 390 | QWidget::mousePressEvent(event); | ||
| 388 | } | 391 | } |
| 389 | 392 | ||
| 390 | void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | 393 | void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { |
| @@ -397,6 +400,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { | |||
| 397 | const auto [x, y] = ScaleTouch(pos); | 400 | const auto [x, y] = ScaleTouch(pos); |
| 398 | this->TouchMoved(x, y); | 401 | this->TouchMoved(x, y); |
| 399 | InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); | 402 | InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); |
| 403 | QWidget::mouseMoveEvent(event); | ||
| 400 | } | 404 | } |
| 401 | 405 | ||
| 402 | void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { | 406 | void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 3b9ab38dd..946aa287a 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -740,6 +740,8 @@ void Config::ReadUIValues() { | |||
| 740 | UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); | 740 | UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); |
| 741 | UISettings::values.pause_when_in_background = | 741 | UISettings::values.pause_when_in_background = |
| 742 | ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool(); | 742 | ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool(); |
| 743 | UISettings::values.hide_mouse = | ||
| 744 | ReadSetting(QStringLiteral("hideInactiveMouse"), false).toBool(); | ||
| 743 | 745 | ||
| 744 | ApplyDefaultProfileIfInputInvalid(); | 746 | ApplyDefaultProfileIfInputInvalid(); |
| 745 | 747 | ||
| @@ -1164,6 +1166,7 @@ void Config::SaveUIValues() { | |||
| 1164 | WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); | 1166 | WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); |
| 1165 | WriteSetting(QStringLiteral("pauseWhenInBackground"), | 1167 | WriteSetting(QStringLiteral("pauseWhenInBackground"), |
| 1166 | UISettings::values.pause_when_in_background, false); | 1168 | UISettings::values.pause_when_in_background, false); |
| 1169 | WriteSetting(QStringLiteral("hideInactiveMouse"), UISettings::values.hide_mouse, false); | ||
| 1167 | 1170 | ||
| 1168 | qt_config->endGroup(); | 1171 | qt_config->endGroup(); |
| 1169 | } | 1172 | } |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 5ef927114..cb95423e0 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -26,6 +26,7 @@ void ConfigureGeneral::SetConfiguration() { | |||
| 26 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); | 26 | ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); |
| 27 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); | 27 | ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); |
| 28 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); | 28 | ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); |
| 29 | ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse); | ||
| 29 | 30 | ||
| 30 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); | 31 | ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); |
| 31 | ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); | 32 | ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); |
| @@ -36,6 +37,7 @@ void ConfigureGeneral::ApplyConfiguration() { | |||
| 36 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); | 37 | UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); |
| 37 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); | 38 | UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); |
| 38 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); | 39 | UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); |
| 40 | UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); | ||
| 39 | 41 | ||
| 40 | Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); | 42 | Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); |
| 41 | Settings::values.frame_limit = ui->frame_limit->value(); | 43 | Settings::values.frame_limit = ui->frame_limit->value(); |
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui index 857119bb3..fc3b7e65a 100644 --- a/src/yuzu/configuration/configure_general.ui +++ b/src/yuzu/configuration/configure_general.ui | |||
| @@ -72,6 +72,13 @@ | |||
| 72 | </property> | 72 | </property> |
| 73 | </widget> | 73 | </widget> |
| 74 | </item> | 74 | </item> |
| 75 | <item> | ||
| 76 | <widget class="QCheckBox" name="toggle_hide_mouse"> | ||
| 77 | <property name="text"> | ||
| 78 | <string>Hide mouse on inactivity</string> | ||
| 79 | </property> | ||
| 80 | </widget> | ||
| 81 | </item> | ||
| 75 | </layout> | 82 | </layout> |
| 76 | </item> | 83 | </item> |
| 77 | </layout> | 84 | </layout> |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 05baec7e1..1e76f789c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -135,6 +135,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; | |||
| 135 | } | 135 | } |
| 136 | #endif | 136 | #endif |
| 137 | 137 | ||
| 138 | constexpr int default_mouse_timeout = 2500; | ||
| 139 | |||
| 138 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; | 140 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; |
| 139 | 141 | ||
| 140 | /** | 142 | /** |
| @@ -236,6 +238,14 @@ GMainWindow::GMainWindow() | |||
| 236 | // Show one-time "callout" messages to the user | 238 | // Show one-time "callout" messages to the user |
| 237 | ShowTelemetryCallout(); | 239 | ShowTelemetryCallout(); |
| 238 | 240 | ||
| 241 | // make sure menubar has the arrow cursor instead of inheriting from this | ||
| 242 | ui.menubar->setCursor(QCursor()); | ||
| 243 | statusBar()->setCursor(QCursor()); | ||
| 244 | |||
| 245 | mouse_hide_timer.setInterval(default_mouse_timeout); | ||
| 246 | connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); | ||
| 247 | connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); | ||
| 248 | |||
| 239 | QStringList args = QApplication::arguments(); | 249 | QStringList args = QApplication::arguments(); |
| 240 | if (args.length() >= 2) { | 250 | if (args.length() >= 2) { |
| 241 | BootGame(args[1]); | 251 | BootGame(args[1]); |
| @@ -1012,6 +1022,13 @@ void GMainWindow::BootGame(const QString& filename) { | |||
| 1012 | async_status_button->setDisabled(true); | 1022 | async_status_button->setDisabled(true); |
| 1013 | renderer_status_button->setDisabled(true); | 1023 | renderer_status_button->setDisabled(true); |
| 1014 | 1024 | ||
| 1025 | if (UISettings::values.hide_mouse) { | ||
| 1026 | mouse_hide_timer.start(); | ||
| 1027 | setMouseTracking(true); | ||
| 1028 | ui.centralwidget->setMouseTracking(true); | ||
| 1029 | ui.menubar->setMouseTracking(true); | ||
| 1030 | } | ||
| 1031 | |||
| 1015 | const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); | 1032 | const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); |
| 1016 | 1033 | ||
| 1017 | std::string title_name; | 1034 | std::string title_name; |
| @@ -1080,6 +1097,10 @@ void GMainWindow::ShutdownGame() { | |||
| 1080 | game_list->show(); | 1097 | game_list->show(); |
| 1081 | game_list->setFilterFocus(); | 1098 | game_list->setFilterFocus(); |
| 1082 | 1099 | ||
| 1100 | setMouseTracking(false); | ||
| 1101 | ui.centralwidget->setMouseTracking(false); | ||
| 1102 | ui.menubar->setMouseTracking(false); | ||
| 1103 | |||
| 1083 | UpdateWindowTitle(); | 1104 | UpdateWindowTitle(); |
| 1084 | 1105 | ||
| 1085 | // Disable status bar updates | 1106 | // Disable status bar updates |
| @@ -1835,6 +1856,17 @@ void GMainWindow::OnConfigure() { | |||
| 1835 | 1856 | ||
| 1836 | config->Save(); | 1857 | config->Save(); |
| 1837 | 1858 | ||
| 1859 | if (UISettings::values.hide_mouse && emulation_running) { | ||
| 1860 | setMouseTracking(true); | ||
| 1861 | ui.centralwidget->setMouseTracking(true); | ||
| 1862 | ui.menubar->setMouseTracking(true); | ||
| 1863 | mouse_hide_timer.start(); | ||
| 1864 | } else { | ||
| 1865 | setMouseTracking(false); | ||
| 1866 | ui.centralwidget->setMouseTracking(false); | ||
| 1867 | ui.menubar->setMouseTracking(false); | ||
| 1868 | } | ||
| 1869 | |||
| 1838 | dock_status_button->setChecked(Settings::values.use_docked_mode); | 1870 | dock_status_button->setChecked(Settings::values.use_docked_mode); |
| 1839 | async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); | 1871 | async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); |
| 1840 | #ifdef HAS_VULKAN | 1872 | #ifdef HAS_VULKAN |
| @@ -1968,6 +2000,30 @@ void GMainWindow::UpdateStatusBar() { | |||
| 1968 | emu_frametime_label->setVisible(true); | 2000 | emu_frametime_label->setVisible(true); |
| 1969 | } | 2001 | } |
| 1970 | 2002 | ||
| 2003 | void GMainWindow::HideMouseCursor() { | ||
| 2004 | if (emu_thread == nullptr || UISettings::values.hide_mouse == false) { | ||
| 2005 | mouse_hide_timer.stop(); | ||
| 2006 | ShowMouseCursor(); | ||
| 2007 | return; | ||
| 2008 | } | ||
| 2009 | setCursor(QCursor(Qt::BlankCursor)); | ||
| 2010 | } | ||
| 2011 | |||
| 2012 | void GMainWindow::ShowMouseCursor() { | ||
| 2013 | unsetCursor(); | ||
| 2014 | if (emu_thread != nullptr && UISettings::values.hide_mouse) { | ||
| 2015 | mouse_hide_timer.start(); | ||
| 2016 | } | ||
| 2017 | } | ||
| 2018 | |||
| 2019 | void GMainWindow::mouseMoveEvent(QMouseEvent* event) { | ||
| 2020 | ShowMouseCursor(); | ||
| 2021 | } | ||
| 2022 | |||
| 2023 | void GMainWindow::mousePressEvent(QMouseEvent* event) { | ||
| 2024 | ShowMouseCursor(); | ||
| 2025 | } | ||
| 2026 | |||
| 1971 | void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { | 2027 | void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { |
| 1972 | QMessageBox::StandardButton answer; | 2028 | QMessageBox::StandardButton answer; |
| 1973 | QString status_message; | 2029 | QString status_message; |
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 0b750689d..60b17c54a 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -216,6 +216,8 @@ private: | |||
| 216 | std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); | 216 | std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); |
| 217 | void UpdateWindowTitle(const QString& title_name = {}); | 217 | void UpdateWindowTitle(const QString& title_name = {}); |
| 218 | void UpdateStatusBar(); | 218 | void UpdateStatusBar(); |
| 219 | void HideMouseCursor(); | ||
| 220 | void ShowMouseCursor(); | ||
| 219 | 221 | ||
| 220 | Ui::MainWindow ui; | 222 | Ui::MainWindow ui; |
| 221 | 223 | ||
| @@ -244,6 +246,7 @@ private: | |||
| 244 | QString game_path; | 246 | QString game_path; |
| 245 | 247 | ||
| 246 | bool auto_paused = false; | 248 | bool auto_paused = false; |
| 249 | QTimer mouse_hide_timer; | ||
| 247 | 250 | ||
| 248 | // FS | 251 | // FS |
| 249 | std::shared_ptr<FileSys::VfsFilesystem> vfs; | 252 | std::shared_ptr<FileSys::VfsFilesystem> vfs; |
| @@ -265,4 +268,6 @@ protected: | |||
| 265 | void dropEvent(QDropEvent* event) override; | 268 | void dropEvent(QDropEvent* event) override; |
| 266 | void dragEnterEvent(QDragEnterEvent* event) override; | 269 | void dragEnterEvent(QDragEnterEvent* event) override; |
| 267 | void dragMoveEvent(QDragMoveEvent* event) override; | 270 | void dragMoveEvent(QDragMoveEvent* event) override; |
| 271 | void mouseMoveEvent(QMouseEvent* event) override; | ||
| 272 | void mousePressEvent(QMouseEvent* event) override; | ||
| 268 | }; | 273 | }; |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index a675ecf4d..830932d45 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -59,6 +59,7 @@ struct Values { | |||
| 59 | bool confirm_before_closing; | 59 | bool confirm_before_closing; |
| 60 | bool first_start; | 60 | bool first_start; |
| 61 | bool pause_when_in_background; | 61 | bool pause_when_in_background; |
| 62 | bool hide_mouse; | ||
| 62 | 63 | ||
| 63 | bool select_user_on_boot; | 64 | bool select_user_on_boot; |
| 64 | 65 | ||