espanso/src/main.rs

26 lines
614 B
Rust
Raw Normal View History

2019-08-30 16:32:10 +00:00
extern fn keypress_callback(raw_buffer: *const i32, len: i32) {
unsafe {
let buffer = std::slice::from_raw_parts(raw_buffer, len as usize);
println!("{}", std::char::from_u32(buffer[0] as u32).unwrap());
}
}
2019-08-30 12:33:40 +00:00
#[link(name="winbridge", kind="static")]
extern {
fn initialize();
fn eventloop();
2019-08-30 16:32:10 +00:00
fn register_keypress_callback(cb: extern fn(*const i32, i32));
2019-08-30 07:58:54 +00:00
}
2019-08-30 12:33:40 +00:00
fn main() {
println!("Hello, world from Rust!");
// calling the function from foo library
unsafe {
initialize();
2019-08-30 16:32:10 +00:00
register_keypress_callback(keypress_callback);
eventloop();
2019-08-30 12:33:40 +00:00
};
}