mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 06:38:52 +00:00
feat: separate profile setting for lighthouse driver
This commit is contained in:
parent
9b5750632e
commit
01791cb353
6 changed files with 109 additions and 16 deletions
|
@ -23,7 +23,7 @@ impl XRServiceType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter() -> Iter<'static, XRServiceType> {
|
pub fn iter() -> Iter<'static, Self> {
|
||||||
[Self::Monado, Self::Wivrn].iter()
|
[Self::Monado, Self::Wivrn].iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,14 @@ impl XRServiceType {
|
||||||
Self::Wivrn => 1,
|
Self::Wivrn => 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_number(i: u32) -> Self {
|
||||||
|
match i {
|
||||||
|
0 => Self::Monado,
|
||||||
|
1 => Self::Wivrn,
|
||||||
|
_ => panic!("XRServiceType index out of bounds"),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for XRServiceType {
|
impl Display for XRServiceType {
|
||||||
|
@ -115,6 +123,63 @@ impl Default for ProfileFeatures {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
pub enum LighthouseDriver {
|
||||||
|
Vive,
|
||||||
|
Survive,
|
||||||
|
SteamVR,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for LighthouseDriver {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Vive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LighthouseDriver {
|
||||||
|
pub fn from_string(s: String) -> Self {
|
||||||
|
match s.trim().to_lowercase().as_str() {
|
||||||
|
"vive" => Self::Vive,
|
||||||
|
"survive" => Self::Survive,
|
||||||
|
"libsurvive" => Self::Survive,
|
||||||
|
"steam" => Self::SteamVR,
|
||||||
|
"steamvr" => Self::SteamVR,
|
||||||
|
_ => Self::Vive,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn iter() -> Iter<'static, Self> {
|
||||||
|
[Self::Vive, Self::Survive, Self::SteamVR].iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_number(&self) -> u32 {
|
||||||
|
match self {
|
||||||
|
Self::Vive => 0,
|
||||||
|
Self::Survive => 1,
|
||||||
|
Self::SteamVR => 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_number(i: u32) -> Self {
|
||||||
|
match i {
|
||||||
|
0 => Self::Vive,
|
||||||
|
1 => Self::Survive,
|
||||||
|
2 => Self::SteamVR,
|
||||||
|
_ => panic!("LighthouseDriver index out of bounds"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for LighthouseDriver {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str(match self {
|
||||||
|
Self::Vive => "Vive",
|
||||||
|
Self::Survive => "Survive",
|
||||||
|
Self::SteamVR => "SteamVR",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct Profile {
|
pub struct Profile {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
|
@ -131,6 +196,9 @@ pub struct Profile {
|
||||||
pub can_be_built: bool,
|
pub can_be_built: bool,
|
||||||
pub editable: bool,
|
pub editable: bool,
|
||||||
pub pull_on_build: bool,
|
pub pull_on_build: bool,
|
||||||
|
#[serde(default = "LighthouseDriver::default")]
|
||||||
|
/** Only applicable for Monado */
|
||||||
|
pub lighthouse_driver: LighthouseDriver,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Profile {
|
impl Display for Profile {
|
||||||
|
@ -168,6 +236,7 @@ impl Default for Profile {
|
||||||
xrservice_repo: None,
|
xrservice_repo: None,
|
||||||
opencomposite_repo: None,
|
opencomposite_repo: None,
|
||||||
editable: true,
|
editable: true,
|
||||||
|
lighthouse_driver: LighthouseDriver::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::APP_NAME,
|
constants::APP_NAME,
|
||||||
paths::{data_opencomposite_path, SYSTEM_PREFIX},
|
paths::{data_opencomposite_path, SYSTEM_PREFIX},
|
||||||
profile::{Profile, ProfileFeatures, XRServiceType},
|
profile::{LighthouseDriver, Profile, ProfileFeatures, XRServiceType},
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ pub fn system_valve_index_profile() -> Profile {
|
||||||
prefix: SYSTEM_PREFIX.into(),
|
prefix: SYSTEM_PREFIX.into(),
|
||||||
can_be_built: false,
|
can_be_built: false,
|
||||||
editable: false,
|
editable: false,
|
||||||
|
lighthouse_driver: LighthouseDriver::Survive,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::APP_NAME,
|
constants::APP_NAME,
|
||||||
paths::{data_libsurvive_path, data_monado_path, data_opencomposite_path, get_data_dir},
|
paths::{data_libsurvive_path, data_monado_path, data_opencomposite_path, get_data_dir},
|
||||||
profile::{Profile, ProfileFeature, ProfileFeatureType, ProfileFeatures, XRServiceType},
|
profile::{
|
||||||
|
LighthouseDriver, Profile, ProfileFeature, ProfileFeatureType, ProfileFeatures,
|
||||||
|
XRServiceType,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
@ -37,6 +40,7 @@ pub fn valve_index_profile() -> Profile {
|
||||||
prefix,
|
prefix,
|
||||||
can_be_built: true,
|
can_be_built: true,
|
||||||
editable: false,
|
editable: false,
|
||||||
|
lighthouse_driver: LighthouseDriver::Survive,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,13 @@ impl Runner {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn xrservice_runner_from_profile(profile: &Profile) -> Self {
|
pub fn xrservice_runner_from_profile(profile: &Profile) -> Self {
|
||||||
|
let mut env = profile.environment.clone();
|
||||||
|
if !env.contains_key("LH_DRIVER") {
|
||||||
|
env.insert(
|
||||||
|
"LH_DRIVER".into(),
|
||||||
|
profile.lighthouse_driver.to_string().to_lowercase(),
|
||||||
|
);
|
||||||
|
}
|
||||||
Self::new(
|
Self::new(
|
||||||
Some(profile.environment.clone()),
|
Some(profile.environment.clone()),
|
||||||
match profile.xrservice_type {
|
match profile.xrservice_type {
|
||||||
|
@ -143,11 +150,7 @@ impl Runner {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut proc = process.unwrap();
|
let mut proc = process.unwrap();
|
||||||
let child_pid = Pid::from_raw(
|
let child_pid = Pid::from_raw(proc.id().try_into().expect("Could not convert pid to u32"));
|
||||||
proc.id()
|
|
||||||
.try_into()
|
|
||||||
.expect("Could not convert pid to u32"),
|
|
||||||
);
|
|
||||||
kill(child_pid, SIGTERM).expect("Could not send sigterm to process");
|
kill(child_pid, SIGTERM).expect("Could not send sigterm to process");
|
||||||
self.join_threads();
|
self.join_threads();
|
||||||
proc.wait().expect("Failed to wait for process");
|
proc.wait().expect("Failed to wait for process");
|
||||||
|
|
|
@ -6,7 +6,7 @@ use super::steam_launch_options_box::{SteamLaunchOptionsBox, SteamLaunchOptionsB
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::APP_NAME;
|
use crate::constants::APP_NAME;
|
||||||
use crate::file_utils::mount_has_nosuid;
|
use crate::file_utils::mount_has_nosuid;
|
||||||
use crate::profile::Profile;
|
use crate::profile::{Profile, LighthouseDriver};
|
||||||
use crate::ui::app::{
|
use crate::ui::app::{
|
||||||
AboutAction, BuildProfileAction, BuildProfileCleanAction, DebugViewToggleAction,
|
AboutAction, BuildProfileAction, BuildProfileCleanAction, DebugViewToggleAction,
|
||||||
};
|
};
|
||||||
|
@ -245,7 +245,7 @@ impl SimpleComponent for MainView {
|
||||||
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: model.selected_profile.features.libsurvive.enabled,
|
set_visible: model.selected_profile.lighthouse_driver == LighthouseDriver::Survive,
|
||||||
gtk::Separator {
|
gtk::Separator {
|
||||||
set_orientation: gtk::Orientation::Horizontal,
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
set_hexpand: true,
|
set_hexpand: true,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use super::{
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
env_var_descriptions::env_var_descriptions_as_paragraph,
|
env_var_descriptions::env_var_descriptions_as_paragraph,
|
||||||
profile::{Profile, XRServiceType},
|
profile::{LighthouseDriver, Profile, XRServiceType},
|
||||||
ui::preference_rows::{entry_row, path_row, switch_row},
|
ui::preference_rows::{entry_row, path_row, switch_row},
|
||||||
withclones,
|
withclones,
|
||||||
};
|
};
|
||||||
|
@ -101,14 +101,30 @@ impl SimpleComponent for ProfileEditor {
|
||||||
.collect::<Vec<String>>(),
|
.collect::<Vec<String>>(),
|
||||||
move |row| {
|
move |row| {
|
||||||
prof.borrow_mut().xrservice_type =
|
prof.borrow_mut().xrservice_type =
|
||||||
match row.selected() {
|
XRServiceType::from_number(row.selected());
|
||||||
0 => XRServiceType::Monado,
|
|
||||||
1 => XRServiceType::Wivrn,
|
|
||||||
_ => panic!("XRServiceType combo row cannot have more than 2 choices"),
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
add: {
|
||||||
|
withclones![prof];
|
||||||
|
&combo_row(
|
||||||
|
"Lighthouse Driver",
|
||||||
|
Some(concat!(
|
||||||
|
"Driver for lighhouse tracked XR devices (ie: Valve Index, HTC Vive...). Only applicable for Monado.\n\n",
|
||||||
|
"Vive: 3DOF tracking\n\n",
|
||||||
|
"Survive: 6DOF reverse engineered lighthouse tracking provided by Libsurvive\n\n",
|
||||||
|
"SteamVR: 6DOF lighthouse tracking using the proprietary SteamVR driver",
|
||||||
|
)),
|
||||||
|
model.profile.borrow().lighthouse_driver.to_string().as_str(),
|
||||||
|
LighthouseDriver::iter()
|
||||||
|
.map(LighthouseDriver::to_string)
|
||||||
|
.collect::<Vec<String>>(),
|
||||||
|
move |row| {
|
||||||
|
prof.borrow_mut().lighthouse_driver =
|
||||||
|
LighthouseDriver::from_number(row.selected());
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
add: {
|
add: {
|
||||||
withclones![prof];
|
withclones![prof];
|
||||||
&path_row(
|
&path_row(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue