Browse Source
[gamemode] Make available on other platforms
[gamemode] Make available on other platforms
Signed-off-by: lizzie <lizzie@eden-emu.dev>pull/353/head
committed by
Caio Oliveira
No known key found for this signature in database
GPG Key ID: 362DA3DC1901E080
9 changed files with 101 additions and 98 deletions
-
2CMakeLists.txt
-
28externals/gamemode/gamemode_client.h
-
8src/common/CMakeLists.txt
-
50src/common/gamemode.cpp
-
17src/common/gamemode.h
-
40src/common/linux/gamemode.cpp
-
24src/common/linux/gamemode.h
-
14src/yuzu/main_window.cpp
-
16src/yuzu_cmd/yuzu.cpp
@ -0,0 +1,50 @@ |
|||||
|
// SPDX-FileCopyrightText: Copyright 2025 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/gamemode.h"
|
||||
|
#include "common/logging/log.h"
|
||||
|
#include "common/settings.h"
|
||||
|
|
||||
|
namespace Common::FeralGamemode { |
||||
|
|
||||
|
void Start() noexcept { |
||||
|
if (Settings::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
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void Stop() noexcept { |
||||
|
if (Settings::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::Linux
|
||||
@ -0,0 +1,17 @@ |
|||||
|
// SPDX-FileCopyrightText: Copyright 2025 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 |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
namespace Common::FeralGamemode { |
||||
|
|
||||
|
/// @brief Start the gamemode client |
||||
|
void Start() noexcept; |
||||
|
|
||||
|
/// @brief Stop the gmemode client |
||||
|
void Stop() noexcept; |
||||
|
|
||||
|
} // namespace Common::FeralGamemode |
||||
@ -1,40 +0,0 @@ |
|||||
// 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
|
|
||||
@ -1,24 +0,0 @@ |
|||||
// 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 |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue