From c49f850b47ae4f497f1715df3493b82be02b5385 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Wed, 21 May 2025 20:45:42 -0700 Subject: [PATCH] Update: push the custom tm code --- event.go | 1 - hook.go | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/event.go b/event.go index 3c8f01c..1370ec5 100644 --- a/event.go +++ b/event.go @@ -71,7 +71,6 @@ func AddEvents(key string, arr ...string) bool { if l > 0 { for i := 0; i < l; i++ { ukey := Keycode[arr[i]] - if e.Kind == KeyHold && e.Keycode == ukey { k++ } diff --git a/hook.go b/hook.go index f30e1f2..e3b4698 100644 --- a/hook.go +++ b/hook.go @@ -234,10 +234,15 @@ func KeychartoRawcode(kc string) uint16 { // Start adds global event hook to OS // returns event channel -func Start() chan Event { +func Start(tm ...int) chan Event { ev = make(chan Event, 1024) go C.start_ev() + tm1 := 50 + if len(tm) > 0 { + tm1 = tm[0] + } + asyncon = true go func() { for { @@ -246,7 +251,7 @@ func Start() chan Event { } C.pollEv() - time.Sleep(time.Millisecond * 50) + time.Sleep(time.Millisecond * time.Duration(tm1)) //todo: find smallest time that does not destroy the cpu utilization } }()