Implemented a back button. Pressing the button in scroll_mt mode will issue a KEY_BACK command, allowing to easily browse between pages.
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::controller::{ControlMode, ControlModeMeta};
|
||||
use crate::dial_device::DialHaptics;
|
||||
use crate::error::{Error, Result};
|
||||
use crate::fake_input;
|
||||
use evdev_rs::enums::EV_KEY;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::{self, JoinHandle};
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -92,16 +93,12 @@ impl ControlMode for ScrollMT {
|
||||
}
|
||||
|
||||
fn on_btn_press(&mut self, _: &DialHaptics) -> Result<()> {
|
||||
// End multitouch scrolling on button press
|
||||
fake_input::scroll_mt_end().map_err(Error::Evdev)?;
|
||||
*self.is_scrolling.lock().unwrap() = false;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_btn_release(&mut self, _haptics: &DialHaptics) -> Result<()> {
|
||||
// Restart multitouch scrolling on button release
|
||||
fake_input::scroll_mt_start().map_err(Error::Evdev)?;
|
||||
*self.is_scrolling.lock().unwrap() = true;
|
||||
// Send "previous page" signal on button press
|
||||
fake_input::key_click(&[EV_KEY::KEY_BACK]).map_err(Error::Evdev)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@ lazy_static::lazy_static! {
|
||||
device.enable(&EventCode::EV_KEY(EV_KEY::KEY_SPACE))?;
|
||||
device.enable(&EventCode::EV_KEY(EV_KEY::KEY_EQUAL))?;
|
||||
device.enable(&EventCode::EV_KEY(EV_KEY::KEY_MINUS))?;
|
||||
|
||||
// ADDED: Enable KEY_BACK
|
||||
device.enable(&EventCode::EV_KEY(EV_KEY::KEY_BACK))?;
|
||||
}
|
||||
|
||||
device.enable(&EventType::EV_REL)?;
|
||||
|
||||
Reference in New Issue
Block a user