diff options
author | xcfrg <30675315+xcfrg@users.noreply.github.com> | 2023-07-16 18:45:33 -0400 |
---|---|---|
committer | flodavid <fl.david.53@gmail.com> | 2023-11-25 19:30:29 +0100 |
commit | dfa56765d6d869a317ec46dcf3a8f4f35b146382 (patch) | |
tree | 827c46ada3f60e9bdef93c25a26319f00377d15f /src/yuzu/main.cpp | |
parent | 5a182f4e7ccfac696cd54542089c880d002f5cc9 (diff) |
yuzu: integrate gamemode support on linux
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index defe45198..cf61d4258 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -185,6 +185,10 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } #endif +#ifdef __linux__ +#include <gamemode_client.h> +#endif + constexpr int default_mouse_hide_timeout = 2500; constexpr int default_mouse_center_timeout = 10; constexpr int default_input_update_timeout = 1; @@ -2126,6 +2130,16 @@ void GMainWindow::OnEmulationStopped() { discord_rpc->Update(); +#ifdef __linux__ + if (UISettings::values.enable_gamemode) { + if (gamemode_request_end() < 0) { + LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Stopped gamemode"); + } + } +#endif + // The emulation is stopped, so closing the window or not does not matter anymore disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); @@ -3504,6 +3518,16 @@ void GMainWindow::OnStartGame() { play_time_manager->Start(); discord_rpc->Update(); + +#ifdef __linux__ + if (UISettings::values.enable_gamemode) { + if (gamemode_request_start() < 0) { + LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Started gamemode"); + } + } +#endif } void GMainWindow::OnRestartGame() { @@ -3524,6 +3548,16 @@ void GMainWindow::OnPauseGame() { play_time_manager->Stop(); UpdateMenuState(); AllowOSSleep(); + +#ifdef __linux__ + if (UISettings::values.enable_gamemode) { + if (gamemode_request_end() < 0) { + LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Stopped gamemode"); + } + } +#endif } void GMainWindow::OnPauseContinueGame() { @@ -5181,6 +5215,26 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { discord_rpc->Update(); } +void GMainWindow::SetGamemodeDisabled([[maybe_unused]] bool state) { +#ifdef __linux__ + if (emulation_running) { + if (state) { + if (gamemode_request_end() < 0) { + LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Stopped gamemode"); + } + } else { + if (gamemode_request_start() < 0) { + LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Started gamemode"); + } + } + } +#endif +} + void GMainWindow::changeEvent(QEvent* event) { #ifdef __unix__ // PaletteChange event appears to only reach so far into the GUI, explicitly asking to |