feat: removed is_legacy_version
in gamescope integration
This commit is contained in:
parent
4ea1a6a320
commit
1d659b2365
1 changed files with 6 additions and 39 deletions
|
@ -1,5 +1,3 @@
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use serde_json::Value as JsonValue;
|
use serde_json::Value as JsonValue;
|
||||||
|
|
||||||
|
@ -85,31 +83,12 @@ impl From<&JsonValue> for Gamescope {
|
||||||
|
|
||||||
force_grab_cursor: value.get("force_grab_cursor")
|
force_grab_cursor: value.get("force_grab_cursor")
|
||||||
.and_then(JsonValue::as_bool)
|
.and_then(JsonValue::as_bool)
|
||||||
.unwrap_or(default.force_grab_cursor),
|
.unwrap_or(default.force_grab_cursor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: temporary workaround for transition period, will be removed in future
|
|
||||||
#[cached::proc_macro::cached]
|
|
||||||
fn is_legacy_version() -> bool {
|
|
||||||
// gamescope doesn't have --version, so parsing --help instead
|
|
||||||
Command::new("gamescope").arg("--help").output()
|
|
||||||
|
|
||||||
// if no --filter, then it's legacy version
|
|
||||||
// also for whatever reason --help is printed to stderr
|
|
||||||
.map(|help| !String::from_utf8_lossy(&help.stderr).contains("-F, --filter"))
|
|
||||||
|
|
||||||
// If failed to launch gamescope, then yes, it's legacy (it's not but meh)
|
|
||||||
.unwrap_or(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Gamescope {
|
impl Gamescope {
|
||||||
/// Check if available gamescope version is legacy (<3.12.0)
|
|
||||||
pub fn is_legacy_version() -> bool {
|
|
||||||
is_legacy_version()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_command(&self) -> Option<String> {
|
pub fn get_command(&self) -> Option<String> {
|
||||||
// https://github.com/bottlesdevs/Bottles/blob/b908311348ed1184ead23dd76f9d8af41ff24082/src/backend/wine/winecommand.py#L478
|
// https://github.com/bottlesdevs/Bottles/blob/b908311348ed1184ead23dd76f9d8af41ff24082/src/backend/wine/winecommand.py#L478
|
||||||
// https://github.com/ValveSoftware/gamescope#options
|
// https://github.com/ValveSoftware/gamescope#options
|
||||||
|
@ -154,33 +133,21 @@ impl Gamescope {
|
||||||
|
|
||||||
// Set integer scaling
|
// Set integer scaling
|
||||||
if self.integer_scaling {
|
if self.integer_scaling {
|
||||||
gamescope += if Self::is_legacy_version() {
|
gamescope += " -S integer";
|
||||||
" -n"
|
|
||||||
} else {
|
|
||||||
" -S integer"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set FSR support
|
// Set FSR support
|
||||||
if self.fsr {
|
if self.fsr {
|
||||||
gamescope += if Self::is_legacy_version() {
|
gamescope += " -F fsr";
|
||||||
" -U"
|
|
||||||
} else {
|
|
||||||
" -F fsr"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set NIS (Nvidia Image Scaling) support
|
// Set NIS (Nvidia Image Scaling) support
|
||||||
if self.nis {
|
if self.nis {
|
||||||
gamescope += if Self::is_legacy_version() {
|
gamescope += " -F nis";
|
||||||
" -Y"
|
|
||||||
} else {
|
|
||||||
" -F nis"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.force_grab_cursor {
|
if self.force_grab_cursor {
|
||||||
gamescope += " --force-grab-cursor"
|
gamescope += " --force-grab-cursor";
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(gamescope)
|
Some(gamescope)
|
||||||
|
|
Loading…
Reference in a new issue