diff options
author | xcfrg <30675315+xcfrg@users.noreply.github.com> | 2023-07-17 00:45:33 +0200 |
---|---|---|
committer | flodavid <fl.david.53@gmail.com> | 2023-11-25 19:30:29 +0100 |
commit | dfa56765d6d869a317ec46dcf3a8f4f35b146382 (patch) | |
tree | 827c46ada3f60e9bdef93c25a26319f00377d15f /src | |
parent | Merge pull request #11889 from t895/ini-lib (diff) | |
download | yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.tar yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.tar.gz yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.tar.bz2 yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.tar.lz yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.tar.xz yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.tar.zst yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/common/settings.h | 2 | ||||
-rw-r--r-- | src/yuzu/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_general.cpp | 3 | ||||
-rw-r--r-- | src/yuzu/configuration/shared_translation.cpp | 1 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 54 | ||||
-rw-r--r-- | src/yuzu/uisettings.h | 3 | ||||
-rw-r--r-- | src/yuzu_cmd/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 24 |
8 files changed, 89 insertions, 1 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index e75099b89..788020bde 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -178,6 +178,8 @@ struct Values { true, &use_speed_limit}; + Setting<bool> enable_gamemode{linkage, false, "enable_gamemode", Category::Core}; + // Cpu SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto, CpuAccuracy::Auto, CpuAccuracy::Paranoid, diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 90278052a..f3ad2214b 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -386,7 +386,7 @@ if (NOT WIN32) target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}) endif() if (UNIX AND NOT APPLE) - target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus) + target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus gamemode) endif() target_compile_definitions(yuzu PRIVATE diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index c727fadd1..ce7e17850 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -29,6 +29,9 @@ ConfigureGeneral::ConfigureGeneral(const Core::System& system_, if (!Settings::IsConfiguringGlobal()) { ui->button_reset_defaults->setVisible(false); } +#ifndef __linux__ + ui->enable_gamemode->setVisible(false); +#endif } ConfigureGeneral::~ConfigureGeneral() = default; diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index a7b5def32..903805e75 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -175,6 +175,7 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) { INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), QStringLiteral()); INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"), QStringLiteral()); + INSERT(UISettings, enable_gamemode, tr("Enable Gamemode"), QStringLiteral()); // Ui Debugging 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 diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 549a39e1b..3e5ddc07a 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -140,6 +140,9 @@ struct Values { Settings::Specialization::Default, true, true}; + // Gamemode + Setting<bool> enable_gamemode{linkage, false, "enable_gamemode", Category::UiGeneral}; + Setting<bool> disable_web_applet{linkage, true, "disable_web_applet", Category::Ui}; // Discord RPC diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index fbeba8813..002f3e841 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -44,6 +44,7 @@ target_link_libraries(yuzu-cmd PRIVATE SDL2::SDL2 Vulkan::Headers) if(UNIX AND NOT APPLE) install(TARGETS yuzu-cmd) + target_link_libraries(yuzu-cmd PRIVATE gamemode) endif() if(WIN32) diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 0416d5951..1c3a1809b 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -63,6 +63,10 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } #endif +#ifdef __linux__ +#include <gamemode_client.h> +#endif + static void PrintHelp(const char* argv0) { std::cout << "Usage: " << argv0 << " [options] <filename>\n" @@ -425,6 +429,16 @@ int main(int argc, char** argv) { exit(0); }); +#ifdef __linux__ + if (Settings::values.disable_gamemode) { + if (gamemode_request_start() < 0) { + LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Started gamemode"); + } + } +#endif + void(system.Run()); if (system.DebuggerEnabled()) { system.InitializeDebugger(); @@ -436,6 +450,16 @@ int main(int argc, char** argv) { void(system.Pause()); system.ShutdownMainProcess(); +#ifdef __linux__ + if (Settings::values.disable_gamemode) { + if (gamemode_request_end() < 0) { + LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Stopped gamemode"); + } + } +#endif + detached_tasks.WaitForAllTasks(); return 0; } |