From 502cc7f4140c7f225b821861faf29ccdf152b824 Mon Sep 17 00:00:00 2001 From: medzernik <1900179+medzernik@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:53:59 +0100 Subject: [PATCH] merge commit --- wooting-macro-backend/src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/wooting-macro-backend/src/lib.rs b/wooting-macro-backend/src/lib.rs index e7c6d9b1..10828600 100644 --- a/wooting-macro-backend/src/lib.rs +++ b/wooting-macro-backend/src/lib.rs @@ -297,6 +297,15 @@ fn keypress_executor_sender(mut rchan_execute: Receiver) { } } +async fn lift_keys(pressed_events: Vec, channel_sender: Sender) { + for x in pressed_events { + channel_sender + .send(rdev::EventType::KeyRelease(SCANCODE_TO_RDEV[&x])) + .await + .unwrap(); + } +} + /// A more efficient way using hashtable to check whether the trigger keys match the macro. /// /// `pressed_events` - the keys pressed in HID format (use the conversion HID hashtable to get the number). @@ -327,6 +336,12 @@ fn check_macro_execution_efficiently( let channel_clone = channel_sender.clone(); let macro_clone = macros.clone(); + let channel_clone2 = channel_sender.clone(); + let pressed_events2 = pressed_events.clone(); + task::spawn(async move { + + lift_keys(pressed_events2, channel_clone2).await; + }); task::spawn(async move { execute_macro(macro_clone, channel_clone).await; @@ -347,8 +362,15 @@ fn check_macro_execution_efficiently( let channel_clone = channel_sender.clone(); let macro_clone = macros.clone(); + let channel_clone2 = channel_sender.clone(); + let pressed_events2 = pressed_events.clone(); + task::spawn(async move { + + lift_keys(pressed_events2, channel_clone2).await; + }); task::spawn(async move { + tokio::time::sleep(time::Duration::from_millis(3)).await; execute_macro(macro_clone, channel_clone).await; }); output = true;