mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-30 04:38:44 +00:00
feat: xr devices struct representing roles in monado log
This commit is contained in:
parent
f139857d92
commit
94932b0214
2 changed files with 66 additions and 0 deletions
|
@ -26,6 +26,7 @@ pub mod downloader;
|
|||
pub mod env_var_descriptions;
|
||||
pub mod log_parser;
|
||||
pub mod log_level;
|
||||
pub mod xr_devices;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// Prepare i18n
|
||||
|
|
65
src/xr_devices.rs
Normal file
65
src/xr_devices.rs
Normal file
|
@ -0,0 +1,65 @@
|
|||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum XRDevice {
|
||||
Head, Left, Right, Gamepad, Eyes, HandTrackingLeft, HandTrackingRight
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct XRDevices {
|
||||
pub head: Option<String>,
|
||||
pub left: Option<String>,
|
||||
pub right: Option<String>,
|
||||
pub gamepad: Option<String>,
|
||||
pub eyes: Option<String>,
|
||||
pub hand_tracking_left: 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 {
|
||||
pub fn from_log_message(s: String) -> Option<Self> {
|
||||
let rows = s.split("\n");
|
||||
let mut in_section = false;
|
||||
let mut devs = Self::default();
|
||||
for row in rows {
|
||||
if !in_section && row.starts_with("\tIn roles:") {
|
||||
in_section = true;
|
||||
continue;
|
||||
}
|
||||
if in_section {
|
||||
if row.starts_with("\tResult:") {
|
||||
break;
|
||||
}
|
||||
match row.trim().split(": ").collect::<Vec<&str>>()[..] {
|
||||
[_, "<none>"] => {},
|
||||
["head", val] => devs.head = Some(val.to_string()),
|
||||
["left", val] => devs.left = Some(val.to_string()),
|
||||
["right", val] => devs.right = Some(val.to_string()),
|
||||
["gamepad", val] => devs.gamepad = Some(val.to_string()),
|
||||
["eyes", val] => devs.eyes = Some(val.to_string()),
|
||||
["hand_tracking.left", val] => devs.hand_tracking_left = Some(val.to_string()),
|
||||
["hand_tracking.right", val] => {
|
||||
devs.hand_tracking_right = Some(val.to_string())
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
if in_section {
|
||||
return Some(devs);
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue