Compare commits
1 Commits
main
...
fix/data-s
Author | SHA1 | Date |
---|---|---|
paring | 2d2215ce96 |
|
@ -4,9 +4,8 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.23"
|
|
||||||
skyhook = { path = "./vendor/skyhook/skyhook" }
|
skyhook = { path = "./vendor/skyhook/skyhook" }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "skyhook"
|
name = "skyhook"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["dylib"]
|
||||||
|
|
19
src/lib.rs
19
src/lib.rs
|
@ -1,11 +1,9 @@
|
||||||
use std::{
|
use std::{
|
||||||
ffi::{c_char, CString},
|
ffi::{c_char, CString},
|
||||||
ptr::null,
|
ptr::null,
|
||||||
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
|
||||||
|
|
||||||
extern crate chrono;
|
|
||||||
extern crate skyhook;
|
extern crate skyhook;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -16,7 +14,7 @@ pub enum NativeEventType {
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct NativeEvent {
|
pub struct NativeEvent {
|
||||||
pub time_sec: i64,
|
pub time_sec: u64,
|
||||||
pub time_nsec: u32,
|
pub time_nsec: u32,
|
||||||
pub event_type: NativeEventType,
|
pub event_type: NativeEventType,
|
||||||
pub vkey: u16,
|
pub vkey: u16,
|
||||||
|
@ -33,8 +31,12 @@ fn send_callback(ev: NativeEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_time(time: NaiveDateTime) -> (i64, u32) {
|
fn get_time(time: SystemTime) -> (u64, u32) {
|
||||||
(time.timestamp(), time.timestamp_subsec_nanos())
|
let dur = time
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.expect("Unable to calculate duration");
|
||||||
|
|
||||||
|
(dur.as_secs(), dur.subsec_nanos())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -80,8 +82,3 @@ pub extern "C" fn stop_hook() -> *const c_char {
|
||||||
|
|
||||||
null()
|
null()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn hook_is_running() -> bool {
|
|
||||||
skyhook::is_running()
|
|
||||||
}
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ebf908ad35cfcb9b2af3b027fcff6c859e3c1d6f
|
Subproject commit 530166d47103698a2613e42b47f8c89a91c2363b
|
Reference in New Issue