diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/common/linux/gamemode.cpp | 40 | ||||
-rw-r--r-- | src/common/linux/gamemode.h | 24 | ||||
-rw-r--r-- | src/common/settings.cpp | 2 | ||||
-rw-r--r-- | src/common/settings.h | 5 | ||||
-rw-r--r-- | src/common/settings_common.h | 1 |
6 files changed, 81 insertions, 0 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index d38d5c6d1..bbc55eb56 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -182,6 +182,15 @@ if(ANDROID) ) endif() +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_sources(common PRIVATE + linux/gamemode.cpp + linux/gamemode.h + ) + + target_link_libraries(common PRIVATE gamemode) +endif() + if(ARCHITECTURE_x86_64) target_sources(common PRIVATE diff --git a/src/common/linux/gamemode.cpp b/src/common/linux/gamemode.cpp new file mode 100644 index 000000000..8d3e2934a --- /dev/null +++ b/src/common/linux/gamemode.cpp @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include <gamemode_client.h> + +#include "common/linux/gamemode.h" +#include "common/logging/log.h" +#include "common/settings.h" + +namespace Common::Linux { + +void StartGamemode() { + if (Settings::values.enable_gamemode) { + if (gamemode_request_start() < 0) { + LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Started gamemode"); + } + } +} + +void StopGamemode() { + if (Settings::values.enable_gamemode) { + if (gamemode_request_end() < 0) { + LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); + } else { + LOG_INFO(Frontend, "Stopped gamemode"); + } + } +} + +void SetGamemodeState(bool state) { + if (state) { + StartGamemode(); + } else { + StopGamemode(); + } +} + +} // 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 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +namespace Common::Linux { + +/** + * Start the (Feral Interactive) Linux gamemode if it is installed and it is activated + */ +void StartGamemode(); + +/** + * Stop the (Feral Interactive) Linux gamemode if it is installed and it is activated + */ +void StopGamemode(); + +/** + * Start or stop the (Feral Interactive) Linux gamemode if it is installed and it is activated + * @param state The new state the gamemode should have + */ +void SetGamemodeState(bool state); + +} // namespace Common::Linux diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 16c2feeab..4666bd0a0 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -236,6 +236,8 @@ const char* TranslateCategory(Category category) { return "Services"; case Category::Paths: return "Paths"; + case Category::Linux: + return "Linux"; case Category::MaxEnum: break; } diff --git a/src/common/settings.h b/src/common/settings.h index 508615011..98341ad96 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -393,6 +393,8 @@ struct Values { Category::RendererDebug}; // TODO: remove this once AMDVLK supports VK_EXT_depth_bias_control bool renderer_amdvlk_depth_bias_workaround{}; + Setting<bool> disable_buffer_reorder{linkage, false, "disable_buffer_reorder", + Category::RendererDebug}; // System SwitchableSetting<Language, true> language_index{linkage, @@ -436,6 +438,9 @@ struct Values { true, true}; + // Linux + SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux}; + // Controls InputSetting<std::array<PlayerInput, 10>> players; 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 { Multiplayer, Services, Paths, + Linux, MaxEnum, }; |