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 {
|
2019-08-30 15:58:18 +00:00
|
|
|
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 {
|
2019-08-30 15:58:18 +00:00
|
|
|
initialize();
|
2019-08-30 16:32:10 +00:00
|
|
|
|
|
|
|
register_keypress_callback(keypress_callback);
|
|
|
|
|
2019-08-30 15:58:18 +00:00
|
|
|
eventloop();
|
2019-08-30 12:33:40 +00:00
|
|
|
};
|
|
|
|
}
|