remove mouse support
All checks were successful
Upload release / build (push) Successful in 29s

This commit is contained in:
Mylloon 2024-10-07 22:14:33 +02:00
parent 39dadd8cfa
commit 1f5e245541
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 8 additions and 23 deletions

View file

@ -15,7 +15,7 @@ function script_load()
ffi.cdef[[
void start_hook(void);
void stop_hook(void);
time_t last_time_input_received(void);
long long last_input_received(void);
]]
monitor = ffi.load(script_path() .. "monitor.dll")
@ -25,6 +25,7 @@ end
function script_unload()
obs.timer_remove(check_restart)
obs.timer_remove(check_idle)
monitor.stop_hook()
end
function check_restart()
@ -34,7 +35,7 @@ end
function check_idle()
local current_time = os.time()
local last_input_time = monitor.last_time_input_received()
local last_input_time = monitor.last_input_received()
if current_time - last_input_time >= idle_time then
monitor.stop_hook()

View file

@ -1,31 +1,20 @@
#include <stdatomic.h>
#include <time.h>
#include <windows.h>
static atomic_llong last_input_time = 0;
static long long last_input_time = 0;
HHOOK hKeyboardHook;
HHOOK hMouseHook;
HHOOK hKeyboardHook = NULL;
LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION) {
atomic_store(&last_input_time, time(NULL));
last_input_time = time(NULL);
}
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
}
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION) {
atomic_store(&last_input_time, time(NULL));
}
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
}
__declspec(dllexport) void start_hook(void) {
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, NULL, 0);
hMouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, NULL, 0);
}
__declspec(dllexport) void stop_hook(void) {
@ -33,13 +22,8 @@ __declspec(dllexport) void stop_hook(void) {
UnhookWindowsHookEx(hKeyboardHook);
hKeyboardHook = NULL;
}
if (hMouseHook) {
UnhookWindowsHookEx(hMouseHook);
hMouseHook = NULL;
}
}
__declspec(dllexport) time_t last_time_input_received(void) {
return atomic_load(&last_input_time);
__declspec(dllexport) long long last_input_received(void) {
return last_input_time;
}