use crate::error::Result;
use crate::hotkey::{HotkeyListener, HotkeyRegistry};
use crate::types::*;
use std::sync::{Arc, RwLock};
pub(crate) trait Simulation: Send {
fn send_key(&mut self, key: Key, action: Action) -> Result<()>;
fn send_button(&mut self, button: Button, action: Action) -> Result<()>;
fn send_movement(&mut self, movement: Movement) -> Result<()>;
fn send_scroll(&mut self, scroll: Scroll) -> Result<()>;
fn send_batch(&mut self, batch: Vec<InputEvent>) -> Result<()>;
}
pub struct BackendListener {
listener: Arc<HotkeyListener>,
}
impl BackendListener {
pub(crate) fn new(registry: Arc<RwLock<HotkeyRegistry>>) -> Self {
Self {
listener: Arc::new(HotkeyListener::new(registry)),
}
}
}
pub(crate) trait Listener: Send + Sync {
fn start(&self) -> Result<()>;
fn stop(&self);
}
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
pub(crate) use linux::Backend;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "windows")]
pub(crate) use windows::Backend;