aboutsummaryrefslogtreecommitdiff
path: root/src/qt_common/gamemode.cpp
blob: b6ce5c2ca8f65941fb33e4034d17695b1b665d4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

// While technically available on al *NIX platforms, Linux is only available
// as the primary target of libgamemode.so - so warnings are suppressed
#ifdef __unix__
#include <gamemode_client.h>
#endif
#include "common/logging/log.h"
#include "qt_common/config/uisettings.h"
#include "qt_common/gamemode.h"

namespace Common::FeralGamemode {

/// @brief Start the gamemode client
void Start() noexcept {
    if (UISettings::values.enable_gamemode) {
#ifdef __unix__
        if (gamemode_request_start() < 0) {
#ifdef __linux__
            LOG_WARNING(Frontend, "{}", gamemode_error_string());
#else
            LOG_INFO(Frontend, "{}", gamemode_error_string());
#endif
        } else {
            LOG_INFO(Frontend, "Done");
        }
#endif
    }
}

/// @brief Stop the gmemode client
void Stop() noexcept {
    if (UISettings::values.enable_gamemode) {
#ifdef __unix__
        if (gamemode_request_end() < 0) {
#ifdef __linux__
            LOG_WARNING(Frontend, "{}", gamemode_error_string());
#else
            LOG_INFO(Frontend, "{}", gamemode_error_string());
#endif
        } else {
            LOG_INFO(Frontend, "Done");
        }
#endif
    }
}

} // namespace Common::FeralGamemode