Merge pull request #11946 from flodavid/gamemode
Enable (Feral Interactive) Gamemode on Linux
This commit is contained in:
commit
337e37f91d
17 changed files with 583 additions and 9 deletions
|
@ -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
|
||||
|
|
39
src/common/linux/gamemode.cpp
Normal file
39
src/common/linux/gamemode.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
// 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/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
|
24
src/common/linux/gamemode.h
Normal file
24
src/common/linux/gamemode.h
Normal file
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -429,6 +429,9 @@ struct Values {
|
|||
true,
|
||||
true};
|
||||
|
||||
// Linux
|
||||
SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux};
|
||||
|
||||
// Controls
|
||||
InputSetting<std::array<PlayerInput, 10>> players;
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ enum class Category : u32 {
|
|||
Multiplayer,
|
||||
Services,
|
||||
Paths,
|
||||
Linux,
|
||||
MaxEnum,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue