From 48480c8444ef5d1529bac6156b6ea1e4a812f59f Mon Sep 17 00:00:00 2001 From: William Edwards Date: Fri, 22 Nov 2024 09:49:57 -0800 Subject: [PATCH] fix(CompositeDevice): clear state for target devices on profile change --- src/input/composite_device/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/input/composite_device/mod.rs b/src/input/composite_device/mod.rs index 855ba07..10f5645 100644 --- a/src/input/composite_device/mod.rs +++ b/src/input/composite_device/mod.rs @@ -1528,6 +1528,17 @@ impl CompositeDevice { }); } + // Clear the state from all target devices + let target_devices = self.target_devices.clone(); + tokio::task::spawn(async move { + for (path, device) in target_devices.iter() { + log::debug!("Clearing state on device: {path}"); + if let Err(e) = device.clear_state().await { + log::error!("Failed to clear state on target device {path}: {e:?}"); + } + } + }); + log::debug!("Successfully loaded device profile: {}", profile.name); Ok(()) }