From db3d7555e0fb98fcd55f842fe033a58888b2dbfc Mon Sep 17 00:00:00 2001 From: kingokksa Date: Sat, 31 Oct 2026 23:50:24 +0800 Subject: [PATCH] feat(gamescope): a three way switch for relative mouse motion Games that confine the cursor and warp it back to read movement never reach the nested hints rule, so their aim stays bounded by the screen. The convar defaults to 0 and leaves that rule alone; 1 forces relative motion for the focused game, 2 keeps the pointer absolute even when the rule would apply. --- .../patches/0126-relative-mouse-convar.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tools/gamescope/patches/0126-relative-mouse-convar.patch diff --git a/tools/gamescope/patches/0126-relative-mouse-convar.patch b/tools/gamescope/patches/0126-relative-mouse-convar.patch new file mode 100644 index 000000000..d0fccec25 --- /dev/null +++ b/tools/gamescope/patches/0126-relative-mouse-convar.patch @@ -0,0 +1,30 @@ +--- a/src/steamcompmgr.cpp ++++ b/src/steamcompmgr.cpp +@@ -3062,8 +3062,13 @@ + #endif + + gamescope::ConVar cv_cursor_composite{ "cursor_composite", 1, "0 = Never composite a cursor. 1 = Composite cursor when not nested. 2 = Always composite a cursor manually" }; ++static gamescope::ConVar cv_relative_mouse( "relative_mouse", 0, ++"0 = Leave it to the game and the nested hints. 1 = Send host pointer motion as relative movement, for games that confine the cursor and warp it back to read movement. 2 = Never go relative." ); + bool ShouldDrawCursor() + { ++ if ( cv_relative_mouse.Get() == 1 ) ++ return true; ++ + global_focus_t *pFocus = GetCurrentFocus(); + gamescope::INestedHints *pNestedHints = pFocus ? pFocus->GetNestedHints() : nullptr; + return gamescope::CursorShouldBeComposited( cv_cursor_composite.Get(), g_bForceRelativeMouse, +@@ -10810,7 +10815,12 @@ + + const bool bExcludedAppId = uAppId && gamescope::Algorithm::Contains( s_uRelativeMouseFilteredAppids, uAppId ); + +- const bool bRelativeMouseMode = bImageEmpty && bHasPointerConstraint && !bExcludedAppId; ++ const int nRelativeMouse = cv_relative_mouse.Get(); ++ const bool bForcedRelativeMouse = nRelativeMouse == 1 && !window_is_steam( pPaintFocus->inputFocusWindow ); ++ ++ const bool bRelativeMouseMode = nRelativeMouse == 2 ++ ? false ++ : ( bForcedRelativeMouse || ( bImageEmpty && bHasPointerConstraint && !bExcludedAppId ) ); + + pPaintFocus->GetNestedHints()->SetRelativeMouseMode( bRelativeMouseMode ); + }