Skip to content

Commit

Permalink
Feature/delay (#137)
Browse files Browse the repository at this point in the history
* Removed unneccessary delay and tested

* Readded linux delays just in case.

* Fix manual merge

---------

Co-authored-by: medzernik <1900179+medzernik@users.noreply.github.com>
  • Loading branch information
Aron-Kristofori and medzernik committed Jan 10, 2024
1 parent 84c3fa7 commit 1db42d9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions wooting-macro-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ async fn execute_macro(macros: Macro, channel: UnboundedSender<rdev::EventType>)
/// Puts a mandatory 0-20 ms delay between each macro execution (depending on the platform).
fn keypress_executor_sender(mut rchan_execute: UnboundedReceiver<rdev::EventType>) {
loop {
let received_event = match &rchan_execute.blocking_recv() {
let received_event = match &rchan_execute.blocking_recv() {
Some(event) => *event,
None => {
error!("Failed to receive an event!");
Expand All @@ -309,14 +309,10 @@ fn keypress_executor_sender(mut rchan_execute: UnboundedReceiver<rdev::EventType
};
plugin::util::direct_send_event(&received_event)
.unwrap_or_else(|err| error!("Error directly sending an event to keyboard: {}", err));

// MacOS and Linux require some delays.
plugin::util::send(&rchan_execute.blocking_recv().unwrap());
//MacOS and Linux require a delay between each macro execution.
#[cfg(not(target_os = "windows"))]
thread::sleep(time::Duration::from_millis(10));

// Windows execution delay can be set lower.
#[cfg(target_os = "windows")]
thread::sleep(time::Duration::from_millis(1));
}
}

Expand Down

0 comments on commit 1db42d9

Please sign in to comment.