diff options
Diffstat (limited to 'src/common/linux/gamemode.cpp')
| -rw-r--r-- | src/common/linux/gamemode.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
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 | |||
| 9 | namespace Common::Linux { | ||
| 10 | |||
| 11 | void 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 | |||
| 21 | void 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 | |||
| 31 | void SetGamemodeState(bool state) { | ||
| 32 | if (state) { | ||
| 33 | StartGamemode(); | ||
| 34 | } else { | ||
| 35 | StopGamemode(); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | } // namespace Common::Linux | ||