add example and update code style

This commit is contained in:
vcaesar 2019-02-19 11:32:48 -04:00
parent 1da30b1d41
commit 9fa8b6c408
6 changed files with 49 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import (
func main() {
EvChan := hook.Start()
defer hook.End()
for ev := range EvChan {
fmt.Println(ev)
}

View File

@ -34,7 +34,7 @@ environment:
PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH%
# - COMPILER: MINGW_W64
# ARCHITECTURE: x64
GOVERSION: 1.11.4
GOVERSION: 1.11.5
# GOPATH: c:\gopath
# scripts that run after cloning repository

View File

@ -34,7 +34,9 @@ void pollEv(){
if (events == NULL) return;
for (;eb_chan_buf_len(events)!=0;) {
char* tmp;
if( eb_chan_try_recv(events,(const void**) &tmp) == eb_chan_res_ok ){
if (eb_chan_try_recv(events, (const void**) &tmp)
== eb_chan_res_ok) {
// send a char
go_send(tmp);
free(tmp);
} else {

40
example/main.go Normal file
View File

@ -0,0 +1,40 @@
package main
import (
"fmt"
"github.com/robotn/gohook"
)
func add() {
s := hook.Start()
defer hook.End()
ct := false
for {
i := <-s
if i.Kind == hook.KeyHold && i.Rawcode == 59 {
ct = true
}
if ct && i.Rawcode == 12 {
break
}
}
}
func base() {
EvChan := hook.Start()
defer hook.End()
for ev := range EvChan {
fmt.Println(ev)
}
}
func main() {
base()
add()
}

View File

@ -175,6 +175,7 @@ var (
251: "unlock trackpad (Chrome/Edge)",
255: "toggle touchpad",
}
keytoraw = map[string]uint16{
"error": 0,
"break": 3,

View File

@ -10,6 +10,7 @@ import (
func main() {
s := hook.Start()
defer hook.End()
tout := time.After(time.Hour * 2)
done := false
for !done {
@ -19,6 +20,7 @@ func main() {
if i.Keychar == 'q' {
tout = time.After(0)
}
fmt.Printf("%v key: %c:%v\n", i.Kind, i.Keychar, i.Rawcode)
} else if i.Kind >= hook.MouseDown && i.Kind < hook.MouseWheel {
//fmt.Printf("x: %v, y: %v, button: %v\n", i.X, i.Y, i.Button)
@ -27,6 +29,7 @@ func main() {
} else {
fmt.Printf("%+v\n", i)
}
case <-tout:
fmt.Print("Done.")
done = true