diff options
-rw-r--r-- | src/common/uuid.h | 5 | ||||
-rw-r--r-- | src/core/hle/service/acc/acc.cpp | 13 | ||||
-rw-r--r-- | src/core/hle/service/am/am.cpp | 16 | ||||
-rw-r--r-- | src/core/hle/service/am/am.h | 6 | ||||
-rw-r--r-- | src/core/hle/service/am/applet_ae.cpp | 2 | ||||
-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 |
12 files changed, 111 insertions, 9 deletions
diff --git a/src/common/uuid.h b/src/common/uuid.h index f6ad064fb..4d3af8cec 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h @@ -40,6 +40,11 @@ struct UUID { uuid = INVALID_UUID; } + // TODO(ogniK): Properly generate a Nintendo ID + constexpr u64 GetNintendoID() const { + return uuid[0]; + } + std::string Format() const; std::string FormatSwitch() const; }; diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 9a7992f58..630a8b048 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -228,7 +228,8 @@ public: class IManagerForApplication final : public ServiceFramework<IManagerForApplication> { public: - IManagerForApplication() : ServiceFramework("IManagerForApplication") { + explicit IManagerForApplication(Common::UUID user_id) + : ServiceFramework("IManagerForApplication"), user_id(user_id) { // clang-format off static const FunctionInfo functions[] = { {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"}, @@ -254,12 +255,14 @@ private: } void GetAccountId(Kernel::HLERequestContext& ctx) { - LOG_WARNING(Service_ACC, "(STUBBED) called"); - // Should return a nintendo account ID + LOG_DEBUG(Service_ACC, "called"); + IPC::ResponseBuilder rb{ctx, 4}; rb.Push(RESULT_SUCCESS); - rb.PushRaw<u64>(1); + rb.PushRaw<u64>(user_id.GetNintendoID()); } + + Common::UUID user_id; }; void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) { @@ -382,7 +385,7 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo LOG_DEBUG(Service_ACC, "called"); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IManagerForApplication>(); + rb.PushIpcInterface<IManagerForApplication>(profile_manager->GetLastOpenedUser()); } void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index a967e6ef7..4df74c4f9 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1525,14 +1525,15 @@ void InstallInterfaces(SM::ServiceManager& service_manager, std::make_shared<TCAP>()->InstallAsService(service_manager); } -IHomeMenuFunctions::IHomeMenuFunctions() : ServiceFramework("IHomeMenuFunctions") { +IHomeMenuFunctions::IHomeMenuFunctions(Kernel::KernelCore& kernel) + : ServiceFramework("IHomeMenuFunctions"), kernel(kernel) { // clang-format off static const FunctionInfo functions[] = { {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"}, {11, nullptr, "LockForeground"}, {12, nullptr, "UnlockForeground"}, {20, nullptr, "PopFromGeneralChannel"}, - {21, nullptr, "GetPopFromGeneralChannelEvent"}, + {21, &IHomeMenuFunctions::GetPopFromGeneralChannelEvent, "GetPopFromGeneralChannelEvent"}, {30, nullptr, "GetHomeButtonWriterLockAccessor"}, {31, nullptr, "GetWriterLockAccessorEx"}, {100, nullptr, "PopRequestLaunchApplicationForDebug"}, @@ -1542,6 +1543,9 @@ IHomeMenuFunctions::IHomeMenuFunctions() : ServiceFramework("IHomeMenuFunctions" // clang-format on RegisterHandlers(functions); + + pop_from_general_channel_event = Kernel::WritableEvent::CreateEventPair( + kernel, "IHomeMenuFunctions:PopFromGeneralChannelEvent"); } IHomeMenuFunctions::~IHomeMenuFunctions() = default; @@ -1553,6 +1557,14 @@ void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) rb.Push(RESULT_SUCCESS); } +void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushCopyObjects(pop_from_general_channel_event.readable); +} + IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStateController") { // clang-format off static const FunctionInfo functions[] = { diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index dfa701d73..469f7f814 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -292,11 +292,15 @@ private: class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { public: - IHomeMenuFunctions(); + explicit IHomeMenuFunctions(Kernel::KernelCore& kernel); ~IHomeMenuFunctions() override; private: void RequestToGetForeground(Kernel::HLERequestContext& ctx); + void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx); + + Kernel::EventPair pop_from_general_channel_event; + Kernel::KernelCore& kernel; }; class IGlobalStateController final : public ServiceFramework<IGlobalStateController> { diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp index e454b77d8..9df286d17 100644 --- a/src/core/hle/service/am/applet_ae.cpp +++ b/src/core/hle/service/am/applet_ae.cpp @@ -202,7 +202,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IHomeMenuFunctions>(); + rb.PushIpcInterface<IHomeMenuFunctions>(system.Kernel()); } void GetGlobalStateController(Kernel::HLERequestContext& ctx) { 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_) setLayout(layout); InputCommon::Init(); + this->setMouseTracking(true); + connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete); } @@ -385,6 +387,7 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { } else if (event->button() == Qt::RightButton) { InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); } + QWidget::mousePressEvent(event); } void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { @@ -397,6 +400,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { const auto [x, y] = ScaleTouch(pos); this->TouchMoved(x, y); InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); + QWidget::mouseMoveEvent(event); } void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index a44eed047..75c6cf20b 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -743,6 +743,8 @@ void Config::ReadUIValues() { UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); UISettings::values.pause_when_in_background = ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool(); + UISettings::values.hide_mouse = + ReadSetting(QStringLiteral("hideInactiveMouse"), false).toBool(); ApplyDefaultProfileIfInputInvalid(); @@ -1169,6 +1171,7 @@ void Config::SaveUIValues() { WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); WriteSetting(QStringLiteral("pauseWhenInBackground"), UISettings::values.pause_when_in_background, false); + WriteSetting(QStringLiteral("hideInactiveMouse"), UISettings::values.hide_mouse, false); qt_config->endGroup(); } 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() { ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); + ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse); ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); @@ -36,6 +37,7 @@ void ConfigureGeneral::ApplyConfiguration() { UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); + UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked(); Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); 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 @@ </property> </widget> </item> + <item> + <widget class="QCheckBox" name="toggle_hide_mouse"> + <property name="text"> + <string>Hide mouse on inactivity</string> + </property> + </widget> + </item> </layout> </item> </layout> diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index b44b4276c..0a6839b2d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -135,6 +135,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } #endif +constexpr int default_mouse_timeout = 2500; + constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; /** @@ -236,6 +238,14 @@ GMainWindow::GMainWindow() // Show one-time "callout" messages to the user ShowTelemetryCallout(); + // make sure menubar has the arrow cursor instead of inheriting from this + ui.menubar->setCursor(QCursor()); + statusBar()->setCursor(QCursor()); + + mouse_hide_timer.setInterval(default_mouse_timeout); + connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor); + connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor); + QStringList args = QApplication::arguments(); if (args.length() >= 2) { BootGame(args[1]); @@ -1012,6 +1022,13 @@ void GMainWindow::BootGame(const QString& filename) { async_status_button->setDisabled(true); renderer_status_button->setDisabled(true); + if (UISettings::values.hide_mouse) { + mouse_hide_timer.start(); + setMouseTracking(true); + ui.centralwidget->setMouseTracking(true); + ui.menubar->setMouseTracking(true); + } + const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); std::string title_name; @@ -1080,6 +1097,10 @@ void GMainWindow::ShutdownGame() { game_list->show(); game_list->setFilterFocus(); + setMouseTracking(false); + ui.centralwidget->setMouseTracking(false); + ui.menubar->setMouseTracking(false); + UpdateWindowTitle(); // Disable status bar updates @@ -1837,6 +1858,17 @@ void GMainWindow::OnConfigure() { config->Save(); + if (UISettings::values.hide_mouse && emulation_running) { + setMouseTracking(true); + ui.centralwidget->setMouseTracking(true); + ui.menubar->setMouseTracking(true); + mouse_hide_timer.start(); + } else { + setMouseTracking(false); + ui.centralwidget->setMouseTracking(false); + ui.menubar->setMouseTracking(false); + } + dock_status_button->setChecked(Settings::values.use_docked_mode); async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); #ifdef HAS_VULKAN @@ -1970,6 +2002,30 @@ void GMainWindow::UpdateStatusBar() { emu_frametime_label->setVisible(true); } +void GMainWindow::HideMouseCursor() { + if (emu_thread == nullptr || UISettings::values.hide_mouse == false) { + mouse_hide_timer.stop(); + ShowMouseCursor(); + return; + } + setCursor(QCursor(Qt::BlankCursor)); +} + +void GMainWindow::ShowMouseCursor() { + unsetCursor(); + if (emu_thread != nullptr && UISettings::values.hide_mouse) { + mouse_hide_timer.start(); + } +} + +void GMainWindow::mouseMoveEvent(QMouseEvent* event) { + ShowMouseCursor(); +} + +void GMainWindow::mousePressEvent(QMouseEvent* event) { + ShowMouseCursor(); +} + void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { QMessageBox::StandardButton answer; 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: std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); void UpdateWindowTitle(const QString& title_name = {}); void UpdateStatusBar(); + void HideMouseCursor(); + void ShowMouseCursor(); Ui::MainWindow ui; @@ -244,6 +246,7 @@ private: QString game_path; bool auto_paused = false; + QTimer mouse_hide_timer; // FS std::shared_ptr<FileSys::VfsFilesystem> vfs; @@ -265,4 +268,6 @@ protected: void dropEvent(QDropEvent* event) override; void dragEnterEvent(QDragEnterEvent* event) override; void dragMoveEvent(QDragMoveEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; }; 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 { bool confirm_before_closing; bool first_start; bool pause_when_in_background; + bool hide_mouse; bool select_user_on_boot; |