Skip to content

Commit

Permalink
chore(gamescope): Add remaining patches (Thanks ChimeraOS team)!
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Apr 29, 2024
1 parent fc3afb5 commit c4005e1
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 13 deletions.
14 changes: 2 additions & 12 deletions spec_files/gamescope/720p.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
index 52dd8d1..b62c46e 100644
index 52dd8d1..05337c1 100644
--- a/src/steamcompmgr.cpp
+++ b/src/steamcompmgr.cpp
@@ -140,6 +140,9 @@ extern float g_flInternalDisplayBrightnessNits;
extern float g_flHDRItmSdrNits;
extern float g_flHDRItmTargetNits;

+// define env_to_bool to point to the function in drm: remove in later patches pl0x
+extern bool env_to_bool(const char *env);
+
uint64_t g_lastWinSeq = 0;

static std::shared_ptr<gamescope::BackendBlob> s_scRGB709To2020Matrix;
@@ -5202,6 +5205,13 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
@@ -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 ];
Expand Down
124 changes: 124 additions & 0 deletions spec_files/gamescope/external-rotation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
diff --git a/src/drm.cpp b/src/drm.cpp
index 42c67b9..628bfc9 100644
--- a/src/drm.cpp
+++ b/src/drm.cpp
@@ -521,6 +521,7 @@ bool g_bSupportsSyncObjs = false;

extern gamescope::GamescopeModeGeneration g_eGamescopeModeGeneration;
extern GamescopePanelOrientation g_DesiredInternalOrientation;
+extern GamescopePanelOrientation g_DesiredExternalOrientation;

extern bool g_bForceDisableColorMgmt;

@@ -2008,6 +2009,10 @@ namespace gamescope
{
m_ChosenOrientation = g_DesiredInternalOrientation;
}
+ else if ( this->GetScreenType() == GAMESCOPE_SCREEN_TYPE_EXTERNAL && g_DesiredExternalOrientation != GAMESCOPE_PANEL_ORIENTATION_AUTO )
+ {
+ m_ChosenOrientation = g_DesiredExternalOrientation;
+ }
else
{
if ( this->GetProperties().panel_orientation )
diff --git a/src/main.cpp b/src/main.cpp
index 88c4c7c..6f4cae4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -121,6 +121,7 @@ const struct option *gamescope_options = (struct option[]){
{ "disable-xres", no_argument, nullptr, 'x' },
{ "fade-out-duration", required_argument, nullptr, 0 },
{ "force-orientation", required_argument, nullptr, 0 },
+ { "force-external-orientation", required_argument, nullptr, 0 },
{ "force-windows-fullscreen", no_argument, nullptr, 0 },

{ "disable-color-management", no_argument, nullptr, 0 },
@@ -171,6 +172,7 @@ const char usage[] =
" --xwayland-count create N xwayland servers\n"
" --prefer-vk-device prefer Vulkan device for compositing (ex: 1002:7300)\n"
" --force-orientation rotate the internal display (left, right, normal, upsidedown)\n"
+ " --force-external-orientation rotate the external display (left, right, normal, upsidedown)\n"
" --force-windows-fullscreen force windows inside of gamescope to be the size of the nested display (fullscreen)\n"
" --cursor-scale-height if specified, sets a base output height to linearly scale the cursor against.\n"
" --hdr-enabled enable HDR output (needs Gamescope WSI layer enabled for support from clients)\n"
@@ -348,7 +350,24 @@ static GamescopePanelOrientation force_orientation(const char *str)
} else if (strcmp(str, "upsidedown") == 0) {
return GAMESCOPE_PANEL_ORIENTATION_180;
} else {
- fprintf( stderr, "gamescope: invalid value for --force-orientation\n" );
+ fprintf( stderr, "gamescope: invalid value for given for --force-orientation\n" );
+ exit(1);
+ }
+}
+
+GamescopePanelOrientation g_DesiredExternalOrientation = GAMESCOPE_PANEL_ORIENTATION_AUTO;
+static GamescopePanelOrientation force_external_orientation(const char *str)
+{
+ if (strcmp(str, "normal") == 0) {
+ return GAMESCOPE_PANEL_ORIENTATION_0;
+ } else if (strcmp(str, "right") == 0) {
+ return GAMESCOPE_PANEL_ORIENTATION_270;
+ } else if (strcmp(str, "left") == 0) {
+ return GAMESCOPE_PANEL_ORIENTATION_90;
+ } else if (strcmp(str, "upsidedown") == 0) {
+ return GAMESCOPE_PANEL_ORIENTATION_180;
+ } else {
+ fprintf( stderr, "gamescope: invalid value for given for --force-external-orientation\n" );
exit(1);
}
}
@@ -648,6 +667,8 @@ int main(int argc, char **argv)
g_eGamescopeModeGeneration = parse_gamescope_mode_generation( optarg );
} else if (strcmp(opt_name, "force-orientation") == 0) {
g_DesiredInternalOrientation = force_orientation( optarg );
+ } else if (strcmp(opt_name, "force-external-orientation") == 0) {
+ g_DesiredExternalOrientation = force_external_orientation( optarg );
} else if (strcmp(opt_name, "sharpness") == 0 ||
strcmp(opt_name, "fsr-sharpness") == 0) {
g_upscaleFilterSharpness = atoi( optarg );
diff --git a/src/main.hpp b/src/main.hpp
index 4e4e9a7..be9a9dd 100644
--- a/src/main.hpp
+++ b/src/main.hpp
@@ -28,6 +28,7 @@ extern bool g_bGrabbed;

extern float g_mouseSensitivity;
extern const char *g_sOutputName;
+extern bool g_bExternalForced;

enum class GamescopeUpscaleFilter : uint32_t
{
diff --git a/src/wlserver.cpp b/src/wlserver.cpp
index 9afaab7..7b78bbc 100644
--- a/src/wlserver.cpp
+++ b/src/wlserver.cpp
@@ -2130,6 +2130,29 @@ static void apply_touchscreen_orientation(double *x, double *y )
break;
}

+ // Rotate screen if it's forced with --force-external-orientation
+ switch ( GetBackend()->GetConnector( gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL )->GetCurrentOrientation() )
+ {
+ default:
+ case GAMESCOPE_PANEL_ORIENTATION_AUTO:
+ case GAMESCOPE_PANEL_ORIENTATION_0:
+ tx = *x;
+ ty = *y;
+ break;
+ case GAMESCOPE_PANEL_ORIENTATION_90:
+ tx = 1.0 - *y;
+ ty = *x;
+ break;
+ case GAMESCOPE_PANEL_ORIENTATION_180:
+ tx = 1.0 - *x;
+ ty = 1.0 - *y;
+ break;
+ case GAMESCOPE_PANEL_ORIENTATION_270:
+ tx = *y;
+ ty = 1.0 - *x;
+ break;
+ }
+
*x = tx;
*y = ty;
}
5 changes: 4 additions & 1 deletion spec_files/gamescope/gamescope.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

%global _default_patch_fuzz 2
%global build_timestamp %(date +"%Y%m%d")
%global gamescope_tag 3.14.7
%global gamescope_tag 3.14.8

Name: gamescope
Version: 100.%{gamescope_tag}
Expand All @@ -18,6 +18,9 @@ Source0: stb.pc
Patch0: hardware.patch
Patch1: 720p.patch
Patch2: disable-steam-touch-click-atom.patch
Patch3: external-rotation.patch
Patch4: panel-type.patch
Patch5: gestures.patch

BuildRequires: meson >= 0.54.0
BuildRequires: ninja-build
Expand Down
50 changes: 50 additions & 0 deletions spec_files/gamescope/gestures.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/src/wlserver.cpp b/src/wlserver.cpp
index 7b78bbc..2b43edd 100644
--- a/src/wlserver.cpp
+++ b/src/wlserver.cpp
@@ -70,6 +70,8 @@

static LogScope wl_log("wlserver");

+extern bool env_to_bool(const char *env);
+
struct wlserver_t wlserver = {
.touch_down_ids = {}
};
@@ -2189,6 +2191,36 @@ void wlserver_touchmotion( double x, double y, int touch_id, uint32_t time )
if ( eMode == gamescope::TouchClickModes::Passthrough )
{
wlr_seat_touch_notify_motion( wlserver.wlr.seat, time, touch_id, tx, ty );
+
+ if ( !env_to_bool(getenv("GAMESCOPE_DISABLE_TOUCH_GESTURES")) ) {
+ bool start_gesture = false;
+
+ // Round the x-coordinate to the nearest whole number
+ uint32_t roundedCursorX = static_cast<int>(std::round(wlserver.mouse_surface_cursorx));
+ // Grab 2% of the display to be used for the edge range
+ double edge_range = g_nOutputWidth * 0.02;
+
+ // if the touch cursor x position is less or equal to the range then start the gesture for left to right
+ if (roundedCursorX <= edge_range) {
+ start_gesture = true;
+ }
+ // if the touch cursor x position is the output width minus the edge range value then we are doing right to left
+ if (roundedCursorX >= g_nOutputWidth - edge_range) {
+ start_gesture = true;
+ }
+ // when the gesture is started and we are moving to the end of the edge range open home
+ if (start_gesture && roundedCursorX >= 1 && roundedCursorX <= edge_range) {
+ wl_log.infof("Detected Home gesture");
+ wlserver_open_steam_menu(0);
+ start_gesture = false;
+ }
+ // when the gesture is started and we are moving from the output width minus the edge range to the output width open QAM
+ if (start_gesture && roundedCursorX >= g_nOutputWidth - edge_range && roundedCursorX <= g_nOutputWidth ) {
+ wl_log.infof("Detected QAM gesture");
+ wlserver_open_steam_menu(1);
+ start_gesture = false;
+ }
+ }
}
else if ( eMode == gamescope::TouchClickModes::Disabled )
{
81 changes: 81 additions & 0 deletions spec_files/gamescope/panel-type.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
diff --git a/src/backend.h b/src/backend.h
index 9c2db15..046eb10 100644
--- a/src/backend.h
+++ b/src/backend.h
@@ -17,6 +17,7 @@ struct wlr_buffer;
struct wlr_dmabuf_attributes;

struct FrameInfo_t;
+extern gamescope::GamescopeScreenType g_ForcedScreenType;

namespace gamescope
{
@@ -213,6 +214,8 @@ namespace gamescope
// Dumb helper we should remove to support multi display someday.
gamescope::GamescopeScreenType GetScreenType()
{
+ if (g_ForcedScreenType != GAMESCOPE_SCREEN_TYPE_AUTO)
+ return g_ForcedScreenType;
if ( GetCurrentConnector() )
return GetCurrentConnector()->GetScreenType();

diff --git a/src/gamescope_shared.h b/src/gamescope_shared.h
index f34174e..ed30d8c 100644
--- a/src/gamescope_shared.h
+++ b/src/gamescope_shared.h
@@ -22,6 +22,7 @@ namespace gamescope
{
GAMESCOPE_SCREEN_TYPE_INTERNAL,
GAMESCOPE_SCREEN_TYPE_EXTERNAL,
+ GAMESCOPE_SCREEN_TYPE_AUTO,

GAMESCOPE_SCREEN_TYPE_COUNT
};
diff --git a/src/main.cpp b/src/main.cpp
index 6f4cae4..27a6c8f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -122,6 +122,7 @@ const struct option *gamescope_options = (struct option[]){
{ "fade-out-duration", required_argument, nullptr, 0 },
{ "force-orientation", required_argument, nullptr, 0 },
{ "force-external-orientation", required_argument, nullptr, 0 },
+ { "force-panel-type", required_argument, nullptr, 0 },
{ "force-windows-fullscreen", no_argument, nullptr, 0 },

{ "disable-color-management", no_argument, nullptr, 0 },
@@ -173,6 +174,7 @@ const char usage[] =
" --prefer-vk-device prefer Vulkan device for compositing (ex: 1002:7300)\n"
" --force-orientation rotate the internal display (left, right, normal, upsidedown)\n"
" --force-external-orientation rotate the external display (left, right, normal, upsidedown)\n"
+ " --force-panel-type force gamescope to treat the display as either internal or external\n"
" --force-windows-fullscreen force windows inside of gamescope to be the size of the nested display (fullscreen)\n"
" --cursor-scale-height if specified, sets a base output height to linearly scale the cursor against.\n"
" --hdr-enabled enable HDR output (needs Gamescope WSI layer enabled for support from clients)\n"
@@ -371,6 +373,18 @@ static GamescopePanelOrientation force_external_orientation(const char *str)
exit(1);
}
}
+gamescope::GamescopeScreenType g_ForcedScreenType = gamescope::GAMESCOPE_SCREEN_TYPE_AUTO;
+static gamescope::GamescopeScreenType force_panel_type(const char *str)
+{
+ if (strcmp(str, "internal") == 0) {
+ return gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL;
+ } else if (strcmp(str, "external") == 0) {
+ return gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL;
+ } else {
+ fprintf( stderr, "gamescope: invalid value for --force-panel-type\n" );
+ exit(1);
+ }
+}

static enum GamescopeUpscaleScaler parse_upscaler_scaler(const char *str)
{
@@ -669,6 +683,8 @@ int main(int argc, char **argv)
g_DesiredInternalOrientation = force_orientation( optarg );
} else if (strcmp(opt_name, "force-external-orientation") == 0) {
g_DesiredExternalOrientation = force_external_orientation( optarg );
+ } else if (strcmp(opt_name, "force-panel-type") == 0) {
+ g_ForcedScreenType = force_panel_type( optarg );
} else if (strcmp(opt_name, "sharpness") == 0 ||
strcmp(opt_name, "fsr-sharpness") == 0) {
g_upscaleFilterSharpness = atoi( optarg );

0 comments on commit c4005e1

Please sign in to comment.