From aaa614519e848c1df781ae27a21faa9346ea859c Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 5 Sep 2022 17:10:37 -0400 Subject: [PATCH] Use the actual gamemode library, instead of the helper Sometimes gamemoderun is not packaged on certain systems, so use the actual library if available instead to sidestep this problem. --- CMakeLists.txt | 6 ++++++ launcher/core/CMakeLists.txt | 9 +++++++++ launcher/core/src/launchercore.cpp | 11 +++++++++-- launcher/desktop/src/settingswindow.cpp | 4 ++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a4a307..d94bac1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ option(ENABLE_WATCHDOG "Build with Tesseract support (needed for Watchdog)" OFF) option(USE_OWN_LIBRARIES "Build with own libraries" OFF) option(BUILD_FLATPAK "Build with Flatpak support in mind" OFF) option(USE_STEAM "Build with Steam support" OFF) +option(USE_GAMEMODE "Build with GameMode support" ON) if (ENABLE_WATCHDOG) find_package(PkgConfig REQUIRED) @@ -17,6 +18,11 @@ if (ENABLE_WATCHDOG) pkg_search_module(LEPTONICA REQUIRED lept) endif () +if (USE_GAMEMODE) + find_package(PkgConfig REQUIRED) + pkg_search_module(GAMEMODE REQUIRED gamemode) +endif() + include(FetchContent) if (NOT USE_OWN_LIBRARIES) diff --git a/launcher/core/CMakeLists.txt b/launcher/core/CMakeLists.txt index 8675b9f..d6e5531 100644 --- a/launcher/core/CMakeLists.txt +++ b/launcher/core/CMakeLists.txt @@ -38,6 +38,11 @@ if(USE_STEAM) Steamworks) endif() +if(USE_GAMEMODE) + set(LIBRARIES ${LIBRARIES} + ${GAMEMODE_LIBRARIES}) +endif() + add_library(astra_core STATIC ${HEADERS} ${SRC}) target_include_directories(astra_core PUBLIC ${KEYCHAIN_INCLUDE_DIRS} @@ -62,6 +67,10 @@ if (ENABLE_WATCHDOG) target_compile_definitions(astra_core PUBLIC ENABLE_WATCHDOG) endif () +if(USE_GAMEMODE) + target_compile_definitions(astra_core PUBLIC USE_GAMEMODE) +endif() + if(USE_STEAM) target_compile_definitions(astra_core PUBLIC USE_STEAM) endif() \ No newline at end of file diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index 9c9744f..17656e5 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -21,6 +21,10 @@ #include #include +#ifdef USE_GAMEMODE +#include +#endif + #include "assetupdater.h" #include "encryptedarg.h" #include "launchercore.h" @@ -211,9 +215,12 @@ void LauncherCore::launchExecutable( if (profile.gamescope.refreshRate > 0) arguments.push_back("-r " + QString::number(profile.gamescope.refreshRate)); } + } +#endif - if (profile.useGamemode) - arguments.push_back("gamemoderun"); +#if USE_GAMEMODE + if(isGame && profile.useGamemode) { + gamemode_request_start(); } #endif diff --git a/launcher/desktop/src/settingswindow.cpp b/launcher/desktop/src/settingswindow.cpp index a030eb4..c3f42a2 100644 --- a/launcher/desktop/src/settingswindow.cpp +++ b/launcher/desktop/src/settingswindow.cpp @@ -237,6 +237,10 @@ void SettingsWindow::reloadControls() { useGamescope->setChecked(profile.useGamescope); useGamemode->setChecked(profile.useGamemode); +#ifndef USE_GAMEMODE + useGameMode->setEnabled(false); +#endif + useGamemode->setEnabled(core.gamemodeAvailable); useGamescope->setEnabled(core.gamescopeAvailable);