mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 14:49:04 +00:00
fix: more gentle libmonado probing (keep monado instance around)
This commit is contained in:
parent
cc09229aeb
commit
98218ab396
2 changed files with 36 additions and 23 deletions
|
@ -94,6 +94,8 @@ pub struct App {
|
||||||
xr_devices: XRDevices,
|
xr_devices: XRDevices,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
fbt_config_editor: Option<Controller<FbtConfigEditor>>,
|
fbt_config_editor: Option<Controller<FbtConfigEditor>>,
|
||||||
|
#[tracker::do_not_track]
|
||||||
|
libmonado: Option<libmonado_rs::Monado>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -218,6 +220,7 @@ impl App {
|
||||||
if let Some(worker) = self.xrservice_worker.as_ref() {
|
if let Some(worker) = self.xrservice_worker.as_ref() {
|
||||||
worker.stop();
|
worker.stop();
|
||||||
}
|
}
|
||||||
|
self.libmonado = None;
|
||||||
self.restore_openxr_openvr_files();
|
self.restore_openxr_openvr_files();
|
||||||
self.main_view
|
self.main_view
|
||||||
.sender()
|
.sender()
|
||||||
|
@ -310,12 +313,25 @@ impl SimpleComponent for App {
|
||||||
Msg::ClockTicking => {
|
Msg::ClockTicking => {
|
||||||
self.main_view.sender().emit(MainViewMsg::ClockTicking);
|
self.main_view.sender().emit(MainViewMsg::ClockTicking);
|
||||||
if let Some(w) = self.xrservice_worker.as_ref() {
|
if let Some(w) = self.xrservice_worker.as_ref() {
|
||||||
if w.state.lock().unwrap().exit_status.is_none() {
|
if {
|
||||||
self.xr_devices
|
let state = w.state.lock().unwrap();
|
||||||
.merge(XRDevices::from_libmonado(&self.get_selected_profile()));
|
state.exit_status.is_none() && !state.stop_requested
|
||||||
self.main_view
|
} {
|
||||||
.sender()
|
if let Some(monado) = self.libmonado.as_ref() {
|
||||||
.emit(MainViewMsg::UpdateDevices(Some(self.xr_devices.clone())));
|
self.xr_devices
|
||||||
|
.merge(XRDevices::from_libmonado(monado));
|
||||||
|
self.main_view
|
||||||
|
.sender()
|
||||||
|
.emit(MainViewMsg::UpdateDevices(Some(self.xr_devices.clone())));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if let Some(so) = self.get_selected_profile().libmonado_so() {
|
||||||
|
self.libmonado = libmonado_rs::Monado::create(so).ok();
|
||||||
|
if self.libmonado.is_some() {
|
||||||
|
sender.input(Msg::ClockTicking);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -657,6 +673,7 @@ impl SimpleComponent for App {
|
||||||
xr_devices: XRDevices::default(),
|
xr_devices: XRDevices::default(),
|
||||||
fbt_config_editor: None,
|
fbt_config_editor: None,
|
||||||
restart_xrservice: false,
|
restart_xrservice: false,
|
||||||
|
libmonado: None,
|
||||||
};
|
};
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
|
|
@ -71,25 +71,21 @@ impl XRDevices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_libmonado(prof: &Profile) -> Self {
|
pub fn from_libmonado(monado: &libmonado_rs::Monado) -> Self {
|
||||||
let mut res = Self::default();
|
let mut res = Self::default();
|
||||||
if let Some(libmonado_path) = prof.libmonado_so() {
|
[
|
||||||
if let Ok(monado) = libmonado_rs::Monado::create(libmonado_path) {
|
XRDevice::Head,
|
||||||
[
|
XRDevice::Left,
|
||||||
XRDevice::Head,
|
XRDevice::Right,
|
||||||
XRDevice::Left,
|
XRDevice::Gamepad,
|
||||||
XRDevice::Right,
|
XRDevice::Eyes,
|
||||||
XRDevice::Gamepad,
|
]
|
||||||
XRDevice::Eyes,
|
.iter()
|
||||||
]
|
.for_each(|xrd| {
|
||||||
.iter()
|
if let Ok(dev) = monado.device_from_role(xrd.to_monado_str()) {
|
||||||
.for_each(|xrd| {
|
res.set_device(&xrd, dev.name);
|
||||||
if let Ok(dev) = monado.device_from_role(xrd.to_monado_str()) {
|
|
||||||
res.set_device(&xrd, dev.name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue