summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/settings.h2
-rw-r--r--src/yuzu/CMakeLists.txt2
-rw-r--r--src/yuzu/configuration/configure_general.cpp3
-rw-r--r--src/yuzu/configuration/shared_translation.cpp1
-rw-r--r--src/yuzu/main.cpp54
-rw-r--r--src/yuzu/uisettings.h3
-rw-r--r--src/yuzu_cmd/CMakeLists.txt1
-rw-r--r--src/yuzu_cmd/yuzu.cpp24
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})
387endif() 387endif()
388if (UNIX AND NOT APPLE) 388if (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)
390endif() 390endif()
391 391
392target_compile_definitions(yuzu PRIVATE 392target_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
34ConfigureGeneral::~ConfigureGeneral() = default; 37ConfigureGeneral::~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
188constexpr int default_mouse_hide_timeout = 2500; 192constexpr int default_mouse_hide_timeout = 2500;
189constexpr int default_mouse_center_timeout = 10; 193constexpr int default_mouse_center_timeout = 10;
190constexpr int default_input_update_timeout = 1; 194constexpr 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
3509void GMainWindow::OnRestartGame() { 3533void 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
3529void GMainWindow::OnPauseContinueGame() { 3563void 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
5218void 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
5184void GMainWindow::changeEvent(QEvent* event) { 5238void 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
45if(UNIX AND NOT APPLE) 45if(UNIX AND NOT APPLE)
46 install(TARGETS yuzu-cmd) 46 install(TARGETS yuzu-cmd)
47 target_link_libraries(yuzu-cmd PRIVATE gamemode)
47endif() 48endif()
48 49
49if(WIN32) 50if(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
66static void PrintHelp(const char* argv0) { 70static 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}