fix: use two numbers to send current time

main
paring 2022-11-26 18:41:06 +09:00
parent 663da66138
commit d93311a4fb
Signed by: pikokr
GPG Key ID: 2C097B03E9D823C4
1 changed files with 8 additions and 3 deletions

View File

@ -16,7 +16,8 @@ pub enum NativeEventType {
#[repr(C)] #[repr(C)]
pub struct NativeEvent { pub struct NativeEvent {
pub time: usize, pub time_sec: u64,
pub time_nsec: u32,
pub event_type: NativeEventType, pub event_type: NativeEventType,
pub vkey: u16, pub vkey: u16,
pub keycode: u16, pub keycode: u16,
@ -43,18 +44,22 @@ pub extern "C" fn start_hook(callback: extern "C" fn(NativeEvent)) -> *const c_c
} }
if let Err(e) = skyhook::run(move |event| { if let Err(e) = skyhook::run(move |event| {
let (sec, nsec) = get_time(event.time);
let event = match event.data { let event = match event.data {
skyhook::types::EventData::KeyPress(label, key) => NativeEvent { skyhook::types::EventData::KeyPress(label, key) => NativeEvent {
time: get_time(event.time),
event_type: NativeEventType::KeyPressed, event_type: NativeEventType::KeyPressed,
vkey: label as u16, vkey: label as u16,
keycode: key, keycode: key,
time_sec: sec,
time_nsec: nsec,
}, },
skyhook::types::EventData::KeyRelease(label, key) => NativeEvent { skyhook::types::EventData::KeyRelease(label, key) => NativeEvent {
time: get_time(event.time),
event_type: NativeEventType::KeyReleased, event_type: NativeEventType::KeyReleased,
vkey: label as u16, vkey: label as u16,
keycode: key, keycode: key,
time_sec: sec,
time_nsec: nsec,
}, },
}; };
send_callback(event); send_callback(event);