mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-21 20:14:50 +00:00
feat: use device prober on first launch to try selecting an appropriate profile
This commit is contained in:
parent
699566f3d4
commit
fbf2682f26
3 changed files with 32 additions and 14 deletions
|
@ -1,4 +1,7 @@
|
|||
use crate::{constants::CMD_NAME, file_utils::get_writer, paths::get_config_dir, profile::Profile};
|
||||
use crate::{
|
||||
constants::CMD_NAME, device_prober::get_xr_usb_devices, file_utils::get_writer,
|
||||
paths::get_config_dir, profile::Profile,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fs::File, io::BufReader};
|
||||
|
||||
|
@ -29,12 +32,20 @@ impl Default for Config {
|
|||
|
||||
impl Config {
|
||||
pub fn get_selected_profile(&self, profiles: &Vec<Profile>) -> Profile {
|
||||
let def = || profiles.get(0).expect("No profiles found").clone();
|
||||
|
||||
match profiles
|
||||
.iter()
|
||||
.find(|p| p.uuid == self.selected_profile_uuid)
|
||||
{
|
||||
Some(p) => p.clone(),
|
||||
None => profiles.get(0).expect("No profiles found").clone(),
|
||||
None => match get_xr_usb_devices().get(0) {
|
||||
Some(dev) => match dev.get_default_profile() {
|
||||
Some(p) => p,
|
||||
None => def(),
|
||||
},
|
||||
None => def(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
use crate::{profile::Profile, profiles::{valve_index::valve_index_profile, wivrn::wivrn_profile}};
|
||||
use crate::{
|
||||
profile::Profile,
|
||||
profiles::{
|
||||
lighthouse::lighthouse_profile, valve_index::valve_index_profile, wivrn::wivrn_profile,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum PhysicalXRDevice {
|
||||
|
@ -84,7 +89,17 @@ impl Display for PhysicalXRDevice {
|
|||
impl PhysicalXRDevice {
|
||||
pub fn get_default_profile(&self) -> Option<Profile> {
|
||||
match &self {
|
||||
Self::ValveIndex => Some(valve_index_profile()),
|
||||
Self::ValveIndex => Some(lighthouse_profile()),
|
||||
Self::HTCVive => Some(lighthouse_profile()),
|
||||
Self::HTCVivePro => Some(lighthouse_profile()),
|
||||
Self::HTCVivePro2 => Some(lighthouse_profile()),
|
||||
Self::Pimax4K => Some(lighthouse_profile()),
|
||||
Self::Pimax5KPlus => Some(lighthouse_profile()),
|
||||
Self::Pimax8K => Some(lighthouse_profile()),
|
||||
Self::VarjoVR1 => Some(lighthouse_profile()),
|
||||
Self::VarjoAero => Some(lighthouse_profile()),
|
||||
Self::VarjoVR2 => Some(lighthouse_profile()),
|
||||
Self::VarjoVR3 => Some(lighthouse_profile()),
|
||||
Self::OculusQuest => Some(wivrn_profile()),
|
||||
Self::OculusQuest2 => Some(wivrn_profile()),
|
||||
Self::OculusQuestPro => Some(wivrn_profile()),
|
||||
|
@ -94,17 +109,11 @@ impl PhysicalXRDevice {
|
|||
Self::PicoNeo3Pro => Some(wivrn_profile()),
|
||||
Self::Pico4 => Some(wivrn_profile()),
|
||||
_ => None,
|
||||
// Self::HTCVive => "HTC Vive",
|
||||
// Self::HTCVivePro => "HTC Vive Pro",
|
||||
// Self::HTCViveCosmos => "HTC Vive Cosmos",
|
||||
// Self::HTCVivePro2 => "HTC Vive Pro2",
|
||||
// Self::OculusRift => "Oculus Rift",
|
||||
// Self::OculusRiftS => "Oculus Rift S",
|
||||
// Self::PlayStationVR => "PlayStation Vr",
|
||||
// Self::PlayStationVR2 => "PlayStation Vr2",
|
||||
// Self::Pimax4K => "Pimax 4K",
|
||||
// Self::Pimax5KPlus => "Pimax 5K Plus",
|
||||
// Self::Pimax8K => "Pimax 8K",
|
||||
// Self::DellVisor => "Dell Visor",
|
||||
// Self::AcerAH101 => "Acer AH101",
|
||||
// Self::HPWMR => "HP WMR",
|
||||
|
@ -113,10 +122,6 @@ impl PhysicalXRDevice {
|
|||
// Self::LenovoExplorer => "Lenovo Explorer",
|
||||
// Self::SamsungOdyssey => "Samsung Odyssey",
|
||||
// Self::SamsungOdysseyPlus => "Samsung Odyssey Plus",
|
||||
// Self::VarjoVR1 => "Varjo VR1",
|
||||
// Self::VarjoAero => "Varjo Aero",
|
||||
// Self::VarjoVR2 => "Varjo VR2",
|
||||
// Self::VarjoVR3 => "Varjo VR3",
|
||||
// Self::RazerHydra => "Razer Hydra",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ use crate::file_builders::openvrpaths_vrpath::{
|
|||
use crate::file_utils::setcap_cap_sys_nice_eip;
|
||||
use crate::log_parser::MonadoLog;
|
||||
use crate::profile::{Profile, XRServiceType};
|
||||
use crate::profiles::lighthouse::lighthouse_profile;
|
||||
use crate::profiles::system_valve_index::system_valve_index_profile;
|
||||
use crate::profiles::valve_index::valve_index_profile;
|
||||
use crate::profiles::wivrn::wivrn_profile;
|
||||
|
@ -205,6 +206,7 @@ impl App {
|
|||
|
||||
pub fn profiles_list(config: &Config) -> Vec<Profile> {
|
||||
let mut profiles = vec![
|
||||
lighthouse_profile(),
|
||||
valve_index_profile(),
|
||||
system_valve_index_profile(),
|
||||
wivrn_profile(),
|
||||
|
|
Loading…
Add table
Reference in a new issue