This commit is contained in:
Robin Appelman 2025-06-09 17:23:49 +02:00
commit 831345ea74
3 changed files with 241 additions and 268 deletions

View file

@ -45,7 +45,6 @@ use std::collections::HashSet;
use std::fmt::{self, Debug, Display, Formatter};
use std::path::PathBuf;
use std::str::FromStr;
use thiserror::Error;
mod keycodes;
@ -56,12 +55,19 @@ mod listener;
pub use listener::ShortcutListener;
/// Error emitted when an input device can't be opened
#[derive(Debug, Clone, Error)]
#[error("Failed to open device {device:?}")]
#[derive(Debug, Clone)]
pub struct DeviceOpenError {
pub device: PathBuf,
}
impl Display for DeviceOpenError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "Failed to open device {:?}", self.device)
}
}
impl std::error::Error for DeviceOpenError {}
/// Modifier key for shortcuts
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Display, FromStr)]
#[repr(u8)]