Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add/gamescope legacy #1911

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions anda/games/gamescope-legacy/0001-cstdint.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 5529e8ac8f3232ec6233e33286834548e1d8018d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= <[email protected]>
Date: Sun, 8 Oct 2023 22:10:33 +0200
Subject: [PATCH] <cstdint>

---
src/reshade/source/effect_parser_stmt.cpp | 1 +
src/reshade/source/effect_token.hpp | 1 +
2 files changed, 2 insertions(+)

diff --git a/src/reshade/source/effect_parser_stmt.cpp b/src/reshade/source/effect_parser_stmt.cpp
index 7829729..f126be2 100644
--- a/src/reshade/source/effect_parser_stmt.cpp
+++ b/src/reshade/source/effect_parser_stmt.cpp
@@ -9,6 +9,7 @@
#include <cctype> // std::toupper
#include <cassert>
#include <functional>
+#include <limits>
#include <string_view>

struct on_scope_exit
diff --git a/src/reshade/source/effect_token.hpp b/src/reshade/source/effect_token.hpp
index 072d439..e4bb633 100644
--- a/src/reshade/source/effect_token.hpp
+++ b/src/reshade/source/effect_token.hpp
@@ -5,6 +5,7 @@

#pragma once

+#include <cstdint>
#include <string>
#include <vector>

--
2.41.0
8 changes: 8 additions & 0 deletions anda/games/gamescope-legacy/anda.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project pkg {
rpm {
spec = "gamescope-legacy.spec"
}
labels {
multilib = 1
}
}
129 changes: 129 additions & 0 deletions anda/games/gamescope-legacy/gamescope-legacy.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
%global libliftoff_minver 0.4.1
%global reshade_commit 4245743a8c41abbe3dc73980c1810fe449359bf1
%global reshade_shortcommit %(c=%{reshade_commit}; echo ${c:0:7})
%global _default_patch_fuzz 2


# =============================================================================
# IMPORTANT: This package should *not* have an update script, at least not one that
# tracks upstream Gamescope from Valve. This package is intended to be a legacy
# build for Polaris and older GPUs from AMD, and should not be updated to the
# latest version.
#
# This package however, should be obsoleted once https://github.com/ValveSoftware/gamescope/issues/1218
# is finally resolved, and Gamescope's Wayland backend has a fallback for GPUs without Vulkan DRM modifiers.
# =============================================================================


Name: gamescope-legacy
Version: 3.14.2
Release: 1%{?dist}
Summary: Legacy builds of gamescope, a micro-compositor for video games on Wayland
Packager: Cappy Ishihara <[email protected]>
License: BSD
URL: https://github.com/ValveSoftware/gamescope
Source0: %{url}/archive/%{version}/gamescope-%{version}.tar.gz
# Create stb.pc to satisfy dependency('stb')
Source1: stb.pc
Source2: https://github.com/Joshua-Ashton/reshade/archive/%{reshade_commit}/reshade-%{reshade_shortcommit}.tar.gz

Patch0: 0001-cstdint.patch

# https://hhd.dev/
Patch1: v2-0001-always-send-ctrl-1-2-to-steam-s-wayland-session.patch

# ChimeraOS
Patch2: legacy-720p.patch

BuildRequires: meson >= 0.54.0
BuildRequires: ninja-build
BuildRequires: cmake
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: glm-devel
BuildRequires: google-benchmark-devel
BuildRequires: libXmu-devel
BuildRequires: libXcursor-devel
BuildRequires: pkgconfig(libdisplay-info)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xdamage)
BuildRequires: pkgconfig(xcomposite)
BuildRequires: pkgconfig(xrender)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(xfixes)
BuildRequires: pkgconfig(xxf86vm)
BuildRequires: pkgconfig(xtst)
BuildRequires: pkgconfig(xres)
BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(vulkan)
BuildRequires: pkgconfig(wayland-scanner)
BuildRequires: pkgconfig(wayland-server)
BuildRequires: pkgconfig(wayland-protocols) >= 1.17
BuildRequires: pkgconfig(xkbcommon)
BuildRequires: pkgconfig(sdl2)
BuildRequires: pkgconfig(libpipewire-0.3)
BuildRequires: pkgconfig(libavif)
BuildRequires: (pkgconfig(wlroots) >= 0.17.0 with pkgconfig(wlroots) < 0.18)
BuildRequires: (pkgconfig(libliftoff) >= 0.4.1 with pkgconfig(libliftoff) < 0.5)
BuildRequires: pkgconfig(libcap)
BuildRequires: pkgconfig(hwdata)
BuildRequires: spirv-headers-devel
# Enforce the the minimum EVR to contain fixes for all of:
# CVE-2021-28021 CVE-2021-42715 CVE-2021-42716 CVE-2022-28041 CVE-2023-43898
# CVE-2023-45661 CVE-2023-45662 CVE-2023-45663 CVE-2023-45664 CVE-2023-45666
# CVE-2023-45667
BuildRequires: stb_image-devel >= 2.28^20231011gitbeebb24-12
# Header-only library: -static is for tracking per guidelines
BuildRequires: stb_image-static
BuildRequires: stb_image_resize-devel
BuildRequires: stb_image_resize-static
BuildRequires: stb_image_write-devel
BuildRequires: stb_image_write-static
BuildRequires: vkroots-devel
BuildRequires: /usr/bin/glslangValidator

