watch & edit to use theme.xml; device batteries
This commit is contained in:
@@ -4,7 +4,8 @@ use std::{collections::VecDeque, time::Instant};
|
||||
|
||||
use glam::{Affine3A, Vec2, Vec3A, Vec3Swizzles};
|
||||
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use idmap_derive::IntegerId;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use wlx_common::windowing::{OverlayWindowState, Positioning};
|
||||
|
||||
use crate::overlays::anchor::ANCHOR_NAME;
|
||||
@@ -12,7 +13,7 @@ use crate::state::{AppSession, AppState};
|
||||
use crate::subsystem::hid::WheelDelta;
|
||||
use crate::subsystem::input::KeyboardFocus;
|
||||
use crate::windowing::manager::OverlayWindowManager;
|
||||
use crate::windowing::window::{self, OverlayWindowData, realign};
|
||||
use crate::windowing::window::{self, realign, OverlayWindowData};
|
||||
use crate::windowing::{OverlayID, OverlaySelector};
|
||||
|
||||
use super::task::TaskType;
|
||||
@@ -31,7 +32,7 @@ pub struct TrackedDevice {
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, IntegerId)]
|
||||
pub enum TrackedDeviceRole {
|
||||
None,
|
||||
Hmd,
|
||||
|
||||
@@ -239,7 +239,8 @@ impl OpenVrInputSource {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_devices(&mut self, system: &mut SystemManager, app: &mut AppState) {
|
||||
pub fn update_devices(&mut self, system: &mut SystemManager, app: &mut AppState) -> bool {
|
||||
let old_len = app.input_state.devices.len();
|
||||
app.input_state.devices.clear();
|
||||
for idx in 0..TrackedDeviceIndex::MAX {
|
||||
let device = TrackedDeviceIndex::new(idx as _).unwrap(); // safe
|
||||
@@ -282,6 +283,8 @@ impl OpenVrInputSource {
|
||||
.then((a.role as u8).cmp(&(b.role as u8)))
|
||||
.then(a.soc.unwrap_or(999.).total_cmp(&b.soc.unwrap_or(999.)))
|
||||
});
|
||||
|
||||
old_len != app.input_state.devices.len()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,10 @@ pub fn openvr_run(
|
||||
}
|
||||
|
||||
if next_device_update <= Instant::now() {
|
||||
input_source.update_devices(&mut system_mgr, &mut app);
|
||||
let changed = input_source.update_devices(&mut system_mgr, &mut app);
|
||||
if changed {
|
||||
overlays.devices_changed(&mut app)?;
|
||||
}
|
||||
next_device_update = Instant::now() + Duration::from_secs(30);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use glam::{Affine3A, Quat, Vec3, bool};
|
||||
use glam::{bool, Affine3A, Quat, Vec3};
|
||||
use libmonado as mnd;
|
||||
use openxr::{self as xr, Quaternionf, Vector2f, Vector3f};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -15,7 +15,7 @@ use crate::{
|
||||
state::{AppSession, AppState},
|
||||
};
|
||||
|
||||
use super::{XrState, helpers::posef_to_transform};
|
||||
use super::{helpers::posef_to_transform, XrState};
|
||||
|
||||
static CLICK_TIMES: [Duration; 3] = [
|
||||
Duration::ZERO,
|
||||
@@ -247,7 +247,8 @@ impl OpenXrInputSource {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_devices(app: &mut AppState, monado: &mut mnd::Monado) {
|
||||
pub fn update_devices(app: &mut AppState, monado: &mut mnd::Monado) -> bool {
|
||||
let old_len = app.input_state.devices.len();
|
||||
app.input_state.devices.clear();
|
||||
|
||||
let roles = [
|
||||
@@ -294,6 +295,8 @@ impl OpenXrInputSource {
|
||||
.then((a.role as u8).cmp(&(b.role as u8)))
|
||||
.then(a.soc.unwrap_or(999.).total_cmp(&b.soc.unwrap_or(999.)))
|
||||
});
|
||||
|
||||
old_len != app.input_state.devices.len()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,10 @@ pub fn openxr_run(
|
||||
if next_device_update <= Instant::now()
|
||||
&& let Some(monado) = &mut monado
|
||||
{
|
||||
OpenXrInputSource::update_devices(&mut app, monado);
|
||||
let changed = OpenXrInputSource::update_devices(&mut app, monado);
|
||||
if changed {
|
||||
overlays.devices_changed(&mut app)?;
|
||||
}
|
||||
next_device_update = Instant::now() + Duration::from_secs(30);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user