#[cfg(target_os = "windows")] mod windows; #[cfg(target_os = "windows")] pub use crate::windows::*; use crate::keyboard::Key; use crate::mouse::Button; use serde::{Deserialize, Serialize}; pub mod keyboard; pub mod mouse; #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Eq, Hash)] pub enum EventListenType { Mouse, Keyboard, } #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] pub enum EventType { KeyPress(Key), KeyRelease(Key), MousePress(Button), MouseRelease(Button), MouseMoveTo { x: f64, y: f64 }, } // #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] // pub struct Event { // pub time: SystemTime, // pub event_type: EventType, // } // pub enum BlockInput { // Block, // DontBlock, // } // pub enum Bind { // NormalBind(BindHandler), // BlockBind(BlockBindHandler), // BlockableBind(BlockableBindHandler), // } // pub type BindHandler = Arc; // pub type BlockBindHandler = Arc; // pub type BlockableBindHandler = Arc BlockInput + Send + Sync + 'static>; // pub type EventBindMap = HashMap; // pub static EVENT_BINDS: Lazy> = Lazy::new(|| Mutex::new(EventBindMap::new())); pub struct Robot; // impl Robot { // pub fn bind(listen_type: EventListenType, callback: F) { // EVENT_BINDS // .lock() // .unwrap() // .insert(listen_type, Bind::NormalBind(Arc::new(callback))); // } // pub fn block_bind( // listen_type: EventListenType, // callback: F, // ) { // EVENT_BINDS // .lock() // .unwrap() // .insert(listen_type, Bind::BlockBind(Arc::new(callback))); // } // pub fn blockable_bind BlockInput + Send + Sync + 'static>( // listen_type: EventListenType, // callback: F, // ) { // EVENT_BINDS // .lock() // .unwrap() // .insert(listen_type, Bind::BlockableBind(Arc::new(callback))); // } // pub fn unbind(listen_type: EventListenType) { // EVENT_BINDS.lock().unwrap().remove(&listen_type); // } // }