# libliftoff hasn't bumped soname, but API/ABI has changed for 0.2.0 release
Requires: libliftoff%{?_isa} >= %{libliftoff_minver}
Requires: xorg-x11-server-Xwayland

Requires: terra-gamescope-libs
Requires: terra-gamescope-libs(x86-32)

Recommends: mesa-dri-drivers
Recommends: mesa-vulkan-drivers

%description
%{name} is the micro-compositor optimized for running video games on Wayland. This is a legacy build primarily intended for use by Polaris GPUs.

%prep
%autosetup -p1 -a2 -N -n gamescope-%{version}
# Install stub pkgconfig file
mkdir -p pkgconfig
cp %{SOURCE1} pkgconfig/stb.pc

# Replace spirv-headers include with the system directory
sed -i 's^../thirdparty/SPIRV-Headers/include/spirv/^/usr/include/spirv/^' src/meson.build

# Push in reshade from sources instead of submodule
rm -rf src/reshade && mv reshade-%{reshade_commit} src/reshade

%autopatch -p1

%build
export PKG_CONFIG_PATH=pkgconfig
%meson -Dpipewire=enabled -Denable_gamescope_wsi_layer=false -Denable_openvr_support=false -Dforce_fallback_for=[]
%meson_build

%install
%meson_install
# Rename to not conflict with the base package
mv %{buildroot}%{_bindir}/gamescope %{buildroot}%{_bindir}/gamescope-legacy

%files
%license LICENSE
%doc README.md
%{_bindir}/gamescope-legacy

%changelog
%autochangelog

33 changes: 33 additions & 0 deletions anda/games/gamescope-legacy/legacy-720p.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 072ebb67cd4a88fd0f5db22a92a46f8316f28a46 Mon Sep 17 00:00:00 2001
From: Matthew Anderson <[email protected]>
Date: Tue, 25 Jul 2023 18:05:05 -0500
Subject: [PATCH] Set default to native resolution of display if Steam tries to
force 720p/800p

You can select 720p/800p still in game or via Steam's resolution setting
Steam > Settings > Display > Resolution

This effectively reverts the changes Valve made a year ago forcing us to
720p.
---
src/steamcompmgr.cpp | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
index 52dd8d1cf..5b0fa6e52 100644
--- a/src/steamcompmgr.cpp
+++ b/src/steamcompmgr.cpp
@@ -5202,6 +5202,13 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
size_t server_idx = size_t{ xwayland_mode_ctl[ 0 ] };
int width = xwayland_mode_ctl[ 1 ];
int height = xwayland_mode_ctl[ 2 ];
+
+ if ( g_nOutputWidth != 1280 && width == 1280 )
+ {
+ width = g_nOutputWidth;
+ height = g_nOutputHeight;
+ }
+
bool allowSuperRes = !!xwayland_mode_ctl[ 3 ];

if ( !allowSuperRes )
7 changes: 7 additions & 0 deletions anda/games/gamescope-legacy/stb.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
prefix=/usr
includedir=${prefix}/include/stb

Name: stb
Description: Single-file public domain libraries for C/C++
Version: 0.1.0
Cflags: -I${includedir}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 35e001dc59a44227d670c667a85a6ef5472eee58 Mon Sep 17 00:00:00 2001
From: antheas <[email protected]>
Date: Sat, 20 Jul 2024 01:23:19 +0300
Subject: [PATCH v2] always send ctrl+1/2 to steam's wayland session

---
src/wlserver.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/wlserver.cpp b/src/wlserver.cpp
index 1852be9..7de737d 100644
--- a/src/wlserver.cpp
+++ b/src/wlserver.cpp
@@ -369,7 +369,12 @@ static void wlserver_handle_key(struct wl_listener *listener, void *data)
keysym == XKB_KEY_XF86AudioLowerVolume ||
keysym == XKB_KEY_XF86AudioRaiseVolume ||
keysym == XKB_KEY_XF86PowerOff;
- if ( ( event->state == WL_KEYBOARD_KEY_STATE_PRESSED || event->state == WL_KEYBOARD_KEY_STATE_RELEASED ) && forbidden_key )
+
+ // Check for steam keys (ctrl + 1/2)
+ bool is_steamshortcut = (keyboard->wlr->modifiers.depressed & WLR_MODIFIER_CTRL) && (keysym == XKB_KEY_1 ||
+ keysym == XKB_KEY_2);
+
+ if ( ( event->state == WL_KEYBOARD_KEY_STATE_PRESSED || event->state == WL_KEYBOARD_KEY_STATE_RELEASED ) && (forbidden_key || is_steamshortcut) )
{
// Always send volume+/- to root server only, to avoid it reaching the game.
struct wlr_surface *old_kb_surf = wlserver.kb_focus_surface;
@@ -378,6 +383,9 @@ static void wlserver_handle_key(struct wl_listener *listener, void *data)
{
wlserver_keyboardfocus( new_kb_surf, false );
wlr_seat_set_keyboard( wlserver.wlr.seat, keyboard->wlr );
+ // Send modifiers to steam for it to work
+ if (is_steamshortcut)
+ wlr_seat_keyboard_notify_modifiers(wlserver.wlr.seat, &keyboard->wlr->modifiers);
wlr_seat_keyboard_notify_key( wlserver.wlr.seat, event->time_msec, event->keycode, event->state );
wlserver_keyboardfocus( old_kb_surf, false );
return;
--
2.45.2
8 changes: 8 additions & 0 deletions anda/misc/extest/anda.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project pkg {
rpm {
spec = "rust-extest.spec"
}
labels {
multilib = 1
}
}
13 changes: 13 additions & 0 deletions anda/misc/extest/override_steam_desktop_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash -x
EXTEST="/usr/lib/extest/libextest.so"
STEAM_DESKTOP_FILE="/usr/share/applications/steam.desktop"

if ! [ -f $STEAM_DESKTOP_FILE ]; then
echo "Could not find Steam's desktop file, is XDG_DATA_DIRS set properly?"
exit 1
fi

sed -i "s,Exec=/usr/bin/steam,Exec=env LD_PRELOAD=$EXTEST /usr/bin/steam," $STEAM_DESKTOP_FILE

echo $STEAM_DESKTOP_FILE
echo "Extest has been set up, enjoy!"
100 changes: 100 additions & 0 deletions anda/misc/extest/rust-extest.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
%global commit 79cdf2f642260d19139b071748c6f8d48a1dff10
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global commit_date 20240712

# While there's an upstream version at Supreeeme/extest, we're using
# the same fork as Bazzite so we can use the same patches.
# This fork has no tags so we're gonna use the commit hash as the version

# Don't mangle shebangs
%global __brp_mangle_shebangs %{nil}

# Exclude input files from mangling
%global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$
# Use Mold as the linker
%global build_rustflags %build_rustflags -C link-arg=-fuse-ld=mold

Name: extest
Version: %commit_date.git~%{shortcommit}
Release: %autorelease
Summary: X11 XTEST reimplementation primarily for Steam Controller on Wayland

License: MIT
URL: https://github.com/KyleGospo/extest

Source0: %{url}/archive/%{commit}.tar.gz

# While the upstream project has the same script, it copies the Steam desktop shortcut to
# $HOME and modifies it there. The following inline script modifies the global Steam
# desktop shortcut to load Extest for all users.
Source1: override_steam_desktop_file.sh

Packager: Cappy Ishihara <[email protected]>

BuildRequires: cargo-rpm-macros >= 24
BuildRequires: anda-srpm-macros
BuildRequires: openssl-devel
BuildRequires: gcc
BuildRequires: perl
BuildRequires: rust-packaging
BuildRequires: systemd-rpm-macros
BuildRequires: clang
BuildRequires: mold
Recommends: %{name}-steam
%ifarch x86_64
Recommends: %{name}.i686
%endif

%description
Extest is a drop in replacement for the X11 XTEST extension. It creates a virtual device with the uinput kernel module. It's been primarily developed for allowing the desktop functionality on the Steam Controller to work while Steam is open on Wayland.


# Subpackage for dynamically patching Steam's scripts
%package steam
BuildArch: noarch
Summary: Extest subpackage that patches Steam's scripts to load Extest

%description steam
This subpackage contains scripts that patch Steam's scripts to load Extest. This is necessary for Extest to work with Steam on Wayland.

# If on x86_64, require the i686 version of the package
%ifarch x86_64
Requires: %{name}.i686
%else
Requires: %{name}
%endif

%prep
%autosetup -n %{name}-%{commit}
%cargo_prep_online

%build
%cargo_build

%install
%cargo_install
mkdir -p %{buildroot}%{_libdir}/extest/
install -D -p -m0755 target/rpm/libextest.so %{buildroot}%{_libdir}/extest/libextest.so

mkdir -p %{buildroot}%{_libexecdir}/extest/
install -D -p -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/extest/override_steam_desktop_file.sh


# Trigger on Steam install for steam subpackage
%triggerin -n %{name}-steam -- steam
%{_libexecdir}/extest/override_steam_desktop_file.sh



%files
%license LICENSE
%doc README.md
%{_libdir}/extest/libextest.so

%files steam
%{_libexecdir}/extest/override_steam_desktop_file.sh


%changelog
%autochangelog

5 changes: 5 additions & 0 deletions anda/misc/extest/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rpm.global("commit", gh_commit("KyleGospo/extest"));
if rpm.changed() {
rpm.global("commit_date", date());
rpm.release();
}
Loading