Expand description
extern crate core_foundation;
use core_foundation::runloop::{kCFRunLoopCommonModes, CFRunLoop};
use core_graphics::event::{CGEventTap, CGEventTapLocation, CGEventTapPlacement, CGEventTapOptions, CGEventType};
let current = CFRunLoop::get_current();
match CGEventTap::new(
CGEventTapLocation::HID,
CGEventTapPlacement::HeadInsertEventTap,
CGEventTapOptions::Default,
vec![CGEventType::MouseMoved],
|_a, _b, d| {
println!("{:?}", d.location());
None
},
) {
Ok(tap) => unsafe {
let loop_source = tap
.mach_port
.create_runloop_source(0)
.expect("Somethings is bad ");
current.add_source(&loop_source, kCFRunLoopCommonModes);
tap.enable();
CFRunLoop::run_current();
},
Err(_) => (assert!(false)),
}
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.