From dfa56765d6d869a317ec46dcf3a8f4f35b146382 Mon Sep 17 00:00:00 2001 From: xcfrg <30675315+xcfrg@users.noreply.github.com> Date: Sun, 16 Jul 2023 18:45:33 -0400 Subject: yuzu: integrate gamemode support on linux --- src/common/settings.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/common') 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 enable_gamemode{linkage, false, "enable_gamemode", Category::Core}; + // Cpu SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, CpuAccuracy::Auto, CpuAccuracy::Paranoid, -- cgit v1.2.3 From 40644d43f700cb0075db0eea288078bda7cf4527 Mon Sep 17 00:00:00 2001 From: flodavid Date: Fri, 3 Nov 2023 15:41:16 +0100 Subject: yuzu: create linux group in general settings - Create files dedicated to starting and stopping gamemode functions - Use them in yuzu and yuzu_cmd modules --- src/common/CMakeLists.txt | 9 +++++++++ src/common/linux/gamemode.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/common/linux/gamemode.h | 24 ++++++++++++++++++++++++ src/common/settings.cpp | 2 ++ src/common/settings.h | 5 +++-- src/common/settings_common.h | 1 + 6 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 src/common/linux/gamemode.cpp create mode 100644 src/common/linux/gamemode.h (limited to 'src/common') 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) ) endif() +if (UNIX) + 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..8876d8dc4 --- /dev/null +++ b/src/common/linux/gamemode.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include + +#include "common/linux/gamemode.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 a10131eb2..3e829253f 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -219,6 +219,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 788020bde..491f0d3e0 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -178,8 +178,6 @@ struct Values { true, &use_speed_limit}; - Setting enable_gamemode{linkage, false, "enable_gamemode", Category::Core}; - // Cpu SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, CpuAccuracy::Auto, CpuAccuracy::Paranoid, @@ -429,6 +427,9 @@ struct Values { true, true}; + // Linux + SwitchableSetting enable_gamemode{linkage, true, "enable_gamemode", Category::Linux}; + // Controls InputSetting> 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, }; -- cgit v1.2.3