mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-09-25 10:48:36 +00:00
feat: feature flag to use libmonado or not
This commit is contained in:
parent
ab32558546
commit
4172c351e1
6 changed files with 51 additions and 19 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -289,6 +289,7 @@ dependencies = [
|
|||
"gettext-rs",
|
||||
"git2",
|
||||
"gtk4",
|
||||
"lazy_static",
|
||||
"libadwaita",
|
||||
"libmonado-rs",
|
||||
"libusb",
|
||||
|
|
|
@ -14,6 +14,7 @@ git2 = "0.17.2"
|
|||
gtk4 = { version = "0.7.2", features = [
|
||||
"v4_10",
|
||||
] }
|
||||
lazy_static = "1.4.0"
|
||||
libadwaita = { version = "0.5.2", features = [
|
||||
"v1_3"
|
||||
] }
|
||||
|
|
|
@ -33,6 +33,12 @@ cd envision
|
|||
./dist/appimage/build_appimage.sh
|
||||
```
|
||||
|
||||
# Feature flags
|
||||
|
||||
|Env var|Values|Default|
|
||||
|---|---|---|
|
||||
|`ENVISION_FF_USE_LIBMONADO`|`1`: enabled; `0`: disabled|`0`|
|
||||
|
||||
# Common issues
|
||||
|
||||
## NOSUID with systemd-homed
|
||||
|
|
|
@ -3,6 +3,7 @@ use super::alert::alert;
|
|||
use super::build_window::{BuildStatus, BuildWindow};
|
||||
use super::debug_view::{DebugView, DebugViewMsg};
|
||||
use super::fbt_config_editor::{FbtConfigEditor, FbtConfigEditorInit, FbtConfigEditorMsg};
|
||||
use super::feature_flags::FF_LIBMONADO_DEVICE_ENUMERATION_ENABLED;
|
||||
use super::job_worker::internal_worker::JobWorkerOut;
|
||||
use super::job_worker::job::WorkerJob;
|
||||
use super::job_worker::JobWorker;
|
||||
|
@ -312,24 +313,26 @@ impl SimpleComponent for App {
|
|||
}
|
||||
Msg::ClockTicking => {
|
||||
self.main_view.sender().emit(MainViewMsg::ClockTicking);
|
||||
if let Some(w) = self.xrservice_worker.as_ref() {
|
||||
if {
|
||||
let state = w.state.lock().unwrap();
|
||||
state.exit_status.is_none() && !state.stop_requested
|
||||
} {
|
||||
if let Some(monado) = self.libmonado.as_ref() {
|
||||
self.xr_devices = XRDevice::merge(
|
||||
&self.xr_devices,
|
||||
&XRDevice::from_libmonado(monado),
|
||||
);
|
||||
self.main_view
|
||||
.sender()
|
||||
.emit(MainViewMsg::UpdateDevices(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);
|
||||
if *FF_LIBMONADO_DEVICE_ENUMERATION_ENABLED {
|
||||
if let Some(w) = self.xrservice_worker.as_ref() {
|
||||
if {
|
||||
let state = w.state.lock().unwrap();
|
||||
state.exit_status.is_none() && !state.stop_requested
|
||||
} {
|
||||
if let Some(monado) = self.libmonado.as_ref() {
|
||||
self.xr_devices = XRDevice::merge(
|
||||
&self.xr_devices,
|
||||
&XRDevice::from_libmonado(monado),
|
||||
);
|
||||
self.main_view
|
||||
.sender()
|
||||
.emit(MainViewMsg::UpdateDevices(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +344,17 @@ impl SimpleComponent for App {
|
|||
match MonadoLog::new_from_str(row.as_str()) {
|
||||
None => {}
|
||||
Some(parsed) => {
|
||||
if let Some(tracker) =
|
||||
if !*FF_LIBMONADO_DEVICE_ENUMERATION_ENABLED
|
||||
&& parsed.func == "p_create_system"
|
||||
{
|
||||
let n_devs = XRDevice::from_log_message(parsed.message.as_str());
|
||||
self.xr_devices = XRDevice::merge(&self.xr_devices, &n_devs);
|
||||
self.main_view
|
||||
.sender()
|
||||
.emit(MainViewMsg::UpdateDevices(
|
||||
self.xr_devices.clone(),
|
||||
));
|
||||
} else if let Some(tracker) =
|
||||
XRDevice::generic_tracker_from_log_row(parsed.message.as_str())
|
||||
{
|
||||
self.xr_devices.push(tracker);
|
||||
|
|
10
src/ui/feature_flags.rs
Normal file
10
src/ui/feature_flags.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use std::env;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
fn get_ff_libmonado_device_enumeration_enabled() -> bool {
|
||||
env::var("ENVISION_FF_USE_LIBMONADO").unwrap_or_default() == "1"
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref FF_LIBMONADO_DEVICE_ENUMERATION_ENABLED: bool = get_ff_libmonado_device_enumeration_enabled();
|
||||
}
|
|
@ -16,3 +16,4 @@ pub mod profile_editor;
|
|||
pub mod steam_launch_options_box;
|
||||
pub mod util;
|
||||
pub mod wivrn_conf_editor;
|
||||
pub mod feature_flags;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue