Skip to content

Commit

Permalink
Add GameMode support for Linux build (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
rluxv committed May 11, 2023
1 parent b74ae21 commit 1bcdb35
Show file tree
Hide file tree
Showing 10 changed files with 467 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ endif()

if (UNIX AND NOT APPLE)
option(ENABLE_WAYLAND "Build with Wayland support" ON)
option(ENABLE_FERAL_GAMEMODE "Enables Feral Interactive GameMode Support" ON)
endif()

option(ENABLE_OPENGL "Enables the OpenGL backend" ON)
option(ENABLE_VULKAN "Enables the Vulkan backend" ON)
option(ENABLE_DISCORD_RPC "Enables the Discord Rich Presence feature" ON)


# input backends
if (WIN32)
option(ENABLE_XINPUT "Enables the usage of XInput" ON)
Expand Down Expand Up @@ -127,6 +129,7 @@ if (UNIX AND NOT APPLE)
add_compile_definitions(HAS_WAYLAND)
endif()
find_package(GTK3 REQUIRED)

endif()

if (ENABLE_VULKAN)
Expand All @@ -143,6 +146,14 @@ if (ENABLE_DISCORD_RPC)
target_include_directories(discord-rpc INTERFACE ./dependencies/discord-rpc/include)
endif()

if(UNIX AND NOT APPLE)
if(ENABLE_FERAL_GAMEMODE)
add_compile_definitions(ENABLE_FERAL_GAMEMODE)
add_subdirectory(dependencies/gamemode EXCLUDE_FROM_ALL)
target_include_directories(gamemode INTERFACE ./dependencies/gamemode/lib)
endif()
endif()

if (ENABLE_WXWIDGETS)
find_package(wxWidgets 3.2 REQUIRED COMPONENTS base core gl propgrid xrc)
endif()
Expand Down
4 changes: 4 additions & 0 deletions dependencies/gamemode/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project( gamemode LANGUAGES C )
add_library (gamemode
"lib/gamemode_client.h"
"lib/client_loader.c")
35 changes: 35 additions & 0 deletions dependencies/gamemode/lib/client_loader.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright (c) 2017-2019, Feral Interactive
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Feral Interactive nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

// Simply include the header with GAMEMODE_AUTO set
// This will ensure it calls the functions when it's loaded
#define GAMEMODE_AUTO
#include "gamemode_client.h"

0 comments on commit 1bcdb35

Please sign in to comment.