From 5b594ab6d0fb44c9f4e4ec660f6dd8d60410c3df Mon Sep 17 00:00:00 2001 From: Daniel Prilik Date: Sat, 7 Nov 2020 10:58:36 -0500 Subject: [PATCH] avoid dropping first input after daemon is spawned --- src/fake_input.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fake_input.rs b/src/fake_input.rs index 6b5e9e4..2a8a1ac 100644 --- a/src/fake_input.rs +++ b/src/fake_input.rs @@ -120,6 +120,10 @@ lazy_static::lazy_static! { Ok(ReentrantMutex::new(UInputDevice::create_from_device(&device)?)) })().expect("failed to install virtual touchpad device"); + // HACK: give the kernel a chance to register the new devices. If this + // line is omitted, the first fake input is likely to be dropped. + std::thread::sleep(std::time::Duration::from_millis(500)); + FakeInputs { keyboard, touchpad