notifications

This commit is contained in:
galister
2024-02-21 19:52:42 +01:00
parent 39cc22474b
commit e7710b56d9
18 changed files with 381 additions and 85 deletions

View File

@@ -129,12 +129,12 @@ impl OpenVrInputSource {
app: &mut AppState,
) {
let aas = ActiveActionSet(ovr_overlay::sys::VRActiveActionSet_t {
ulActionSet: self.set_hnd.0,
ulRestrictedToDevice: 0,
ulSecondaryActionSet: 0,
unPadding: 0,
nPriority: 0,
});
ulActionSet: self.set_hnd.0,
ulRestrictedToDevice: 0,
ulSecondaryActionSet: 0,
unPadding: 0,
nPriority: 0,
});
let _ = input.update_actions(&mut [aas]);
@@ -156,7 +156,6 @@ impl OpenVrInputSource {
.map(|pose| {
app_hand.pose = pose.0.pose.mDeviceToAbsoluteTracking.to_affine();
hand.has_pose = true;
});
app_hand.now.click = input
@@ -235,10 +234,9 @@ impl OpenVrInputSource {
_ => continue,
};
get_tracked_device(system, device, role).map(|device| {
if let Some(device) = get_tracked_device(system, device, role) {
app.input_state.devices.push(device);
});
}
}
app.input_state.devices.sort_by(|a, b| {

View File

@@ -18,7 +18,7 @@ pub(super) fn install_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::Res
if let Ok(true) = app_mgr.is_application_installed(APP_KEY) {
if let Ok(mut file) = File::open(&manifest_path) {
let mut buf = String::new();
if let Ok(_) = file.read_to_string(&mut buf) {
if file.read_to_string(&mut buf).is_ok() {
let manifest: json::JsonValue = json::parse(&buf)?;
if manifest["applications"][0]["binary_path_linux"] == executable_path {
log::info!("Manifest already up to date");
@@ -50,16 +50,20 @@ pub(super) fn install_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::Res
bail!("Failed to create manifest file at {:?}", manifest_path);
};
let Ok(()) = manifest.write(&mut file) else {
bail!("Failed to write manifest file at {:?}", manifest_path);
if let Err(e) = manifest.write(&mut file) {
bail!(
"Failed to write manifest file at {:?}: {:?}",
manifest_path,
e
);
};
let Ok(()) = app_mgr.add_application_manifest(&manifest_path, false) else {
bail!("Failed to add manifest to OpenVR");
if let Err(e) = app_mgr.add_application_manifest(&manifest_path, false) {
bail!("Failed to add manifest to OpenVR: {}", e.description());
};
let Ok(()) = app_mgr.set_application_auto_launch(APP_KEY, true) else {
bail!("Failed to set auto launch");
if let Err(e) = app_mgr.set_application_auto_launch(APP_KEY, true) {
bail!("Failed to set auto launch: {}", e.description());
};
Ok(())
@@ -69,8 +73,8 @@ pub(super) fn uninstall_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::R
let manifest_path = CONFIG_ROOT_PATH.join("wlx-overlay-s.vrmanifest");
if let Ok(true) = app_mgr.is_application_installed(APP_KEY) {
let Ok(()) = app_mgr.remove_application_manifest(&manifest_path) else {
bail!("Failed to remove manifest from OpenVR");
if let Err(e) = app_mgr.remove_application_manifest(&manifest_path) {
bail!("Failed to remove manifest from OpenVR: {}", e.description());
};
log::info!("Uninstalled manifest");
}

View File

@@ -21,6 +21,7 @@ use vulkano::{
use crate::{
backend::{
input::interact,
notifications::NotificationManager,
openvr::{
input::{set_action_manifest, OpenVrInputSource},
lines::LinePool,
@@ -91,6 +92,9 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
let _ = install_manifest(&mut app_mgr);
let mut overlays = OverlayContainer::<OpenVrOverlayData>::new(&mut state)?;
let mut notifications = NotificationManager::new();
notifications.run_dbus();
notifications.run_udp();
let mut space_mover = playspace::PlayspaceMover::new();
#[cfg(feature = "osc")]
@@ -149,6 +153,8 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
next_device_update = Instant::now() + Duration::from_secs(30);
}
notifications.submit_pending(&mut state);
state.tasks.retrieve_due(&mut due_tasks);
while let Some(task) = due_tasks.pop_front() {
match task {
@@ -167,6 +173,8 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
continue;
};
log::info!("Creating overlay: {}", state.name);
overlays.add(OverlayData {
state,
backend,
@@ -175,14 +183,11 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
}
TaskType::DropOverlay(sel) => {
if let Some(o) = overlays.mut_by_selector(&sel) {
log::info!("Dropping overlay: {}", o.state.name);
o.destroy(&mut overlay_mngr);
overlays.drop_by_selector(&sel);
}
}
TaskType::Toast(t) => {
// TODO toasts
log::info!("Toast: {} {}", t.title, t.body);
}
}
}
@@ -249,8 +254,6 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
// close font handles?
// playspace moved end frame
state.hid_provider.on_new_frame();
let mut seconds_since_vsync = 0f32;