1
0

experimental multitouch based smooth scrolling

high-resolution mouse wheels aren't supported in userland yet, so why
don't we fake a high resolution touchpad instead 😄

it's somewhat working, though it seems to crash on startup when
installed (among other weird bugs).
This commit is contained in:
Daniel Prilik
2020-11-02 18:50:45 -05:00
parent 3285021903
commit 4f25a73eb3
7 changed files with 4905 additions and 57 deletions

View File

@@ -2,6 +2,7 @@ mod media;
mod null;
mod paddle;
mod scroll;
mod scroll_mt;
mod volume;
mod zoom;
@@ -9,5 +10,6 @@ pub use self::media::*;
pub use self::null::*;
pub use self::paddle::*;
pub use self::scroll::*;
pub use self::scroll_mt::*;
pub use self::volume::*;
pub use self::zoom::*;

View File

@@ -0,0 +1,61 @@
use crate::controller::{ControlMode, ControlModeMeta};
use crate::dial_device::DialHaptics;
use crate::fake_input::FakeInput;
use crate::DynResult;
pub struct ScrollMT {
acc_delta: i32,
fake_input: FakeInput,
}
impl ScrollMT {
pub fn new() -> ScrollMT {
ScrollMT {
acc_delta: 0,
fake_input: FakeInput::new(),
}
}
}
impl ControlMode for ScrollMT {
fn meta(&self) -> ControlModeMeta {
ControlModeMeta {
name: "Scroll",
icon: "input-mouse",
}
}
fn on_start(&mut self, haptics: &DialHaptics) -> DynResult<()> {
haptics.set_mode(false, Some(3600))?;
self.acc_delta = 0;
self.fake_input.scroll_mt_start()?;
Ok(())
}
fn on_end(&mut self, _haptics: &DialHaptics) -> DynResult<()> {
self.fake_input.scroll_mt_end()?;
Ok(())
}
// HACK: the button will reset the scroll event, which sometimes helps
fn on_btn_press(&mut self, _: &DialHaptics) -> DynResult<()> {
self.fake_input.scroll_mt_end()?;
Ok(())
}
fn on_btn_release(&mut self, _haptics: &DialHaptics) -> DynResult<()> {
self.fake_input.scroll_mt_start()?;
Ok(())
}
fn on_dial(&mut self, _: &DialHaptics, delta: i32) -> DynResult<()> {
self.acc_delta += delta;
self.fake_input.scroll_mt_step(self.acc_delta)?;
Ok(())
}
}