diff options
author | liamwhite <[email protected]> | 2023-11-29 12:33:09 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2023-11-29 12:33:09 -0500 |
commit | 337e37f91dcc7d5b6a0a5da3f3196aa0f8df4143 (patch) | |
tree | 70d10b1f7919e6ed6709acab3259c69b038add6c /src/yuzu/main.cpp | |
parent | 992ca8c358a5c25840d822ca19baa6c64c689088 (diff) | |
parent | ac11f6e4c5da64db5a6fb2647afbb85164f06086 (diff) | |
download | yuzu-mainline-337e37f91dcc7d5b6a0a5da3f3196aa0f8df4143.tar.gz yuzu-mainline-337e37f91dcc7d5b6a0a5da3f3196aa0f8df4143.zip |
Merge pull request #11946 from flodavid/gamemode
Enable (Feral Interactive) Gamemode on Linux
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 31aabb78a..10c788290 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -17,6 +17,7 @@ #ifdef __unix__ #include <csignal> #include <sys/socket.h> +#include "common/linux/gamemode.h" #endif #include <boost/container/flat_set.hpp> @@ -319,6 +320,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk provider{std::make_unique<FileSys::ManualContentProvider>()} { #ifdef __unix__ SetupSigInterrupts(); + SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); #endif system->Initialize(); @@ -2120,6 +2122,10 @@ void GMainWindow::OnEmulationStopped() { discord_rpc->Update(); +#ifdef __unix__ + Common::Linux::StopGamemode(); +#endif + // The emulation is stopped, so closing the window or not does not matter anymore disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); @@ -3502,6 +3508,10 @@ void GMainWindow::OnStartGame() { play_time_manager->Start(); discord_rpc->Update(); + +#ifdef __unix__ + Common::Linux::StartGamemode(); +#endif } void GMainWindow::OnRestartGame() { @@ -3522,6 +3532,10 @@ void GMainWindow::OnPauseGame() { play_time_manager->Stop(); UpdateMenuState(); AllowOSSleep(); + +#ifdef __unix__ + Common::Linux::StopGamemode(); +#endif } void GMainWindow::OnPauseContinueGame() { @@ -3803,6 +3817,9 @@ void GMainWindow::OnConfigure() { const auto old_theme = UISettings::values.theme; const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); const auto old_language_index = Settings::values.language_index.GetValue(); +#ifdef __unix__ + const bool old_gamemode = Settings::values.enable_gamemode.GetValue(); +#endif Settings::SetConfiguringGlobal(true); ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), @@ -3864,6 +3881,11 @@ void GMainWindow::OnConfigure() { if (UISettings::values.enable_discord_presence.GetValue() != old_discord_presence) { SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue()); } +#ifdef __unix__ + if (Settings::values.enable_gamemode.GetValue() != old_gamemode) { + SetGamemodeEnabled(Settings::values.enable_gamemode.GetValue()); + } +#endif if (!multiplayer_state->IsHostingPublicRoom()) { multiplayer_state->UpdateCredentials(); @@ -5172,6 +5194,14 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { discord_rpc->Update(); } +#ifdef __unix__ +void GMainWindow::SetGamemodeEnabled(bool state) { + if (emulation_running) { + Common::Linux::SetGamemodeState(state); + } +} +#endif + void GMainWindow::changeEvent(QEvent* event) { #ifdef __unix__ // PaletteChange event appears to only reach so far into the GUI, explicitly asking to |