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/linux/gamemode.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/common/linux/gamemode.cpp (limited to 'src/common/linux/gamemode.cpp') 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 -- cgit v1.2.3