From 513f894efc9e9c199ebd061d2ec838f33a9adabc Mon Sep 17 00:00:00 2001 From: Ilia Malakhov Date: Sat, 29 Jul 2023 00:09:09 +0200 Subject: [PATCH 1/4] gamescope3.12 upscaling options fix --- src/config/schema_blanks/gamescope/mod.rs | 40 +++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/config/schema_blanks/gamescope/mod.rs b/src/config/schema_blanks/gamescope/mod.rs index a923b69..3fe3c31 100644 --- a/src/config/schema_blanks/gamescope/mod.rs +++ b/src/config/schema_blanks/gamescope/mod.rs @@ -1,15 +1,17 @@ -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; -pub mod size; +use std::process::Command; + pub mod framerate; +pub mod size; pub mod window_type; pub mod prelude { - pub use super::Gamescope; - pub use super::size::Size; pub use super::framerate::Framerate; + pub use super::size::Size; pub use super::window_type::WindowType; + pub use super::Gamescope; } use prelude::*; @@ -91,6 +93,18 @@ impl From<&JsonValue> for Gamescope { } impl Gamescope { + fn is_legacy_version() -> bool { + // gamescope doesn't have --version, so parsing --help + match Command::new("/usr/bin/gamescope").arg("--help").output() { + Err(_) => false, + Ok(output) => String::from_utf8(output.stderr) + .unwrap() + .lines() + .find(|s| s.contains("-F, --filter")) + .is_none() // if no --filter, then it's old version + } + } + pub fn get_command(&self) -> Option { // https://github.com/bottlesdevs/Bottles/blob/b908311348ed1184ead23dd76f9d8af41ff24082/src/backend/wine/winecommand.py#L478 if self.enabled { @@ -134,17 +148,29 @@ impl Gamescope { // Set integer scaling if self.integer_scaling { - gamescope += " -n"; + if Gamescope::is_legacy_version() { + gamescope += " -n"; + } else { + gamescope += " -F integer" + } } // Set FSR support if self.fsr { - gamescope += " -U"; + if Gamescope::is_legacy_version() { + gamescope += " -U"; + } else { + gamescope += " -F fsr" + } } // Set NIS (Nvidia Image Scaling) support if self.nis { - gamescope += " -Y"; + if Gamescope::is_legacy_version() { + gamescope += " -Y"; + } else { + gamescope += " -F nis" + } } Some(gamescope) From 4e4711409091a1676bf0f16fe510144b55b27705 Mon Sep 17 00:00:00 2001 From: Ilia Malakhov Date: Sat, 29 Jul 2023 00:12:36 +0200 Subject: [PATCH 2/4] Fix for case when gamescope --help has broken output --- src/config/schema_blanks/gamescope/mod.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/config/schema_blanks/gamescope/mod.rs b/src/config/schema_blanks/gamescope/mod.rs index 3fe3c31..1b1e82a 100644 --- a/src/config/schema_blanks/gamescope/mod.rs +++ b/src/config/schema_blanks/gamescope/mod.rs @@ -1,17 +1,20 @@ -use serde::{Deserialize, Serialize}; +use serde::{Serialize, Deserialize}; use serde_json::Value as JsonValue; use std::process::Command; -pub mod framerate; pub mod size; + +pub mod framerate; + pub mod window_type; pub mod prelude { - pub use super::framerate::Framerate; - pub use super::size::Size; - pub use super::window_type::WindowType; pub use super::Gamescope; + pub use super::size::Size; + pub use super::framerate::Framerate; + + pub use super::window_type::WindowType; } use prelude::*; @@ -98,7 +101,7 @@ impl Gamescope { match Command::new("/usr/bin/gamescope").arg("--help").output() { Err(_) => false, Ok(output) => String::from_utf8(output.stderr) - .unwrap() + .unwrap_or_default() .lines() .find(|s| s.contains("-F, --filter")) .is_none() // if no --filter, then it's old version From 18744481b3043e8a117e726860c5f0b39ba394a2 Mon Sep 17 00:00:00 2001 From: Ilia Malakhov Date: Sat, 29 Jul 2023 00:36:27 +0200 Subject: [PATCH 3/4] Gamescope::is_legacy_version true by default. Comments fixes --- src/config/schema_blanks/gamescope/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config/schema_blanks/gamescope/mod.rs b/src/config/schema_blanks/gamescope/mod.rs index 1b1e82a..bba2259 100644 --- a/src/config/schema_blanks/gamescope/mod.rs +++ b/src/config/schema_blanks/gamescope/mod.rs @@ -97,14 +97,14 @@ impl From<&JsonValue> for Gamescope { impl Gamescope { fn is_legacy_version() -> bool { - // gamescope doesn't have --version, so parsing --help + // gamescope doesn't have --version, so parsing --help instead match Command::new("/usr/bin/gamescope").arg("--help").output() { - Err(_) => false, + Err(_) => true, Ok(output) => String::from_utf8(output.stderr) .unwrap_or_default() .lines() .find(|s| s.contains("-F, --filter")) - .is_none() // if no --filter, then it's old version + .is_none() // if no --filter, then it's legacy version } } From ffa8223dc2c0a67c0ccb67de0c63cf079e1241fe Mon Sep 17 00:00:00 2001 From: Ilia Malakhov Date: Sat, 29 Jul 2023 00:51:42 +0200 Subject: [PATCH 4/4] If expression --- src/config/schema_blanks/gamescope/mod.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/config/schema_blanks/gamescope/mod.rs b/src/config/schema_blanks/gamescope/mod.rs index bba2259..de8f200 100644 --- a/src/config/schema_blanks/gamescope/mod.rs +++ b/src/config/schema_blanks/gamescope/mod.rs @@ -151,28 +151,28 @@ impl Gamescope { // Set integer scaling if self.integer_scaling { - if Gamescope::is_legacy_version() { - gamescope += " -n"; + gamescope += if Gamescope::is_legacy_version() { + " -n" } else { - gamescope += " -F integer" + " -F integer" } } // Set FSR support if self.fsr { - if Gamescope::is_legacy_version() { - gamescope += " -U"; + gamescope += if Gamescope::is_legacy_version() { + " -U" } else { - gamescope += " -F fsr" + " -F fsr" } } // Set NIS (Nvidia Image Scaling) support if self.nis { - if Gamescope::is_legacy_version() { - gamescope += " -Y"; + gamescope += if Gamescope::is_legacy_version() { + " -Y" } else { - gamescope += " -F nis" + " -F nis" } }