update libmonado and use better input blocking when available
This commit is contained in:
32
Cargo.lock
generated
32
Cargo.lock
generated
@@ -694,15 +694,12 @@ dependencies = [
|
||||
"itertools 0.12.1",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash 1.1.0",
|
||||
"shlex",
|
||||
"syn 2.0.113",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2277,15 +2274,6 @@ version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hound"
|
||||
version = "3.5.1"
|
||||
@@ -2893,12 +2881,10 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "libmonado"
|
||||
version = "1.3.2"
|
||||
source = "git+https://github.com/technobaboo/libmonado-rs.git?rev=26292e5b14663ee2f089f66f0851438a0c00ee67#26292e5b14663ee2f089f66f0851438a0c00ee67"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0df3183760954d877b894d42f5c6954837d8a7d7bd5f042409c4175afeaf24ea"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cmake",
|
||||
"convert_case 0.6.0",
|
||||
"dlopen2",
|
||||
"flagset",
|
||||
"libc",
|
||||
@@ -6441,18 +6427,6 @@ dependencies = [
|
||||
"vulkano-shaders",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix 0.38.44",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "widestring"
|
||||
version = "1.2.1"
|
||||
|
||||
@@ -57,7 +57,7 @@ interprocess = { version = "2.2.3" }
|
||||
json = { version = "0.12.4", optional = true }
|
||||
json5 = "1.3.0"
|
||||
libc = "0.2.178"
|
||||
libmonado = { git = "https://github.com/technobaboo/libmonado-rs.git", rev = "26292e5b14663ee2f089f66f0851438a0c00ee67", optional = true }
|
||||
libmonado = { version = "1.6.0", optional = true }
|
||||
log-panics = { version = "2.1.0", features = ["with-backtrace"] }
|
||||
mint = "0.5.9"
|
||||
openxr = { version = "0.21.0", features = ["linked", "mint"], optional = true }
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
use libmonado::{ClientState, Monado};
|
||||
use libmonado::{BlockFlags, ClientLogic, ClientState, Monado, Version};
|
||||
use log::{trace, warn};
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
pub(super) struct InputBlocker {
|
||||
use_io_blocks: bool,
|
||||
blocked_last_frame: bool,
|
||||
}
|
||||
|
||||
impl InputBlocker {
|
||||
pub const fn new() -> Self {
|
||||
pub fn new(monado: &Monado) -> Self {
|
||||
Self {
|
||||
use_io_blocks: monado.get_api_version() >= Version::new(1, 6, 0),
|
||||
blocked_last_frame: false,
|
||||
}
|
||||
}
|
||||
@@ -29,47 +31,59 @@ impl InputBlocker {
|
||||
match (should_block, self.blocked_last_frame) {
|
||||
(true, false) => {
|
||||
trace!("Blocking input");
|
||||
set_clients_io_active(monado, false);
|
||||
self.block_inputs(monado, true);
|
||||
}
|
||||
(false, true) => {
|
||||
trace!("Unblocking input");
|
||||
set_clients_io_active(monado, true);
|
||||
self.block_inputs(monado, false);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.blocked_last_frame = should_block;
|
||||
}
|
||||
}
|
||||
|
||||
fn set_clients_io_active(monado: &mut Monado, active: bool) {
|
||||
match monado.clients() {
|
||||
Ok(clients) => {
|
||||
for mut client in clients {
|
||||
let name = match client.name() {
|
||||
Ok(n) => n,
|
||||
Err(e) => {
|
||||
warn!("Failed to get client name: {e}");
|
||||
continue;
|
||||
fn block_inputs(&self, monado: &mut Monado, block: bool) {
|
||||
match monado.clients() {
|
||||
Ok(clients) => {
|
||||
for mut client in clients {
|
||||
match client.name() {
|
||||
Ok(n) => {
|
||||
if n == "wayvr" {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Failed to get client name: {e}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let state = match client.state() {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
warn!("Failed to get client state: {e}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
if state.contains(ClientState::ClientSessionVisible) {
|
||||
let r = if self.use_io_blocks {
|
||||
client.set_io_blocks(if block {
|
||||
BlockFlags::BlockInputs.into()
|
||||
} else {
|
||||
BlockFlags::None.into()
|
||||
})
|
||||
} else {
|
||||
client.set_io_active(!block)
|
||||
};
|
||||
if let Err(e) = r {
|
||||
warn!("Failed to set io active for client: {e}");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let state = match client.state() {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
warn!("Failed to get client state: {e}");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
if name != "wayvr"
|
||||
&& state.contains(ClientState::ClientSessionVisible)
|
||||
&& let Err(e) = client.set_io_active(active)
|
||||
{
|
||||
warn!("Failed to set io active for client: {e}");
|
||||
}
|
||||
}
|
||||
Err(e) => warn!("Failed to get clients from Monado: {e}"),
|
||||
}
|
||||
Err(e) => warn!("Failed to get clients from Monado: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
};
|
||||
|
||||
use glam::{Affine3A, Quat, Vec3, bool};
|
||||
use libmonado as mnd;
|
||||
use libmonado::{self as mnd, DeviceLogic};
|
||||
use openxr::{self as xr, Quaternionf, Vector2f, Vector3f};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wlx_common::{config::HandsfreePointer, config_io};
|
||||
|
||||
@@ -93,7 +93,7 @@ pub fn openxr_run(show_by_default: bool, headless: bool) -> Result<(), BackendEr
|
||||
.ok()
|
||||
});
|
||||
|
||||
let mut blocker = app.monado.is_some().then(blocker::InputBlocker::new);
|
||||
let mut blocker = app.monado.as_ref().map(blocker::InputBlocker::new);
|
||||
|
||||
let (session, mut frame_wait, mut frame_stream) = unsafe {
|
||||
let raw_session = helpers::create_overlay_session(
|
||||
|
||||
@@ -24,6 +24,9 @@ use wlx_common::{
|
||||
windowing::{OverlayWindowState, Positioning},
|
||||
};
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
use libmonado::{ClientLogic, DeviceLogic};
|
||||
|
||||
use crate::{
|
||||
RESTART, RUNNING,
|
||||
backend::{
|
||||
|
||||
Reference in New Issue
Block a user