Update: push the custom tm code

This commit is contained in:
vcaesar 2025-05-21 20:45:42 -07:00
parent a8f8a8fb20
commit c49f850b47
2 changed files with 7 additions and 3 deletions

View File

@ -71,7 +71,6 @@ func AddEvents(key string, arr ...string) bool {
if l > 0 { if l > 0 {
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
ukey := Keycode[arr[i]] ukey := Keycode[arr[i]]
if e.Kind == KeyHold && e.Keycode == ukey { if e.Kind == KeyHold && e.Keycode == ukey {
k++ k++
} }

View File

@ -234,10 +234,15 @@ func KeychartoRawcode(kc string) uint16 {
// Start adds global event hook to OS // Start adds global event hook to OS
// returns event channel // returns event channel
func Start() chan Event { func Start(tm ...int) chan Event {
ev = make(chan Event, 1024) ev = make(chan Event, 1024)
go C.start_ev() go C.start_ev()
tm1 := 50
if len(tm) > 0 {
tm1 = tm[0]
}
asyncon = true asyncon = true
go func() { go func() {
for { for {
@ -246,7 +251,7 @@ func Start() chan Event {
} }
C.pollEv() 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 //todo: find smallest time that does not destroy the cpu utilization
} }
}() }()