diff options
| author | 2023-07-16 18:45:33 -0400 | |
|---|---|---|
| committer | 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.gz yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.tar.xz yuzu-dfa56765d6d869a317ec46dcf3a8f4f35b146382.zip | |
yuzu: integrate gamemode support on linux
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 { | |||
| 178 | true, | 178 | true, |
| 179 | &use_speed_limit}; | 179 | &use_speed_limit}; |
| 180 | 180 | ||
| 181 | Setting<bool> enable_gamemode{linkage, false, "enable_gamemode", Category::Core}; | ||
| 182 | |||
| 181 | // Cpu | 183 | // Cpu |
| 182 | SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto, | 184 | SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto, |
| 183 | CpuAccuracy::Auto, CpuAccuracy::Paranoid, | 185 | 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) | |||
| 386 | target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}) | 386 | target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}) |
| 387 | endif() | 387 | endif() |
| 388 | if (UNIX AND NOT APPLE) | 388 | if (UNIX AND NOT APPLE) |
| 389 | target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus) | 389 | target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus gamemode) |
| 390 | endif() | 390 | endif() |
| 391 | 391 | ||
| 392 | target_compile_definitions(yuzu PRIVATE | 392 | 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_, | |||
| 29 | if (!Settings::IsConfiguringGlobal()) { | 29 | if (!Settings::IsConfiguringGlobal()) { |
| 30 | ui->button_reset_defaults->setVisible(false); | 30 | ui->button_reset_defaults->setVisible(false); |
| 31 | } | 31 | } |
| 32 | #ifndef __linux__ | ||
| 33 | ui->enable_gamemode->setVisible(false); | ||
| 34 | #endif | ||
| 32 | } | 35 | } |
| 33 | 36 | ||
| 34 | ConfigureGeneral::~ConfigureGeneral() = default; | 37 | 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) { | |||
| 175 | INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), QStringLiteral()); | 175 | INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), QStringLiteral()); |
| 176 | INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"), | 176 | INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"), |
| 177 | QStringLiteral()); | 177 | QStringLiteral()); |
| 178 | INSERT(UISettings, enable_gamemode, tr("Enable Gamemode"), QStringLiteral()); | ||
| 178 | 179 | ||
| 179 | // Ui Debugging | 180 | // Ui Debugging |
| 180 | 181 | ||
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; | |||
| 185 | } | 185 | } |
| 186 | #endif | 186 | #endif |
| 187 | 187 | ||
| 188 | #ifdef __linux__ | ||
| 189 | #include <gamemode_client.h> | ||
| 190 | #endif | ||
| 191 | |||
| 188 | constexpr int default_mouse_hide_timeout = 2500; | 192 | constexpr int default_mouse_hide_timeout = 2500; |
| 189 | constexpr int default_mouse_center_timeout = 10; | 193 | constexpr int default_mouse_center_timeout = 10; |
| 190 | constexpr int default_input_update_timeout = 1; | 194 | constexpr int default_input_update_timeout = 1; |
| @@ -2126,6 +2130,16 @@ void GMainWindow::OnEmulationStopped() { | |||
| 2126 | 2130 | ||
| 2127 | discord_rpc->Update(); | 2131 | discord_rpc->Update(); |
| 2128 | 2132 | ||
| 2133 | #ifdef __linux__ | ||
| 2134 | if (UISettings::values.enable_gamemode) { | ||
| 2135 | if (gamemode_request_end() < 0) { | ||
| 2136 | LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); | ||
| 2137 | } else { | ||
| 2138 | LOG_INFO(Frontend, "Stopped gamemode"); | ||
| 2139 | } | ||
| 2140 | } | ||
| 2141 | #endif | ||
| 2142 | |||
| 2129 | // The emulation is stopped, so closing the window or not does not matter anymore | 2143 | // The emulation is stopped, so closing the window or not does not matter anymore |
| 2130 | disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); | 2144 | disconnect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); |
| 2131 | 2145 | ||
| @@ -3504,6 +3518,16 @@ void GMainWindow::OnStartGame() { | |||
| 3504 | play_time_manager->Start(); | 3518 | play_time_manager->Start(); |
| 3505 | 3519 | ||
| 3506 | discord_rpc->Update(); | 3520 | discord_rpc->Update(); |
| 3521 | |||
| 3522 | #ifdef __linux__ | ||
| 3523 | if (UISettings::values.enable_gamemode) { | ||
| 3524 | if (gamemode_request_start() < 0) { | ||
| 3525 | LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); | ||
| 3526 | } else { | ||
| 3527 | LOG_INFO(Frontend, "Started gamemode"); | ||
| 3528 | } | ||
| 3529 | } | ||
| 3530 | #endif | ||
| 3507 | } | 3531 | } |
| 3508 | 3532 | ||
| 3509 | void GMainWindow::OnRestartGame() { | 3533 | void GMainWindow::OnRestartGame() { |
| @@ -3524,6 +3548,16 @@ void GMainWindow::OnPauseGame() { | |||
| 3524 | play_time_manager->Stop(); | 3548 | play_time_manager->Stop(); |
| 3525 | UpdateMenuState(); | 3549 | UpdateMenuState(); |
| 3526 | AllowOSSleep(); | 3550 | AllowOSSleep(); |
| 3551 | |||
| 3552 | #ifdef __linux__ | ||
| 3553 | if (UISettings::values.enable_gamemode) { | ||
| 3554 | if (gamemode_request_end() < 0) { | ||
| 3555 | LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); | ||
| 3556 | } else { | ||
| 3557 | LOG_INFO(Frontend, "Stopped gamemode"); | ||
| 3558 | } | ||
| 3559 | } | ||
| 3560 | #endif | ||
| 3527 | } | 3561 | } |
| 3528 | 3562 | ||
| 3529 | void GMainWindow::OnPauseContinueGame() { | 3563 | void GMainWindow::OnPauseContinueGame() { |
| @@ -5181,6 +5215,26 @@ void GMainWindow::SetDiscordEnabled([[maybe_unused]] bool state) { | |||
| 5181 | discord_rpc->Update(); | 5215 | discord_rpc->Update(); |
| 5182 | } | 5216 | } |
| 5183 | 5217 | ||
| 5218 | void GMainWindow::SetGamemodeDisabled([[maybe_unused]] bool state) { | ||
| 5219 | #ifdef __linux__ | ||
| 5220 | if (emulation_running) { | ||
| 5221 | if (state) { | ||
| 5222 | if (gamemode_request_end() < 0) { | ||
| 5223 | LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); | ||
| 5224 | } else { | ||
| 5225 | LOG_INFO(Frontend, "Stopped gamemode"); | ||
| 5226 | } | ||
| 5227 | } else { | ||
| 5228 | if (gamemode_request_start() < 0) { | ||
| 5229 | LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); | ||
| 5230 | } else { | ||
| 5231 | LOG_INFO(Frontend, "Started gamemode"); | ||
| 5232 | } | ||
| 5233 | } | ||
| 5234 | } | ||
| 5235 | #endif | ||
| 5236 | } | ||
| 5237 | |||
| 5184 | void GMainWindow::changeEvent(QEvent* event) { | 5238 | void GMainWindow::changeEvent(QEvent* event) { |
| 5185 | #ifdef __unix__ | 5239 | #ifdef __unix__ |
| 5186 | // PaletteChange event appears to only reach so far into the GUI, explicitly asking to | 5240 | // 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 { | |||
| 140 | Settings::Specialization::Default, | 140 | Settings::Specialization::Default, |
| 141 | true, | 141 | true, |
| 142 | true}; | 142 | true}; |
| 143 | // Gamemode | ||
| 144 | Setting<bool> enable_gamemode{linkage, false, "enable_gamemode", Category::UiGeneral}; | ||
| 145 | |||
| 143 | Setting<bool> disable_web_applet{linkage, true, "disable_web_applet", Category::Ui}; | 146 | Setting<bool> disable_web_applet{linkage, true, "disable_web_applet", Category::Ui}; |
| 144 | 147 | ||
| 145 | // Discord RPC | 148 | // 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) | |||
| 44 | 44 | ||
| 45 | if(UNIX AND NOT APPLE) | 45 | if(UNIX AND NOT APPLE) |
| 46 | install(TARGETS yuzu-cmd) | 46 | install(TARGETS yuzu-cmd) |
| 47 | target_link_libraries(yuzu-cmd PRIVATE gamemode) | ||
| 47 | endif() | 48 | endif() |
| 48 | 49 | ||
| 49 | if(WIN32) | 50 | 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; | |||
| 63 | } | 63 | } |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | #ifdef __linux__ | ||
| 67 | #include <gamemode_client.h> | ||
| 68 | #endif | ||
| 69 | |||
| 66 | static void PrintHelp(const char* argv0) { | 70 | static void PrintHelp(const char* argv0) { |
| 67 | std::cout << "Usage: " << argv0 | 71 | std::cout << "Usage: " << argv0 |
| 68 | << " [options] <filename>\n" | 72 | << " [options] <filename>\n" |
| @@ -425,6 +429,16 @@ int main(int argc, char** argv) { | |||
| 425 | exit(0); | 429 | exit(0); |
| 426 | }); | 430 | }); |
| 427 | 431 | ||
| 432 | #ifdef __linux__ | ||
| 433 | if (Settings::values.disable_gamemode) { | ||
| 434 | if (gamemode_request_start() < 0) { | ||
| 435 | LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); | ||
| 436 | } else { | ||
| 437 | LOG_INFO(Frontend, "Started gamemode"); | ||
| 438 | } | ||
| 439 | } | ||
| 440 | #endif | ||
| 441 | |||
| 428 | void(system.Run()); | 442 | void(system.Run()); |
| 429 | if (system.DebuggerEnabled()) { | 443 | if (system.DebuggerEnabled()) { |
| 430 | system.InitializeDebugger(); | 444 | system.InitializeDebugger(); |
| @@ -436,6 +450,16 @@ int main(int argc, char** argv) { | |||
| 436 | void(system.Pause()); | 450 | void(system.Pause()); |
| 437 | system.ShutdownMainProcess(); | 451 | system.ShutdownMainProcess(); |
| 438 | 452 | ||
| 453 | #ifdef __linux__ | ||
| 454 | if (Settings::values.disable_gamemode) { | ||
| 455 | if (gamemode_request_end() < 0) { | ||
| 456 | LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); | ||
| 457 | } else { | ||
| 458 | LOG_INFO(Frontend, "Stopped gamemode"); | ||
| 459 | } | ||
| 460 | } | ||
| 461 | #endif | ||
| 462 | |||
| 439 | detached_tasks.WaitForAllTasks(); | 463 | detached_tasks.WaitForAllTasks(); |
| 440 | return 0; | 464 | return 0; |
| 441 | } | 465 | } |