1
0

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:
2025-03-28 08:24:40 +01:00
parent bd805cb821
commit 399f359713
2 changed files with 6 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ use crate::controller::{ControlMode, ControlModeMeta};
use crate::dial_device::DialHaptics; use crate::dial_device::DialHaptics;
use crate::error::{Error, Result}; use crate::error::{Error, Result};
use crate::fake_input; use crate::fake_input;
use evdev_rs::enums::EV_KEY;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread::{self, JoinHandle}; use std::thread::{self, JoinHandle};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@@ -92,16 +93,12 @@ impl ControlMode for ScrollMT {
} }
fn on_btn_press(&mut self, _: &DialHaptics) -> Result<()> { 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(()) Ok(())
} }
fn on_btn_release(&mut self, _haptics: &DialHaptics) -> Result<()> { fn on_btn_release(&mut self, _haptics: &DialHaptics) -> Result<()> {
// Restart multitouch scrolling on button release // Send "previous page" signal on button press
fake_input::scroll_mt_start().map_err(Error::Evdev)?; fake_input::key_click(&[EV_KEY::KEY_BACK]).map_err(Error::Evdev)?;
*self.is_scrolling.lock().unwrap() = true;
Ok(()) Ok(())
} }

View File

@@ -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_SPACE))?;
device.enable(&EventCode::EV_KEY(EV_KEY::KEY_EQUAL))?; device.enable(&EventCode::EV_KEY(EV_KEY::KEY_EQUAL))?;
device.enable(&EventCode::EV_KEY(EV_KEY::KEY_MINUS))?; 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)?; device.enable(&EventType::EV_REL)?;