From ee2c09c690b72fd7d8151810bcf40da7102ebdae Mon Sep 17 00:00:00 2001 From: Daniel Prilik Date: Fri, 6 Nov 2020 10:55:47 -0500 Subject: [PATCH] enable experimental smooth scrolling support --- README.md | 2 +- src/controller/controls/scroll_mt.rs | 10 ++++++++-- src/fake_input.rs | 4 ++-- src/main.rs | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 99ddcbf..540eb9e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ While the device-handling code itself is somewhat messy at the moment, it should - [x] Volume Controls - [x] Media Controls - [x] Scrolling - using a virtual mouse-wheel - - [ ] Scrolling - using a virtual touchpad (for [smoother scrolling](https://who-t.blogspot.com/2020/04/high-resolution-wheel-scrolling-in.html)) - **WIP** + - [x] Scrolling - using a virtual touchpad (for [smoother scrolling](https://who-t.blogspot.com/2020/04/high-resolution-wheel-scrolling-in.html)) - **EXPERIMENTAL** - [x] Zooming - [x] [Paddle](https://www.google.com/search?q=arkanoid+paddle) (emulated left, right, and space key) - [ ] \(meta\) custom modes specified via config file(s) diff --git a/src/controller/controls/scroll_mt.rs b/src/controller/controls/scroll_mt.rs index b785761..921a0b2 100644 --- a/src/controller/controls/scroll_mt.rs +++ b/src/controller/controls/scroll_mt.rs @@ -16,7 +16,7 @@ impl ScrollMT { impl ControlMode for ScrollMT { fn meta(&self) -> ControlModeMeta { ControlModeMeta { - name: "Scroll", + name: "Scroll (Fake Multitouch - EXPERIMENTAL)", icon: "input-mouse", haptics: false, steps: 3600, @@ -26,7 +26,13 @@ impl ControlMode for ScrollMT { fn on_start(&mut self, _haptics: &DialHaptics) -> Result<()> { self.acc_delta = 0; - fake_input::scroll_mt_start().map_err(Error::Evdev)?; + // HACK: for some reason, if scroll mode is the startup mode, then just calling + // `scroll_mt_start` doesn't work as expected. + std::thread::spawn(move || { + fake_input::scroll_mt_end().unwrap(); + std::thread::sleep(std::time::Duration::from_millis(200)); + fake_input::scroll_mt_start().unwrap(); + }); Ok(()) } diff --git a/src/fake_input.rs b/src/fake_input.rs index 383e81f..6b5e9e4 100644 --- a/src/fake_input.rs +++ b/src/fake_input.rs @@ -6,8 +6,8 @@ use parking_lot::ReentrantMutex; // this should be a fairly high number, as the axis is from 0..(MT_BASELINE*2) const MT_BASELINE: i32 = std::i32::MAX / 8; -// higher = more sensitive -const MT_SENSITIVITY: i32 = 64; +// higher = slower scrolling +const MT_SENSITIVITY: i32 = 48; pub struct FakeInputs { keyboard: ReentrantMutex, diff --git a/src/main.rs b/src/main.rs index c89ae08..7da541c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -82,8 +82,8 @@ fn controller_main() -> Result<()> { dial, cfg.last_mode, vec![ - // Box::new(controller::controls::ScrollMT::new()), Box::new(controller::controls::Scroll::new()), + Box::new(controller::controls::ScrollMT::new()), Box::new(controller::controls::Zoom::new()), Box::new(controller::controls::Volume::new()), Box::new(controller::controls::Media::new()),