feat: is_running for linux

v1
paring 2023-05-28 13:34:26 +09:00
parent 86782a4f9a
commit cdca6f026c
Signed by: pikokr
GPG Key ID: 8C7ABCEF704FD728
5 changed files with 30 additions and 0 deletions

View File

@ -20,3 +20,7 @@ pub fn run(callback: fn(Event)) -> Result<(), Error> {
pub fn stop() -> Result<(), Error> {
platforms::stop()
}
pub fn is_running() -> bool {
platforms::is_running()
}

View File

@ -158,3 +158,7 @@ pub fn stop() -> Result<(), Error> {
message: "Hook cannot be stopped before starting.".into(),
})
}
pub fn is_running() -> bool {
unsafe { STARTED }
}

View File

@ -53,3 +53,11 @@ pub fn stop() -> Result<(), Error> {
Ok(())
}
pub fn is_running() -> bool {
match unsafe { &SELECTED_METHOD } {
LinuxHookMethod::InputDev => inputdev::is_running(),
LinuxHookMethod::XInput => xinput::is_running(),
_ => false,
}
}

View File

@ -156,6 +156,16 @@ pub fn stop() -> Result<(), Error> {
Ok(())
}
pub fn is_running() -> bool {
unsafe {
if let Some(_) = &RECORDER {
true
} else {
false
}
}
}
unsafe extern "C" fn record_callback(_: *mut i8, raw_data: *mut xrecord::XRecordInterceptData) {
let data = &*raw_data;

View File

@ -15,6 +15,10 @@ pub fn stop() -> Result<(), Error> {
linux::stop()
}
pub fn is_running() -> bool {
linux::is_running()
}
// ------- WINDOWS -------
#[cfg(target_os = "windows")]