From c771e62c39be3d560fd3595f4eee282989ca48a5 Mon Sep 17 00:00:00 2001 From: gfiroozeh <164580927+gfiroozeh@users.noreply.github.com> Date: Fri, 22 Mar 2024 20:00:39 -0400 Subject: [PATCH] feat: add gamescope force-grab-cursor flag --- assets/locales/en/gamescope.ftl | 3 +++ src/ui/preferences/gamescope.rs | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/assets/locales/en/gamescope.ftl b/assets/locales/en/gamescope.ftl index 6fbb639a..b0b51f96 100644 --- a/assets/locales/en/gamescope.ftl +++ b/assets/locales/en/gamescope.ftl @@ -11,3 +11,6 @@ nis-description = An open source upscaling technique developed by Nvidia as a cr other-settings = Other settings framerate-limit = Framerate limit unfocused-framerate-limit = Unfocused framerate limit + +force-grab-cursor = Force grab cursor +force-grab-cursor-description = Always use relative mouse mode instead of flipping dependent on cursor visibility. The mouse cursor will correctly be centered in the game. \ No newline at end of file diff --git a/src/ui/preferences/gamescope.rs b/src/ui/preferences/gamescope.rs index 207ae068..4acbd974 100644 --- a/src/ui/preferences/gamescope.rs +++ b/src/ui/preferences/gamescope.rs @@ -250,6 +250,26 @@ impl SimpleAsyncComponent for GamescopeApp { } } } + }, + + adw::ActionRow { + set_title: &tr!("force-grab-cursor"), + set_subtitle: &tr!("force-grab-cursor-description"), + + add_suffix = >k::Switch { + set_valign: gtk::Align::Center, + set_state: CONFIG.game.enhancements.gamescope.force_grab_cursor, + + connect_state_notify => |switch| { + if is_ready() { + if let Ok(mut config) = Config::get() { + config.game.enhancements.gamescope.force_grab_cursor = switch.state(); + + Config::update(config); + } + } + } + } } } }