1
0

enable experimental smooth scrolling support

This commit is contained in:
Daniel Prilik
2020-11-06 10:55:47 -05:00
parent 68676cc1d1
commit ee2c09c690
4 changed files with 12 additions and 6 deletions

View File

@@ -38,7 +38,7 @@ While the device-handling code itself is somewhat messy at the moment, it should
- [x] Volume Controls - [x] Volume Controls
- [x] Media Controls - [x] Media Controls
- [x] Scrolling - using a virtual mouse-wheel - [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] Zooming
- [x] [Paddle](https://www.google.com/search?q=arkanoid+paddle) (emulated left, right, and space key) - [x] [Paddle](https://www.google.com/search?q=arkanoid+paddle) (emulated left, right, and space key)
- [ ] \(meta\) custom modes specified via config file(s) - [ ] \(meta\) custom modes specified via config file(s)

View File

@@ -16,7 +16,7 @@ impl ScrollMT {
impl ControlMode for ScrollMT { impl ControlMode for ScrollMT {
fn meta(&self) -> ControlModeMeta { fn meta(&self) -> ControlModeMeta {
ControlModeMeta { ControlModeMeta {
name: "Scroll", name: "Scroll (Fake Multitouch - EXPERIMENTAL)",
icon: "input-mouse", icon: "input-mouse",
haptics: false, haptics: false,
steps: 3600, steps: 3600,
@@ -26,7 +26,13 @@ impl ControlMode for ScrollMT {
fn on_start(&mut self, _haptics: &DialHaptics) -> Result<()> { fn on_start(&mut self, _haptics: &DialHaptics) -> Result<()> {
self.acc_delta = 0; 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(()) Ok(())
} }

View File

@@ -6,8 +6,8 @@ use parking_lot::ReentrantMutex;
// this should be a fairly high number, as the axis is from 0..(MT_BASELINE*2) // this should be a fairly high number, as the axis is from 0..(MT_BASELINE*2)
const MT_BASELINE: i32 = std::i32::MAX / 8; const MT_BASELINE: i32 = std::i32::MAX / 8;
// higher = more sensitive // higher = slower scrolling
const MT_SENSITIVITY: i32 = 64; const MT_SENSITIVITY: i32 = 48;
pub struct FakeInputs { pub struct FakeInputs {
keyboard: ReentrantMutex<UInputDevice>, keyboard: ReentrantMutex<UInputDevice>,

View File

@@ -82,8 +82,8 @@ fn controller_main() -> Result<()> {
dial, dial,
cfg.last_mode, cfg.last_mode,
vec![ vec![
// Box::new(controller::controls::ScrollMT::new()),
Box::new(controller::controls::Scroll::new()), Box::new(controller::controls::Scroll::new()),
Box::new(controller::controls::ScrollMT::new()),
Box::new(controller::controls::Zoom::new()), Box::new(controller::controls::Zoom::new()),
Box::new(controller::controls::Volume::new()), Box::new(controller::controls::Volume::new()),
Box::new(controller::controls::Media::new()), Box::new(controller::controls::Media::new()),