2018-09-18 02:09:59 +08:00
|
|
|
// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2018-09-17 07:29:13 +08:00
|
|
|
package hook
|
|
|
|
|
|
|
|
/*
|
|
|
|
#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations
|
2018-09-18 02:17:14 +08:00
|
|
|
#cgo darwin LDFLAGS: -framework Cocoa
|
2018-09-18 01:30:41 +08:00
|
|
|
|
2018-09-17 07:29:13 +08:00
|
|
|
#cgo linux CFLAGS:-I/usr/src
|
2018-09-17 07:43:30 +08:00
|
|
|
#cgo linux LDFLAGS: -L/usr/src -lX11 -lXtst
|
|
|
|
#cgo linux LDFLAGS: -lX11-xcb -lxcb -lxcb-xkb -lxkbcommon -lxkbcommon-x11
|
2018-09-18 01:30:41 +08:00
|
|
|
//#cgo windows LDFLAGS: -lgdi32 -luser32
|
2018-09-17 07:29:13 +08:00
|
|
|
|
|
|
|
#include "event/goEvent.h"
|
|
|
|
// #include "event/hook_async.h"
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
2018-09-18 02:17:14 +08:00
|
|
|
import (
|
2018-09-17 07:29:13 +08:00
|
|
|
// "fmt"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AddEvent add event listener
|
|
|
|
func AddEvent(key string) int {
|
|
|
|
cs := C.CString(key)
|
2018-09-17 08:17:40 +08:00
|
|
|
defer C.free(unsafe.Pointer(cs))
|
2018-09-18 02:17:14 +08:00
|
|
|
|
2018-09-17 07:29:13 +08:00
|
|
|
eve := C.add_event(cs)
|
|
|
|
geve := int(eve)
|
|
|
|
|
|
|
|
return geve
|
|
|
|
}
|
|
|
|
|
|
|
|
// StopEvent stop event listener
|
|
|
|
func StopEvent() {
|
|
|
|
C.stop_event()
|
2018-09-18 02:17:14 +08:00
|
|
|
}
|