#[repr(C)] pub enum EventType { Press, Release, } #[repr(C)] pub struct Event { event_type: EventType, key: i32, } static mut SHOULD_BREAK: bool = false; static mut GLOBAL_HOOK: Option = None; static mut STARTED: bool = false; mod windows; #[no_mangle] pub extern "C" fn run(callback: extern "C" fn(Event)) { unsafe { GLOBAL_HOOK = Some(callback); } if unsafe { STARTED } { return; } unsafe { STARTED = true; } std::thread::spawn(|| { windows::install_hooks(); windows::process_message(); }); } pub extern "C" fn stop() { unsafe { SHOULD_BREAK = true; } }