diff --git a/hook.go b/hook.go index e69de29..04458a2 100644 --- a/hook.go +++ b/hook.go @@ -0,0 +1,34 @@ +package hook + +/* +#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations +#cgo darwin LDFLAGS: -framework Cocoa +#cgo linux CFLAGS:-I/usr/src +#cgo linux LDFLAGS: -lX11-xcb -lxcb -lxcb-xkb -lxkbcommon -lxkbcommon-x11 -lm +#cgo windows LDFLAGS: -lgdi32 -luser32 + +#include "event/goEvent.h" +// #include "event/hook_async.h" +*/ +import "C" + +import( + // "fmt" + "unsafe" +) + +// AddEvent add event listener +func AddEvent(key string) int { + cs := C.CString(key) + + eve := C.add_event(cs) + geve := int(eve) + + defer C.free(unsafe.Pointer(cs)) + return geve +} + +// StopEvent stop event listener +func StopEvent() { + C.stop_event() +} \ No newline at end of file diff --git a/hook/darwin/input.h b/hook/darwin/input.h index 23977e5..a841070 100644 --- a/hook/darwin/input.h +++ b/hook/darwin/input.h @@ -5,16 +5,16 @@ #include #include // For HIToolbox kVK_ keycodes and TIS funcitons. #ifdef USE_IOKIT - #include +#include #endif #include #ifndef USE_IOKIT // Some of the system key codes that are needed from IOKit. -// #define NX_KEYTYPE_SOUND_UP 0x00 -// #define NX_KEYTYPE_SOUND_DOWN 0x01 -// #define NX_KEYTYPE_MUTE 0x07 +#define NX_KEYTYPE_SOUND_UP 0x00 +#define NX_KEYTYPE_SOUND_DOWN 0x01 +#define NX_KEYTYPE_MUTE 0x07 /* Display controls... #define NX_KEYTYPE_BRIGHTNESS_UP 0x02 @@ -26,18 +26,18 @@ #define NX_KEYTYPE_ILLUMINATION_TOGGLE 0x17 */ -// #define NX_KEYTYPE_CAPS_LOCK 0x04 -// #define NX_KEYTYPE_HELP 0x05 -// #define NX_POWER_KEY 0x06 +#define NX_KEYTYPE_CAPS_LOCK 0x04 +//#define NX_KEYTYPE_HELP 0x05 +#define NX_POWER_KEY 0x06 -// #define NX_KEYTYPE_EJECT 0x0E -// #define NX_KEYTYPE_PLAY 0x10 -// #define NX_KEYTYPE_NEXT 0x12 -// #define NX_KEYTYPE_PREVIOUS 0x13 +#define NX_KEYTYPE_EJECT 0x0E +#define NX_KEYTYPE_PLAY 0x10 +#define NX_KEYTYPE_NEXT 0x12 +#define NX_KEYTYPE_PREVIOUS 0x13 /* There is no official fast-forward or rewind scan code support.*/ -// #define NX_KEYTYPE_FAST 0x14 -// #define NX_KEYTYPE_REWIND 0x15 +#define NX_KEYTYPE_FAST 0x14 +#define NX_KEYTYPE_REWIND 0x15 #endif diff --git a/test/main.go b/test/main.go index 0fe8d28..d3fe134 100644 --- a/test/main.go +++ b/test/main.go @@ -3,11 +3,11 @@ package main import ( "fmt" - "go-vgo/robotn/gohook" + "github.com/robotn/gohook" ) func main() { - hook.AsyncHook() + // hook.AsyncHook() veve := hook.AddEvent("v") if veve == 0 { fmt.Println("v...")