summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt9
-rw-r--r--src/common/linux/gamemode.cpp39
-rw-r--r--src/common/linux/gamemode.h24
-rw-r--r--src/common/settings.cpp2
-rw-r--r--src/common/settings.h5
-rw-r--r--src/common/settings_common.h1
6 files changed, 80 insertions, 0 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index e216eb3de..57cbb9d07 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -174,6 +174,15 @@ if(ANDROID)
174 ) 174 )
175endif() 175endif()
176 176
177if (UNIX)
178 target_sources(common PRIVATE
179 linux/gamemode.cpp
180 linux/gamemode.h
181 )
182
183 target_link_libraries(common PRIVATE gamemode)
184endif()
185
177if(ARCHITECTURE_x86_64) 186if(ARCHITECTURE_x86_64)
178 target_sources(common 187 target_sources(common
179 PRIVATE 188 PRIVATE
diff --git a/src/common/linux/gamemode.cpp b/src/common/linux/gamemode.cpp
new file mode 100644
index 000000000..8876d8dc4
--- /dev/null
+++ b/src/common/linux/gamemode.cpp
@@ -0,0 +1,39 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include <gamemode_client.h>
5
6#include "common/linux/gamemode.h"
7#include "common/settings.h"
8
9namespace Common::Linux {
10
11void StartGamemode() {
12 if (Settings::values.enable_gamemode) {
13 if (gamemode_request_start() < 0) {
14 LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string());
15 } else {
16 LOG_INFO(Frontend, "Started gamemode");
17 }
18 }
19}
20
21void StopGamemode() {
22 if (Settings::values.enable_gamemode) {
23 if (gamemode_request_end() < 0) {
24 LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string());
25 } else {
26 LOG_INFO(Frontend, "Stopped gamemode");
27 }
28 }
29}
30
31void SetGamemodeState(bool state) {
32 if (state) {
33 StartGamemode();
34 } else {
35 StopGamemode();
36 }
37}
38
39} // namespace Common::Linux
diff --git a/src/common/linux/gamemode.h b/src/common/linux/gamemode.h
new file mode 100644
index 000000000..b80646ae2
--- /dev/null
+++ b/src/common/linux/gamemode.h
@@ -0,0 +1,24 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6namespace Common::Linux {
7
8/**
9 * Start the (Feral Interactive) Linux gamemode if it is installed and it is activated
10 */
11void StartGamemode();
12
13/**
14 * Stop the (Feral Interactive) Linux gamemode if it is installed and it is activated
15 */
16void StopGamemode();
17
18/**
19 * Start or stop the (Feral Interactive) Linux gamemode if it is installed and it is activated
20 * @param state The new state the gamemode should have
21 */
22void SetGamemodeState(bool state);
23
24} // namespace Common::Linux
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index a10131eb2..3e829253f 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -219,6 +219,8 @@ const char* TranslateCategory(Category category) {
219 return "Services"; 219 return "Services";
220 case Category::Paths: 220 case Category::Paths:
221 return "Paths"; 221 return "Paths";
222 case Category::Linux:
223 return "Linux";
222 case Category::MaxEnum: 224 case Category::MaxEnum:
223 break; 225 break;
224 } 226 }
diff --git a/src/common/settings.h b/src/common/settings.h
index e75099b89..6425cd98f 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -384,6 +384,8 @@ struct Values {
384 Category::RendererDebug}; 384 Category::RendererDebug};
385 // TODO: remove this once AMDVLK supports VK_EXT_depth_bias_control 385 // TODO: remove this once AMDVLK supports VK_EXT_depth_bias_control
386 bool renderer_amdvlk_depth_bias_workaround{}; 386 bool renderer_amdvlk_depth_bias_workaround{};
387 Setting<bool> disable_buffer_reorder{linkage, false, "disable_buffer_reorder",
388 Category::RendererDebug};
387 389
388 // System 390 // System
389 SwitchableSetting<Language, true> language_index{linkage, 391 SwitchableSetting<Language, true> language_index{linkage,
@@ -427,6 +429,9 @@ struct Values {
427 true, 429 true,
428 true}; 430 true};
429 431
432 // Linux
433 SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux};
434
430 // Controls 435 // Controls
431 InputSetting<std::array<PlayerInput, 10>> players; 436 InputSetting<std::array<PlayerInput, 10>> players;
432 437
diff --git a/src/common/settings_common.h b/src/common/settings_common.h
index 7943223eb..344c04439 100644
--- a/src/common/settings_common.h
+++ b/src/common/settings_common.h
@@ -41,6 +41,7 @@ enum class Category : u32 {
41 Multiplayer, 41 Multiplayer,
42 Services, 42 Services,
43 Paths, 43 Paths,
44 Linux,
44 MaxEnum, 45 MaxEnum,
45}; 46};
46 47