mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-09-25 18:58:38 +00:00
fix: lots of clippy errors
This commit is contained in:
parent
92d522e86b
commit
4659eca89c
33 changed files with 197 additions and 302 deletions
|
@ -4,10 +4,9 @@ use std::path::Path;
|
||||||
pub fn get_adb_install_runner(apk_path: &String) -> Runner {
|
pub fn get_adb_install_runner(apk_path: &String) -> Runner {
|
||||||
let path = Path::new(apk_path);
|
let path = Path::new(apk_path);
|
||||||
path.try_exists().expect("APK file provided does not exist");
|
path.try_exists().expect("APK file provided does not exist");
|
||||||
let runner = Runner::new(
|
Runner::new(
|
||||||
None,
|
None,
|
||||||
"adb".into(),
|
"adb".into(),
|
||||||
vec!["install".into(), path.to_str().unwrap().to_string()],
|
vec!["install".into(), path.to_str().unwrap().to_string()],
|
||||||
);
|
)
|
||||||
runner
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ impl Cmake {
|
||||||
];
|
];
|
||||||
if self.vars.is_some() {
|
if self.vars.is_some() {
|
||||||
for (k, v) in self.vars.as_ref().unwrap() {
|
for (k, v) in self.vars.as_ref().unwrap() {
|
||||||
if k.contains(" ") {
|
if k.contains(' ') {
|
||||||
panic!("Cmake vars cannot contain spaces!");
|
panic!("Cmake vars cannot contain spaces!");
|
||||||
}
|
}
|
||||||
if v.contains(" ") {
|
if v.contains(' ') {
|
||||||
args.push(format!("-D{k}=\"{v}\"", k = k, v = v));
|
args.push(format!("-D{k}=\"{v}\"", k = k, v = v));
|
||||||
} else {
|
} else {
|
||||||
args.push(format!("-D{k}={v}", k = k, v = v));
|
args.push(format!("-D{k}={v}", k = k, v = v));
|
||||||
|
|
|
@ -20,10 +20,7 @@ impl Git {
|
||||||
fn get_ref(&self) -> Option<String> {
|
fn get_ref(&self) -> Option<String> {
|
||||||
let mut split = self.repo.split('#');
|
let mut split = self.repo.split('#');
|
||||||
split.next().expect("Could not get repo url");
|
split.next().expect("Could not get repo url");
|
||||||
match split.next() {
|
split.next().map(|s| s.into())
|
||||||
None => None,
|
|
||||||
Some(s) => Some(s.into()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_reset_runner(&self) -> Runner {
|
pub fn get_reset_runner(&self) -> Runner {
|
||||||
|
@ -61,14 +58,13 @@ impl Git {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_checkout_ref_runner(&self) -> Option<Runner> {
|
pub fn get_checkout_ref_runner(&self) -> Option<Runner> {
|
||||||
match self.get_ref() {
|
self.get_ref().map(|r| {
|
||||||
Some(r) => Some(Runner::new(
|
Runner::new(
|
||||||
None,
|
None,
|
||||||
"git".into(),
|
"git".into(),
|
||||||
vec!["-C".into(), self.dir.clone(), "checkout".into(), r],
|
vec!["-C".into(), self.dir.clone(), "checkout".into(), r],
|
||||||
)),
|
)
|
||||||
None => None,
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_clone_or_not_runner(&self) -> Option<Runner> {
|
pub fn get_clone_or_not_runner(&self) -> Option<Runner> {
|
||||||
|
|
|
@ -15,18 +15,14 @@ pub fn get_build_basalt_runners(profile: &Profile, clean_build: bool) -> Vec<Run
|
||||||
},
|
},
|
||||||
dir: profile.features.basalt.path.as_ref().unwrap().clone(),
|
dir: profile.features.basalt.path.as_ref().unwrap().clone(),
|
||||||
};
|
};
|
||||||
match git.clone_or_pull(profile) {
|
if let Some(r) = git.clone_or_pull(profile) {
|
||||||
Some(r) => runners.push(r),
|
runners.push(r);
|
||||||
None => {}
|
|
||||||
};
|
};
|
||||||
match git.get_checkout_ref_runner() {
|
if let Some(r) = git.get_checkout_ref_runner() {
|
||||||
Some(r) => {
|
runners.push(r);
|
||||||
runners.push(r);
|
if profile.pull_on_build {
|
||||||
if profile.pull_on_build {
|
runners.push(git.get_pull_runner());
|
||||||
runners.push(git.get_pull_runner());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let build_dir = format!("{}/build", profile.features.basalt.path.as_ref().unwrap());
|
let build_dir = format!("{}/build", profile.features.basalt.path.as_ref().unwrap());
|
||||||
|
|
|
@ -15,18 +15,14 @@ pub fn get_build_libsurvive_runners(profile: &Profile, clean_build: bool) -> Vec
|
||||||
},
|
},
|
||||||
dir: profile.features.libsurvive.path.as_ref().unwrap().clone(),
|
dir: profile.features.libsurvive.path.as_ref().unwrap().clone(),
|
||||||
};
|
};
|
||||||
match git.clone_or_pull(profile) {
|
if let Some(r) = git.clone_or_pull(profile) {
|
||||||
Some(r) => runners.push(r),
|
runners.push(r);
|
||||||
None => {}
|
|
||||||
};
|
};
|
||||||
match git.get_checkout_ref_runner() {
|
if let Some(r) = git.get_checkout_ref_runner() {
|
||||||
Some(r) => {
|
runners.push(r);
|
||||||
runners.push(r);
|
if profile.pull_on_build {
|
||||||
if profile.pull_on_build {
|
runners.push(git.get_pull_runner());
|
||||||
runners.push(git.get_pull_runner());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let build_dir = format!(
|
let build_dir = format!(
|
||||||
|
|
|
@ -2,13 +2,12 @@ use crate::{constants::pkg_data_dir, paths::get_cache_dir, profile::Profile, run
|
||||||
|
|
||||||
pub fn get_build_mercury_runner(profile: &Profile) -> Runner {
|
pub fn get_build_mercury_runner(profile: &Profile) -> Runner {
|
||||||
let args = vec![profile.prefix.clone(), get_cache_dir()];
|
let args = vec![profile.prefix.clone(), get_cache_dir()];
|
||||||
let runner = Runner::new(
|
Runner::new(
|
||||||
None,
|
None,
|
||||||
format!(
|
format!(
|
||||||
"{sysdata}/scripts/build_mercury.sh",
|
"{sysdata}/scripts/build_mercury.sh",
|
||||||
sysdata = pkg_data_dir()
|
sysdata = pkg_data_dir()
|
||||||
),
|
),
|
||||||
args,
|
args,
|
||||||
);
|
)
|
||||||
runner
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,18 +15,14 @@ pub fn get_build_monado_runners(profile: &Profile, clean_build: bool) -> Vec<Run
|
||||||
},
|
},
|
||||||
dir: profile.xrservice_path.clone(),
|
dir: profile.xrservice_path.clone(),
|
||||||
};
|
};
|
||||||
match git.clone_or_pull(profile) {
|
if let Some(r) = git.clone_or_pull(profile) {
|
||||||
Some(r) => runners.push(r),
|
runners.push(r);
|
||||||
None => {}
|
}
|
||||||
};
|
if let Some(r) = git.get_checkout_ref_runner() {
|
||||||
match git.get_checkout_ref_runner() {
|
runners.push(r);
|
||||||
Some(r) => {
|
if profile.pull_on_build {
|
||||||
runners.push(r);
|
runners.push(git.get_pull_runner());
|
||||||
if profile.pull_on_build {
|
|
||||||
runners.push(git.get_pull_runner());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let build_dir = format!("{}/build", profile.xrservice_path);
|
let build_dir = format!("{}/build", profile.xrservice_path);
|
||||||
|
|
|
@ -15,18 +15,14 @@ pub fn get_build_opencomposite_runners(profile: &Profile, clean_build: bool) ->
|
||||||
},
|
},
|
||||||
dir: profile.opencomposite_path.clone(),
|
dir: profile.opencomposite_path.clone(),
|
||||||
};
|
};
|
||||||
match git.clone_or_pull(profile) {
|
if let Some(r) = git.clone_or_pull(profile) {
|
||||||
Some(r) => runners.push(r),
|
runners.push(r);
|
||||||
None => {}
|
|
||||||
};
|
};
|
||||||
match git.get_checkout_ref_runner() {
|
if let Some(r) = git.get_checkout_ref_runner() {
|
||||||
Some(r) => {
|
runners.push(r);
|
||||||
runners.push(r);
|
if profile.pull_on_build {
|
||||||
if profile.pull_on_build {
|
runners.push(git.get_pull_runner());
|
||||||
runners.push(git.get_pull_runner());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let build_dir = format!("{}/build", profile.opencomposite_path);
|
let build_dir = format!("{}/build", profile.opencomposite_path);
|
||||||
|
|
|
@ -15,18 +15,14 @@ pub fn get_build_wivrn_runners(profile: &Profile, clean_build: bool) -> Vec<Runn
|
||||||
},
|
},
|
||||||
dir: profile.xrservice_path.clone(),
|
dir: profile.xrservice_path.clone(),
|
||||||
};
|
};
|
||||||
match git.clone_or_pull(profile) {
|
if let Some(r) = git.clone_or_pull(profile) {
|
||||||
Some(r) => runners.push(r),
|
runners.push(r);
|
||||||
None => {}
|
}
|
||||||
};
|
if let Some(r) = git.get_checkout_ref_runner() {
|
||||||
match git.get_checkout_ref_runner() {
|
runners.push(r);
|
||||||
Some(r) => {
|
if profile.pull_on_build {
|
||||||
runners.push(r);
|
runners.push(git.get_pull_runner());
|
||||||
if profile.pull_on_build {
|
|
||||||
runners.push(git.get_pull_runner());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let build_dir = format!("{}/build", profile.xrservice_path);
|
let build_dir = format!("{}/build", profile.xrservice_path);
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl Default for Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn get_selected_profile(&self, profiles: &Vec<Profile>) -> Profile {
|
pub fn get_selected_profile(&self, profiles: &[Profile]) -> Profile {
|
||||||
let def = || profiles.get(0).expect("No profiles found").clone();
|
let def = || profiles.get(0).expect("No profiles found").clone();
|
||||||
|
|
||||||
match profiles
|
match profiles
|
||||||
|
@ -84,12 +84,8 @@ impl Config {
|
||||||
Self::from_path(Self::config_file_path())
|
Self::from_path(Self::config_file_path())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_profiles(&mut self, profiles: &Vec<Profile>) {
|
pub fn set_profiles(&mut self, profiles: &[Profile]) {
|
||||||
self.user_profiles = profiles
|
self.user_profiles = profiles.iter().filter(|p| p.editable).cloned().collect();
|
||||||
.iter()
|
|
||||||
.filter(|p| p.editable)
|
|
||||||
.map(Profile::clone)
|
|
||||||
.collect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub fn check_dependency(dep: Dependency) -> bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_dependencies(deps: Vec<Dependency>) -> Vec<DependencyCheckResult> {
|
pub fn check_dependencies(deps: Vec<Dependency>) -> Vec<DependencyCheckResult> {
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn download_file(url: String, path: String) -> JoinHandle<Result<(), reqwest
|
||||||
.expect("Could not get HTTP response bytes")
|
.expect("Could not get HTTP response bytes")
|
||||||
.chunks(CHUNK_SIZE)
|
.chunks(CHUNK_SIZE)
|
||||||
{
|
{
|
||||||
writer.write(chunk).expect("Failed to write chunk");
|
writer.write_all(chunk).expect("Failed to write chunk");
|
||||||
}
|
}
|
||||||
writer.flush().expect("Failed to flush download writer");
|
writer.flush().expect("Failed to flush download writer");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -33,10 +33,7 @@ fn get_active_runtime_json_path() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_steam(active_runtime: &ActiveRuntime) -> bool {
|
pub fn is_steam(active_runtime: &ActiveRuntime) -> bool {
|
||||||
match active_runtime.runtime.valve_runtime_is_steamvr {
|
matches!(active_runtime.runtime.valve_runtime_is_steamvr, Some(true))
|
||||||
Some(true) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_backup_steam_active_runtime_path() -> String {
|
fn get_backup_steam_active_runtime_path() -> String {
|
||||||
|
@ -51,9 +48,8 @@ fn get_backed_up_steam_active_runtime() -> Option<ActiveRuntime> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn backup_steam_active_runtime() {
|
fn backup_steam_active_runtime() {
|
||||||
let ar = get_current_active_runtime();
|
if let Some(ar) = get_current_active_runtime() {
|
||||||
if ar.is_some() {
|
if is_steam(&ar) {
|
||||||
if is_steam(&ar.unwrap()) {
|
|
||||||
copy_file(
|
copy_file(
|
||||||
&get_active_runtime_json_path(),
|
&get_active_runtime_json_path(),
|
||||||
&get_backup_steam_active_runtime_path(),
|
&get_backup_steam_active_runtime_path(),
|
||||||
|
@ -85,9 +81,8 @@ pub fn dump_current_active_runtime(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_steam_active_runtime() -> ActiveRuntime {
|
fn build_steam_active_runtime() -> ActiveRuntime {
|
||||||
let backup = get_backed_up_steam_active_runtime();
|
if let Some(backup) = get_backed_up_steam_active_runtime() {
|
||||||
if backup.is_some() {
|
return backup;
|
||||||
return backup.unwrap();
|
|
||||||
}
|
}
|
||||||
ActiveRuntime {
|
ActiveRuntime {
|
||||||
file_format_version: "1.0.0".into(),
|
file_format_version: "1.0.0".into(),
|
||||||
|
|
|
@ -28,14 +28,10 @@ fn get_openvrpaths_vrpath_path() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_steam(ovr_paths: &OpenVrPaths) -> bool {
|
pub fn is_steam(ovr_paths: &OpenVrPaths) -> bool {
|
||||||
ovr_paths
|
ovr_paths.runtime.iter().any(|rt| {
|
||||||
.runtime
|
rt.to_lowercase()
|
||||||
.iter()
|
.ends_with("/steam/steamapps/common/steamvr")
|
||||||
.find(|rt| {
|
})
|
||||||
rt.to_lowercase()
|
|
||||||
.ends_with("/steam/steamapps/common/steamvr")
|
|
||||||
})
|
|
||||||
.is_some()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_backup_steam_openvrpaths_path() -> String {
|
fn get_backup_steam_openvrpaths_path() -> String {
|
||||||
|
@ -50,9 +46,8 @@ fn get_backed_up_steam_openvrpaths() -> Option<OpenVrPaths> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn backup_steam_openvrpaths() {
|
fn backup_steam_openvrpaths() {
|
||||||
let openvrpaths = get_current_openvrpaths();
|
if let Some(openvrpaths) = get_current_openvrpaths() {
|
||||||
if openvrpaths.is_some() {
|
if is_steam(&openvrpaths) {
|
||||||
if is_steam(&openvrpaths.unwrap()) {
|
|
||||||
copy_file(
|
copy_file(
|
||||||
&get_openvrpaths_vrpath_path(),
|
&get_openvrpaths_vrpath_path(),
|
||||||
&get_backup_steam_openvrpaths_path(),
|
&get_backup_steam_openvrpaths_path(),
|
||||||
|
@ -82,9 +77,8 @@ pub fn dump_current_openvrpaths(ovr_paths: &OpenVrPaths) -> Result<(), serde_jso
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_steam_openvrpaths() -> OpenVrPaths {
|
fn build_steam_openvrpaths() -> OpenVrPaths {
|
||||||
let backup = get_backed_up_steam_openvrpaths();
|
if let Some(backup) = get_backed_up_steam_openvrpaths() {
|
||||||
if backup.is_some() {
|
return backup;
|
||||||
return backup.unwrap();
|
|
||||||
}
|
}
|
||||||
let datadir = get_xdg_data_dir();
|
let datadir = get_xdg_data_dir();
|
||||||
OpenVrPaths {
|
OpenVrPaths {
|
||||||
|
|
|
@ -11,13 +11,10 @@ use std::{
|
||||||
|
|
||||||
pub fn get_writer(path_s: &String) -> BufWriter<std::fs::File> {
|
pub fn get_writer(path_s: &String) -> BufWriter<std::fs::File> {
|
||||||
let path = Path::new(path_s);
|
let path = Path::new(path_s);
|
||||||
match path.parent() {
|
if let Some(parent) = path.parent() {
|
||||||
Some(parent) => {
|
if !parent.is_dir() {
|
||||||
if !parent.is_dir() {
|
create_dir_all(parent).expect("Could not create dir")
|
||||||
create_dir_all(parent).expect("Could not create dir")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
};
|
};
|
||||||
let file = OpenOptions::new()
|
let file = OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
|
@ -36,14 +33,14 @@ pub fn get_reader(path_s: &String) -> Option<BufReader<File>> {
|
||||||
match File::open(path) {
|
match File::open(path) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Error opening {}: {}", path_s, e);
|
println!("Error opening {}: {}", path_s, e);
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
Ok(fd) => Some(BufReader::new(fd)),
|
Ok(fd) => Some(BufReader::new(fd)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deserialize_file<T: serde::de::DeserializeOwned>(path_s: &String) -> Option<T> {
|
pub fn deserialize_file<T: serde::de::DeserializeOwned>(path_s: &String) -> Option<T> {
|
||||||
match get_reader(&path_s) {
|
match get_reader(path_s) {
|
||||||
None => None,
|
None => None,
|
||||||
Some(reader) => match serde_json::from_reader(reader) {
|
Some(reader) => match serde_json::from_reader(reader) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -79,26 +76,23 @@ pub fn setcap_cap_sys_nice_eip(file: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rm_rf(path_s: &String) {
|
pub fn rm_rf(path_s: &String) {
|
||||||
match remove_dir_all(path_s) {
|
if remove_dir_all(path_s).is_err() {
|
||||||
Err(_) => println!("Failed to remove path {}", path_s),
|
println!("Failed to remove path {}", path_s);
|
||||||
Ok(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_file(source_s: &String, dest_s: &String) {
|
pub fn copy_file(source_s: &String, dest_s: &String) {
|
||||||
let source = Path::new(source_s);
|
let source = Path::new(source_s);
|
||||||
let dest = Path::new(dest_s);
|
let dest = Path::new(dest_s);
|
||||||
let parent = dest.parent();
|
if let Some(parent) = dest.parent() {
|
||||||
if parent.is_some() {
|
if !parent.is_dir() {
|
||||||
if !parent.unwrap().is_dir() {
|
create_dir_all(parent)
|
||||||
create_dir_all(parent.unwrap()).expect(
|
.unwrap_or_else(|_| panic!("Failed to create dir {}", parent.to_str().unwrap()));
|
||||||
format!("Failed to create dir {}", parent.unwrap().to_str().unwrap()).as_str(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_file_readonly(dest_s, false)
|
set_file_readonly(dest_s, false)
|
||||||
.expect(format!("Failed to set file {} as rw", dest_s).as_str());
|
.unwrap_or_else(|_| panic!("Failed to set file {} as rw", dest_s));
|
||||||
copy(source, dest).expect(format!("Failed to copy {} to {}", source_s, dest_s).as_str());
|
copy(source, dest).unwrap_or_else(|_| panic!("Failed to copy {} to {}", source_s, dest_s));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mount_has_nosuid(path_s: &str) -> Result<bool, Errno> {
|
pub fn mount_has_nosuid(path_s: &str) -> Result<bool, Errno> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use serde::{de::Visitor, Deserialize, Serialize};
|
use serde::{de::Visitor, Deserialize, Serialize};
|
||||||
use std::{fmt::Display, slice::Iter};
|
use std::{fmt::Display, slice::Iter, str::FromStr};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize)]
|
||||||
pub enum LogLevel {
|
pub enum LogLevel {
|
||||||
|
@ -24,14 +24,21 @@ impl<'de> Visitor<'de> for LogLevelStringVisitor {
|
||||||
where
|
where
|
||||||
E: serde::de::Error,
|
E: serde::de::Error,
|
||||||
{
|
{
|
||||||
Ok(LogLevel::from_string(v.to_string()))
|
Ok(LogLevel::from_str(v).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
|
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: serde::de::Error,
|
E: serde::de::Error,
|
||||||
{
|
{
|
||||||
Ok(LogLevel::from_string(v))
|
Ok(LogLevel::from_str(&v).unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||||
|
where
|
||||||
|
E: serde::de::Error,
|
||||||
|
{
|
||||||
|
Ok(LogLevel::from_str(v).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +51,9 @@ impl<'de> Deserialize<'de> for LogLevel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LogLevel {
|
impl FromStr for LogLevel {
|
||||||
pub fn from_string(s: String) -> Self {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s.to_lowercase().as_str() {
|
Ok(match s.to_lowercase().as_str() {
|
||||||
"trace" => Self::Trace,
|
"trace" => Self::Trace,
|
||||||
"debug" => Self::Debug,
|
"debug" => Self::Debug,
|
||||||
"info" => Self::Info,
|
"info" => Self::Info,
|
||||||
|
@ -55,9 +62,13 @@ impl LogLevel {
|
||||||
"error" => Self::Error,
|
"error" => Self::Error,
|
||||||
"err" => Self::Error,
|
"err" => Self::Error,
|
||||||
_ => Self::Debug,
|
_ => Self::Debug,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Err = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LogLevel {
|
||||||
pub fn iter() -> Iter<'static, LogLevel> {
|
pub fn iter() -> Iter<'static, LogLevel> {
|
||||||
[
|
[
|
||||||
Self::Trace,
|
Self::Trace,
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub struct MonadoLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonadoLog {
|
impl MonadoLog {
|
||||||
pub fn from_str(s: &str) -> Option<Self> {
|
pub fn new_from_str(s: &str) -> Option<Self> {
|
||||||
serde_json::from_str::<Self>(s).ok()
|
serde_json::from_str::<Self>(s).ok()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,16 +39,16 @@ pub mod xr_devices;
|
||||||
fn restore_steam_xr_files() {
|
fn restore_steam_xr_files() {
|
||||||
let active_runtime = get_current_active_runtime();
|
let active_runtime = get_current_active_runtime();
|
||||||
let openvrpaths = get_current_openvrpaths();
|
let openvrpaths = get_current_openvrpaths();
|
||||||
if active_runtime.is_some() {
|
if let Some(ar) = active_runtime {
|
||||||
if !file_builders::active_runtime_json::is_steam(&active_runtime.unwrap()) {
|
if !file_builders::active_runtime_json::is_steam(&ar) {
|
||||||
match set_current_active_runtime_to_steam() {
|
match set_current_active_runtime_to_steam() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => println!("Warning: failed to restore active runtime to steam!"),
|
Err(_) => println!("Warning: failed to restore active runtime to steam!"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if openvrpaths.is_some() {
|
if let Some(ovrp) = openvrpaths {
|
||||||
if !file_builders::openvrpaths_vrpath::is_steam(&openvrpaths.unwrap()) {
|
if !file_builders::openvrpaths_vrpath::is_steam(&ovrp) {
|
||||||
match set_current_openvrpaths_to_steam() {
|
match set_current_openvrpaths_to_steam() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => println!("Warning: failed to restore openvrpaths to steam!"),
|
Err(_) => println!("Warning: failed to restore openvrpaths to steam!"),
|
||||||
|
|
|
@ -285,7 +285,7 @@ impl Profile {
|
||||||
serde_json::from_reader(reader).expect("Faiuled to deserialize profile")
|
serde_json::from_reader(reader).expect("Faiuled to deserialize profile")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump_profile(&self, path_s: &String) -> () {
|
pub fn dump_profile(&self, path_s: &String) {
|
||||||
let writer = get_writer(path_s);
|
let writer = get_writer(path_s);
|
||||||
serde_json::to_writer_pretty(writer, self).expect("Could not write profile")
|
serde_json::to_writer_pretty(writer, self).expect("Could not write profile")
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,11 +114,8 @@ impl Runner {
|
||||||
.envs(self.environment.clone())
|
.envs(self.environment.clone())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn();
|
.spawn()?;
|
||||||
if cmd.is_err() {
|
self.process = Some(cmd);
|
||||||
return Err(cmd.unwrap_err());
|
|
||||||
}
|
|
||||||
self.process = Some(cmd.unwrap());
|
|
||||||
let stdout = self.process.as_mut().unwrap().stdout.take().unwrap();
|
let stdout = self.process.as_mut().unwrap().stdout.take().unwrap();
|
||||||
let stderr = self.process.as_mut().unwrap().stderr.take().unwrap();
|
let stderr = self.process.as_mut().unwrap().stderr.take().unwrap();
|
||||||
let stdout_sender = self.sender.clone();
|
let stdout_sender = self.sender.clone();
|
||||||
|
@ -178,11 +175,8 @@ impl Runner {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn receive_output(&mut self) {
|
fn receive_output(&mut self) {
|
||||||
loop {
|
while let Ok(data) = self.receiver.try_recv() {
|
||||||
match self.receiver.try_recv() {
|
self.output.push(data);
|
||||||
Ok(data) => self.output.push(data),
|
|
||||||
Err(_) => break,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +194,7 @@ impl Runner {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_log(path_s: String, log: &Vec<String>) -> Result<(), std::io::Error> {
|
fn save_log(path_s: String, log: &[String]) -> Result<(), std::io::Error> {
|
||||||
let mut writer = get_writer(&path_s);
|
let mut writer = get_writer(&path_s);
|
||||||
let log_s = log.concat();
|
let log_s = log.concat();
|
||||||
writer.write_all(log_s.as_ref())
|
writer.write_all(log_s.as_ref())
|
||||||
|
|
|
@ -34,13 +34,8 @@ impl RunnerPipeline {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.has_started = true;
|
self.has_started = true;
|
||||||
match self.get_current_runner() {
|
if let Some(runner) = self.get_current_runner() {
|
||||||
None => {
|
runner.borrow_mut().start();
|
||||||
return;
|
|
||||||
}
|
|
||||||
Some(runner) => {
|
|
||||||
runner.borrow_mut().start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ pub fn alert(title: &str, msg: Option<&str>, parent: Option<>k::Window>) {
|
||||||
.modal(true)
|
.modal(true)
|
||||||
.heading(title)
|
.heading(title)
|
||||||
.build();
|
.build();
|
||||||
if msg.is_some() {
|
if let Some(m) = msg {
|
||||||
d.set_body(msg.unwrap());
|
d.set_body(m);
|
||||||
}
|
}
|
||||||
if parent.is_some() {
|
if parent.is_some() {
|
||||||
d.set_transient_for(parent);
|
d.set_transient_for(parent);
|
||||||
|
|
|
@ -193,10 +193,10 @@ impl App {
|
||||||
|
|
||||||
pub fn shutdown_xrservice(&mut self) {
|
pub fn shutdown_xrservice(&mut self) {
|
||||||
self.set_inhibit_session(false);
|
self.set_inhibit_session(false);
|
||||||
if self.xrservice_runner.is_some() {
|
if self.xrservice_runner.is_some()
|
||||||
if self.xrservice_runner.as_mut().unwrap().status() == RunnerStatus::Running {
|
&& self.xrservice_runner.as_mut().unwrap().status() == RunnerStatus::Running
|
||||||
self.xrservice_runner.as_mut().unwrap().terminate();
|
{
|
||||||
}
|
self.xrservice_runner.as_mut().unwrap().terminate();
|
||||||
}
|
}
|
||||||
self.restore_openxr_openvr_files();
|
self.restore_openxr_openvr_files();
|
||||||
self.main_view
|
self.main_view
|
||||||
|
@ -258,10 +258,10 @@ impl SimpleComponent for App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shutdown(&mut self, _widgets: &mut Self::Widgets, _output: relm4::Sender<Self::Output>) {
|
fn shutdown(&mut self, _widgets: &mut Self::Widgets, _output: relm4::Sender<Self::Output>) {
|
||||||
if self.xrservice_runner.is_some() {
|
if self.xrservice_runner.is_some()
|
||||||
if self.xrservice_runner.as_mut().unwrap().status() == RunnerStatus::Running {
|
&& self.xrservice_runner.as_mut().unwrap().status() == RunnerStatus::Running
|
||||||
self.xrservice_runner.as_mut().unwrap().terminate();
|
{
|
||||||
}
|
self.xrservice_runner.as_mut().unwrap().terminate();
|
||||||
}
|
}
|
||||||
self.restore_openxr_openvr_files();
|
self.restore_openxr_openvr_files();
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ impl SimpleComponent for App {
|
||||||
}
|
}
|
||||||
Msg::ProcessDevicesLog(rows) => {
|
Msg::ProcessDevicesLog(rows) => {
|
||||||
for row in rows {
|
for row in rows {
|
||||||
match MonadoLog::from_str(row.as_str()) {
|
match MonadoLog::new_from_str(row.as_str()) {
|
||||||
None => {}
|
None => {}
|
||||||
Some(parsed) => {
|
Some(parsed) => {
|
||||||
if parsed.func == "p_create_system" {
|
if parsed.func == "p_create_system" {
|
||||||
|
@ -386,12 +386,11 @@ impl SimpleComponent for App {
|
||||||
Some(runner) => match runner.status() {
|
Some(runner) => match runner.status() {
|
||||||
RunnerStatus::Stopped(_) => {}
|
RunnerStatus::Stopped(_) => {}
|
||||||
RunnerStatus::Running => {
|
RunnerStatus::Running => {
|
||||||
if self.xrservice_runner.is_some() {
|
if self.xrservice_runner.is_some()
|
||||||
if self.xrservice_runner.as_mut().unwrap().status()
|
&& self.xrservice_runner.as_mut().unwrap().status()
|
||||||
== RunnerStatus::Running
|
== RunnerStatus::Running
|
||||||
{
|
{
|
||||||
self.xrservice_runner.as_mut().unwrap().terminate();
|
self.xrservice_runner.as_mut().unwrap().terminate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -464,13 +463,7 @@ impl SimpleComponent for App {
|
||||||
Msg::DeleteProfile => {
|
Msg::DeleteProfile => {
|
||||||
let todel = self.get_selected_profile();
|
let todel = self.get_selected_profile();
|
||||||
if todel.editable {
|
if todel.editable {
|
||||||
self.config.user_profiles = self
|
self.config.user_profiles.retain(|p| p.uuid != todel.uuid);
|
||||||
.config
|
|
||||||
.user_profiles
|
|
||||||
.iter()
|
|
||||||
.filter(|p| p.uuid != todel.uuid)
|
|
||||||
.map(|p| p.clone())
|
|
||||||
.collect();
|
|
||||||
self.config.save();
|
self.config.save();
|
||||||
self.profiles = Self::profiles_list(&self.config);
|
self.profiles = Self::profiles_list(&self.config);
|
||||||
self.main_view
|
self.main_view
|
||||||
|
@ -550,7 +543,7 @@ impl SimpleComponent for App {
|
||||||
sender: ComponentSender<Self>,
|
sender: ComponentSender<Self>,
|
||||||
) -> ComponentParts<Self> {
|
) -> ComponentParts<Self> {
|
||||||
let config = Config::get_config();
|
let config = Config::get_config();
|
||||||
let win_size = config.win_size.clone();
|
let win_size = config.win_size;
|
||||||
let profiles = Self::profiles_list(&config);
|
let profiles = Self::profiles_list(&config);
|
||||||
let setcap_confirm_dialog = adw::MessageDialog::builder()
|
let setcap_confirm_dialog = adw::MessageDialog::builder()
|
||||||
.modal(true)
|
.modal(true)
|
||||||
|
@ -682,7 +675,7 @@ impl SimpleComponent for App {
|
||||||
withclones![sender];
|
withclones![sender];
|
||||||
glib::timeout_add_local(Duration::from_millis(1000), move || {
|
glib::timeout_add_local(Duration::from_millis(1000), move || {
|
||||||
sender.input(Msg::ClockTicking);
|
sender.input(Msg::ClockTicking);
|
||||||
return glib::Continue(true);
|
glib::Continue(true)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl SimpleComponent for BuildWindow {
|
||||||
self.set_title(t);
|
self.set_title(t);
|
||||||
}
|
}
|
||||||
Self::Input::UpdateContent(c) => {
|
Self::Input::UpdateContent(c) => {
|
||||||
if c.len() > 0 {
|
if !c.is_empty() {
|
||||||
let is_at_bottom = {
|
let is_at_bottom = {
|
||||||
let adj = self.scrolledwin.as_ref().unwrap().vadjustment();
|
let adj = self.scrolledwin.as_ref().unwrap().vadjustment();
|
||||||
(adj.upper() - adj.page_size() - adj.value()) <= 15.0
|
(adj.upper() - adj.page_size() - adj.value()) <= 15.0
|
||||||
|
|
|
@ -200,12 +200,12 @@ impl SimpleComponent for DebugView {
|
||||||
};
|
};
|
||||||
self.log.extend(n_log.clone());
|
self.log.extend(n_log.clone());
|
||||||
for row in n_log {
|
for row in n_log {
|
||||||
let txt = match MonadoLog::from_str(row.as_str()) {
|
let txt = match MonadoLog::new_from_str(row.as_str()) {
|
||||||
Some(o) => match o.level >= self.log_level {
|
Some(o) => match o.level >= self.log_level {
|
||||||
false => None,
|
false => None,
|
||||||
true => Some(format!(
|
true => Some(format!(
|
||||||
"{lvl}\t[{file}:{func}]\n\t{msg}\n",
|
"{lvl}\t[{file}:{func}]\n\t{msg}\n",
|
||||||
lvl = o.level.to_string(),
|
lvl = o.level,
|
||||||
file = o.file,
|
file = o.file,
|
||||||
func = o.func,
|
func = o.func,
|
||||||
msg = o.message
|
msg = o.message
|
||||||
|
@ -213,9 +213,9 @@ impl SimpleComponent for DebugView {
|
||||||
},
|
},
|
||||||
None => Some(row),
|
None => Some(row),
|
||||||
};
|
};
|
||||||
if txt.is_some() {
|
if let Some(t) = txt {
|
||||||
self.textbuf
|
self.textbuf
|
||||||
.insert(&mut self.textbuf.end_iter(), txt.unwrap().as_str());
|
.insert(&mut self.textbuf.end_iter(), t.as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let textbuf = self.textbuf.clone();
|
let textbuf = self.textbuf.clone();
|
||||||
|
@ -284,11 +284,10 @@ impl SimpleComponent for DebugView {
|
||||||
.log_level_dropdown
|
.log_level_dropdown
|
||||||
.connect_selected_notify(move |dd| {
|
.connect_selected_notify(move |dd| {
|
||||||
sender.input(Self::Input::LogLevelChanged(
|
sender.input(Self::Input::LogLevelChanged(
|
||||||
LogLevel::iter()
|
*LogLevel::iter()
|
||||||
.as_slice()
|
.as_slice()
|
||||||
.get(dd.selected() as usize)
|
.get(dd.selected() as usize)
|
||||||
.unwrap()
|
.unwrap(),
|
||||||
.clone(),
|
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,7 @@ impl SimpleComponent for InstallWivrnBox {
|
||||||
set_margin_top: 12,
|
set_margin_top: 12,
|
||||||
set_margin_bottom: 12,
|
set_margin_bottom: 12,
|
||||||
#[track = "model.changed(Self::selected_profile())"]
|
#[track = "model.changed(Self::selected_profile())"]
|
||||||
set_visible: match model.selected_profile.xrservice_type {
|
set_visible: model.selected_profile.xrservice_type == XRServiceType::Wivrn,
|
||||||
XRServiceType::Wivrn => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
gtk::Separator {
|
gtk::Separator {
|
||||||
set_orientation: gtk::Orientation::Horizontal,
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
set_hexpand: true,
|
set_hexpand: true,
|
||||||
|
@ -111,10 +108,7 @@ impl SimpleComponent for InstallWivrnBox {
|
||||||
set_margin_end: 12,
|
set_margin_end: 12,
|
||||||
set_halign: gtk::Align::Start,
|
set_halign: gtk::Align::Start,
|
||||||
#[track = "model.changed(Self::install_wivrn_status())"]
|
#[track = "model.changed(Self::install_wivrn_status())"]
|
||||||
set_sensitive: match model.install_wivrn_status {
|
set_sensitive: model.install_wivrn_status != InstallWivrnStatus::InProgress,
|
||||||
InstallWivrnStatus::InProgress => false,
|
|
||||||
_ => true,
|
|
||||||
},
|
|
||||||
set_menu_model: Some(&install_wivrn_menu),
|
set_menu_model: Some(&install_wivrn_menu),
|
||||||
},
|
},
|
||||||
gtk::Label {
|
gtk::Label {
|
||||||
|
@ -123,10 +117,7 @@ impl SimpleComponent for InstallWivrnBox {
|
||||||
set_margin_end: 12,
|
set_margin_end: 12,
|
||||||
set_xalign: 0.0,
|
set_xalign: 0.0,
|
||||||
#[track = "model.changed(Self::install_wivrn_status())"]
|
#[track = "model.changed(Self::install_wivrn_status())"]
|
||||||
set_visible: match &model.install_wivrn_status {
|
set_visible: matches!(&model.install_wivrn_status, InstallWivrnStatus::Done(Some(_))),
|
||||||
InstallWivrnStatus::Done(Some(_)) => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
#[track = "model.changed(Self::install_wivrn_status())"]
|
#[track = "model.changed(Self::install_wivrn_status())"]
|
||||||
set_label: match &model.install_wivrn_status {
|
set_label: match &model.install_wivrn_status {
|
||||||
InstallWivrnStatus::Done(Some(err)) => err.as_str(),
|
InstallWivrnStatus::Done(Some(err)) => err.as_str(),
|
||||||
|
@ -139,10 +130,7 @@ impl SimpleComponent for InstallWivrnBox {
|
||||||
set_margin_end: 12,
|
set_margin_end: 12,
|
||||||
set_xalign: 0.0,
|
set_xalign: 0.0,
|
||||||
#[track = "model.changed(Self::install_wivrn_status())"]
|
#[track = "model.changed(Self::install_wivrn_status())"]
|
||||||
set_visible: match &model.install_wivrn_status {
|
set_visible: model.install_wivrn_status == InstallWivrnStatus::Success,
|
||||||
InstallWivrnStatus::Success => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
set_label: "WiVRn Installed Successfully",
|
set_label: "WiVRn Installed Successfully",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,9 +366,10 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
let path_s = self.steam_lighthouse_path.clone();
|
let path_s = self.steam_lighthouse_path.clone();
|
||||||
let lh_path = Path::new(&path_s);
|
let lh_path = Path::new(&path_s);
|
||||||
if lh_path.is_file() {
|
if lh_path.is_file() {
|
||||||
let survive_cli_path = self.profile.as_ref().unwrap().get_survive_cli_path();
|
if let Some(survive_cli_path) =
|
||||||
if survive_cli_path.is_some() {
|
self.profile.as_ref().unwrap().get_survive_cli_path()
|
||||||
let mut runner = self.create_calibration_runner(survive_cli_path.unwrap());
|
{
|
||||||
|
let mut runner = self.create_calibration_runner(survive_cli_path);
|
||||||
self.calibration_running.set(true);
|
self.calibration_running.set(true);
|
||||||
self.first_run_done = false;
|
self.first_run_done = false;
|
||||||
self.calibration_seconds_elapsed = 0.0;
|
self.calibration_seconds_elapsed = 0.0;
|
||||||
|
@ -378,7 +379,7 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
let cont = self.calibration_running.clone();
|
let cont = self.calibration_running.clone();
|
||||||
glib::timeout_add_local(Duration::from_millis(1000), move || {
|
glib::timeout_add_local(Duration::from_millis(1000), move || {
|
||||||
timer_sender.input(LibsurviveSetupMsg::TickCalibrationRunner);
|
timer_sender.input(LibsurviveSetupMsg::TickCalibrationRunner);
|
||||||
return glib::Continue(cont.get());
|
glib::Continue(cont.get())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.calibration_runner = Some(runner);
|
self.calibration_runner = Some(runner);
|
||||||
|
@ -387,10 +388,7 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.scroll_to(self.loading_page.as_ref().unwrap(), true);
|
.scroll_to(self.loading_page.as_ref().unwrap(), true);
|
||||||
} else {
|
} else {
|
||||||
let parent = match self.win.as_ref() {
|
let parent = self.win.as_ref().map(|w| w.clone().upcast::<gtk::Window>());
|
||||||
None => None,
|
|
||||||
Some(w) => Some(w.clone().upcast::<gtk::Window>()),
|
|
||||||
};
|
|
||||||
alert(
|
alert(
|
||||||
"Survive CLI not found",
|
"Survive CLI not found",
|
||||||
Some(concat!(
|
Some(concat!(
|
||||||
|
@ -418,16 +416,14 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
chooser.open(
|
chooser.open(
|
||||||
Some(&self.win.as_ref().unwrap().clone()),
|
Some(&self.win.as_ref().unwrap().clone()),
|
||||||
gtk::gio::Cancellable::NONE,
|
gtk::gio::Cancellable::NONE,
|
||||||
move |res| match res {
|
move |res| {
|
||||||
Ok(file) => {
|
if let Ok(file) = res {
|
||||||
let path = file.path();
|
if let Some(path) = file.path() {
|
||||||
if path.is_some() {
|
|
||||||
fd_sender.input(LibsurviveSetupMsg::SetSteamLighthousePath(Some(
|
fd_sender.input(LibsurviveSetupMsg::SetSteamLighthousePath(Some(
|
||||||
path.unwrap().to_str().unwrap().to_string(),
|
path.to_str().unwrap().to_string(),
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -437,42 +433,37 @@ impl SimpleComponent for LibsurviveSetupWindow {
|
||||||
(self.calibration_seconds_elapsed / (CALIBRATION_RUN_TIME_SECONDS * 2.0))
|
(self.calibration_seconds_elapsed / (CALIBRATION_RUN_TIME_SECONDS * 2.0))
|
||||||
.min(1.0),
|
.min(1.0),
|
||||||
);
|
);
|
||||||
if !self.first_run_done {
|
if !self.first_run_done
|
||||||
if self.calibration_seconds_elapsed >= CALIBRATION_RUN_TIME_SECONDS {
|
&& self.calibration_seconds_elapsed >= CALIBRATION_RUN_TIME_SECONDS
|
||||||
if self.calibration_runner.is_some() {
|
{
|
||||||
self.first_run_done = true;
|
if self.calibration_runner.is_some() {
|
||||||
let runner = self.calibration_runner.as_mut().unwrap();
|
self.first_run_done = true;
|
||||||
runner.terminate();
|
|
||||||
let mut n_runner = self.create_calibration_runner(
|
|
||||||
self.profile
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.get_survive_cli_path()
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
n_runner.start();
|
|
||||||
self.calibration_runner = Some(n_runner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if self.calibration_seconds_elapsed >= (CALIBRATION_RUN_TIME_SECONDS * 2.0) {
|
|
||||||
let runner = self.calibration_runner.as_mut().unwrap();
|
let runner = self.calibration_runner.as_mut().unwrap();
|
||||||
runner.terminate();
|
runner.terminate();
|
||||||
self.calibration_running.set(false);
|
let mut n_runner = self.create_calibration_runner(
|
||||||
self.carousel
|
self.profile
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.scroll_to(self.calibration_done_page.as_ref().unwrap(), true);
|
.get_survive_cli_path()
|
||||||
|
.unwrap(),
|
||||||
|
);
|
||||||
|
n_runner.start();
|
||||||
|
self.calibration_runner = Some(n_runner);
|
||||||
}
|
}
|
||||||
|
} else if self.calibration_seconds_elapsed >= (CALIBRATION_RUN_TIME_SECONDS * 2.0) {
|
||||||
|
let runner = self.calibration_runner.as_mut().unwrap();
|
||||||
|
runner.terminate();
|
||||||
|
self.calibration_running.set(false);
|
||||||
|
self.carousel
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.scroll_to(self.calibration_done_page.as_ref().unwrap(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Input::Cancel => {
|
Self::Input::Cancel => {
|
||||||
if self.calibration_running.get() {
|
if self.calibration_running.get() {
|
||||||
match self.calibration_runner.as_mut() {
|
if let Some(runner) = self.calibration_runner.as_mut() {
|
||||||
Some(runner) => {
|
runner.terminate();
|
||||||
runner.terminate();
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
self.calibration_running.set(false);
|
self.calibration_running.set(false);
|
||||||
self.carousel
|
self.carousel
|
||||||
|
|
|
@ -357,7 +357,7 @@ impl SimpleComponent for MainView {
|
||||||
},
|
},
|
||||||
connect_realize => move |dd| {
|
connect_realize => move |dd| {
|
||||||
limit_dropdown_width(
|
limit_dropdown_width(
|
||||||
&dd, match model.enable_debug_view {
|
dd, match model.enable_debug_view {
|
||||||
true => 18,
|
true => 18,
|
||||||
false => -1,
|
false => -1,
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,8 +18,8 @@ pub fn switch_row<F: Fn(>k::Switch, bool) -> glib::signal::Inhibit + 'static>(
|
||||||
.subtitle_lines(0)
|
.subtitle_lines(0)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if description.is_some() {
|
if let Some(d) = description {
|
||||||
row.set_subtitle(description.unwrap());
|
row.set_subtitle(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
let switch = gtk::Switch::builder()
|
let switch = gtk::Switch::builder()
|
||||||
|
@ -76,8 +76,8 @@ pub fn path_row<F: Fn(Option<String>) + 'static + Clone>(
|
||||||
.icon_name(GString::from("folder-open-symbolic"))
|
.icon_name(GString::from("folder-open-symbolic"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if description.is_some() {
|
if let Some(d) = description {
|
||||||
row.set_subtitle(description.unwrap());
|
row.set_subtitle(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
let path_label = >k::Label::builder()
|
let path_label = >k::Label::builder()
|
||||||
|
@ -111,21 +111,15 @@ pub fn path_row<F: Fn(Option<String>) + 'static + Clone>(
|
||||||
withclones![path_label];
|
withclones![path_label];
|
||||||
row.connect_activated(move |_| {
|
row.connect_activated(move |_| {
|
||||||
withclones![path_label, cb];
|
withclones![path_label, cb];
|
||||||
filedialog.select_folder(
|
filedialog.select_folder(root_win.as_ref(), gio::Cancellable::NONE, move |res| {
|
||||||
root_win.as_ref(),
|
if let Ok(file) = res {
|
||||||
gio::Cancellable::NONE,
|
if let Some(path) = file.path() {
|
||||||
move |res| match res {
|
let path_s = path.to_str().unwrap().to_string();
|
||||||
Ok(file) => {
|
path_label.set_text(path_s.as_str());
|
||||||
let path = file.path();
|
cb(Some(path_s))
|
||||||
if path.is_some() {
|
|
||||||
let path_s = path.unwrap().to_str().unwrap().to_string();
|
|
||||||
path_label.set_text(path_s.as_str());
|
|
||||||
cb(Some(path_s))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
}
|
||||||
},
|
})
|
||||||
)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,15 +145,12 @@ pub fn combo_row<F: Fn(&adw::ComboRow) + 'static>(
|
||||||
))
|
))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if description.is_some() {
|
if let Some(desc) = description {
|
||||||
row.set_subtitle(description.unwrap());
|
row.set_subtitle(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
let selected = values.iter().position(|v| *v == value.to_string());
|
let selected = values.iter().position(|v| v == value);
|
||||||
row.set_selected(match selected {
|
row.set_selected(selected.unwrap_or(0) as u32);
|
||||||
Some(i) => i,
|
|
||||||
None => 0,
|
|
||||||
} as u32);
|
|
||||||
|
|
||||||
row.connect_selected_item_notify(cb);
|
row.connect_selected_item_notify(cb);
|
||||||
|
|
||||||
|
|
|
@ -317,8 +317,8 @@ impl SimpleComponent for ProfileEditor {
|
||||||
.guard()
|
.guard()
|
||||||
.iter()
|
.iter()
|
||||||
.position(|evr| evr.name == name);
|
.position(|evr| evr.name == name);
|
||||||
if pos.is_some() {
|
if let Some(p) = pos {
|
||||||
self.env_rows.guard().remove(pos.unwrap());
|
self.env_rows.guard().remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Input::AddEnvVar(name) => {
|
Self::Input::AddEnvVar(name) => {
|
||||||
|
|
|
@ -13,12 +13,9 @@ pub fn limit_dropdown_width(dd: >k4::DropDown, chars: i32) {
|
||||||
if dd_child.is_none() {
|
if dd_child.is_none() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
match dd_child.clone().unwrap().downcast::<gtk4::Label>() {
|
if let Ok(label) = dd_child.clone().unwrap().downcast::<gtk4::Label>() {
|
||||||
Ok(label) => {
|
label.set_max_width_chars(chars);
|
||||||
label.set_max_width_chars(chars);
|
label.set_ellipsize(gtk4::pango::EllipsizeMode::End);
|
||||||
label.set_ellipsize(gtk4::pango::EllipsizeMode::End);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
let nc = dd_child.unwrap().first_child().clone();
|
let nc = dd_child.unwrap().first_child().clone();
|
||||||
dd_child = nc;
|
dd_child = nc;
|
||||||
|
|
|
@ -127,10 +127,7 @@ impl SimpleComponent for WivrnConfEditor {
|
||||||
let scalex = self.scalex_entry.as_ref().unwrap().text().parse::<f32>();
|
let scalex = self.scalex_entry.as_ref().unwrap().text().parse::<f32>();
|
||||||
let scaley = self.scaley_entry.as_ref().unwrap().text().parse::<f32>();
|
let scaley = self.scaley_entry.as_ref().unwrap().text().parse::<f32>();
|
||||||
if scalex.is_ok() && scaley.is_ok() {
|
if scalex.is_ok() && scaley.is_ok() {
|
||||||
self.conf.scale = Some([
|
self.conf.scale = Some([*scalex.as_ref().unwrap(), *scaley.as_ref().unwrap()]);
|
||||||
scalex.as_ref().unwrap().clone(),
|
|
||||||
scaley.as_ref().unwrap().clone(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
if scalex.is_ok() || scaley.is_ok() {
|
if scalex.is_ok() || scaley.is_ok() {
|
||||||
let scale = scalex.unwrap_or(scaley.unwrap());
|
let scale = scalex.unwrap_or(scaley.unwrap());
|
||||||
|
@ -141,14 +138,14 @@ impl SimpleComponent for WivrnConfEditor {
|
||||||
|
|
||||||
let mut enc = self.conf.encoders.remove(0);
|
let mut enc = self.conf.encoders.remove(0);
|
||||||
let bitrate = self.bitrate_entry.as_ref().unwrap().text().parse::<u32>();
|
let bitrate = self.bitrate_entry.as_ref().unwrap().text().parse::<u32>();
|
||||||
if bitrate.is_ok() {
|
if let Ok(br) = bitrate {
|
||||||
enc.bitrate = Some(bitrate.unwrap());
|
enc.bitrate = Some(br);
|
||||||
}
|
}
|
||||||
let encoders = Encoder::as_vec();
|
let encoders = Encoder::as_vec();
|
||||||
let encoder =
|
let encoder =
|
||||||
encoders.get(self.encoder_combo.as_ref().unwrap().selected() as usize);
|
encoders.get(self.encoder_combo.as_ref().unwrap().selected() as usize);
|
||||||
if encoder.is_some() {
|
if let Some(e) = encoder {
|
||||||
enc.encoder = encoder.unwrap().clone();
|
enc.encoder = e.clone();
|
||||||
}
|
}
|
||||||
self.conf.encoders.insert(0, enc);
|
self.conf.encoders.insert(0, enc);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub enum XRDevice {
|
||||||
HandTrackingRight,
|
HandTrackingRight,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct XRDevices {
|
pub struct XRDevices {
|
||||||
pub head: Option<String>,
|
pub head: Option<String>,
|
||||||
pub left: Option<String>,
|
pub left: Option<String>,
|
||||||
|
@ -20,23 +20,9 @@ pub struct XRDevices {
|
||||||
pub hand_tracking_right: Option<String>,
|
pub hand_tracking_right: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for XRDevices {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
head: None,
|
|
||||||
left: None,
|
|
||||||
right: None,
|
|
||||||
gamepad: None,
|
|
||||||
eyes: None,
|
|
||||||
hand_tracking_left: None,
|
|
||||||
hand_tracking_right: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl XRDevices {
|
impl XRDevices {
|
||||||
pub fn from_log_message(s: String) -> Option<Self> {
|
pub fn from_log_message(s: String) -> Option<Self> {
|
||||||
let rows = s.split("\n");
|
let rows = s.split('\n');
|
||||||
let mut in_section = false;
|
let mut in_section = false;
|
||||||
let mut devs = Self::default();
|
let mut devs = Self::default();
|
||||||
for row in rows {
|
for row in rows {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue