1
0

split scroll/zoom into two modes

accidentally switching to zoom mode ended up being pretty annoying
This commit is contained in:
Daniel Prilik
2020-11-01 23:55:51 -05:00
parent 0edac73be3
commit ffa936a0e3
7 changed files with 113 additions and 89 deletions

View File

@@ -0,0 +1,50 @@
use crate::controller::{ControlMode, ControlModeMeta};
use crate::dial_device::DialHaptics;
use crate::fake_input::{FakeInput, ScrollStep};
use crate::DynResult;
pub struct Scroll {
fake_input: FakeInput,
}
impl Scroll {
pub fn new() -> Scroll {
Scroll {
fake_input: FakeInput::new(),
}
}
}
impl ControlMode for Scroll {
fn meta(&self) -> ControlModeMeta {
ControlModeMeta {
name: "Scroll",
icon: "input-mouse",
}
}
fn on_start(&mut self, haptics: &DialHaptics) -> DynResult<()> {
haptics.set_mode(false, Some(90))?;
Ok(())
}
fn on_btn_press(&mut self, _: &DialHaptics) -> DynResult<()> {
Ok(())
}
fn on_btn_release(&mut self, _haptics: &DialHaptics) -> DynResult<()> {
Ok(())
}
fn on_dial(&mut self, _: &DialHaptics, delta: i32) -> DynResult<()> {
if delta > 0 {
eprintln!("scroll down");
self.fake_input.scroll_step(ScrollStep::Down)?;
} else {
eprintln!("scroll up");
self.fake_input.scroll_step(ScrollStep::Up)?;
}
Ok(())
}
}