From 1cd32232a88e75823476f2a2be1d2b05e1b1d1fa Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 13 Nov 2017 23:30:00 +0800 Subject: [PATCH] add public event and update code --- event/goEvent.h | 74 +---------------------------------- event/pub.h | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 73 deletions(-) create mode 100644 event/pub.h diff --git a/event/goEvent.h b/event/goEvent.h index d09c1d8..6094e10 100644 --- a/event/goEvent.h +++ b/event/goEvent.h @@ -17,81 +17,9 @@ #include #endif -#include "../base/os.h" +#include "pub.h" -#if defined(IS_MACOSX) - #include "hook/darwin/input_c.h" - #include "hook/darwin/hook_c.h" - #include "hook/darwin/event_c.h" - #include "hook/darwin/properties_c.h" -#elif defined(USE_X11) - //#define USE_XKBCOMMON 0 - #include "hook/x11/input_c.h" - #include "hook/x11/hook_c.h" - #include "hook/x11/event_c.h" - #include "hook/x11/properties_c.h" -#elif defined(IS_WINDOWS) - #include "hook/windows/input_c.h" - #include "hook/windows/hook_c.h" - #include "hook/windows/event_c.h" - #include "hook/windows/properties_c.h" -#endif -#include -#include -#include -#include -#include -#include "hook/iohook.h" - -int aStop(); -int aEvent(char *aevent); - -bool loggerProc(unsigned int level, const char *format, ...) { - bool status = false; - - va_list args; - switch (level) { - #ifdef USE_DEBUG - case LOG_LEVEL_DEBUG: - case LOG_LEVEL_INFO: - va_start(args, format); - status = vfprintf(stdout, format, args) >= 0; - va_end(args); - break; - #endif - - case LOG_LEVEL_WARN: - case LOG_LEVEL_ERROR: - va_start(args, format); - status = vfprintf(stderr, format, args) >= 0; - va_end(args); - break; - } - - return status; -} - -// NOTE: The following callback executes on the same thread that hook_run() is called -// from. - -struct _MEvent { - uint8_t id; - size_t mask; - uint16_t keychar; - // char *keychar; - size_t x; - uint8_t y; - uint8_t bytesPerPixel; -}; - -typedef struct _MEvent MEvent; -// typedef MMBitmap *MMBitmapRef; -char *cevent; -// uint16_t *cevent; -int cstatus = 1; - -MEvent mEvent; void dispatch_proc(iohook_event * const event) { char buffer[256] = { 0 }; size_t length = snprintf(buffer, sizeof(buffer), diff --git a/event/pub.h b/event/pub.h new file mode 100644 index 0000000..ba071c1 --- /dev/null +++ b/event/pub.h @@ -0,0 +1,100 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// The hook directory link from the https://github.com/robotn/gohook/ +// event/hook, you need to follow the relevant agreement and LICENSE. +// See the LICENSE file at the top-level directory of this distribution and at +// https://github.com/robotn/gohook/blob/master/LICENSE + +#include "../base/os.h" + +#if defined(IS_MACOSX) + #include "hook/darwin/input_c.h" + #include "hook/darwin/hook_c.h" + #include "hook/darwin/event_c.h" + #include "hook/darwin/properties_c.h" +#elif defined(USE_X11) + //#define USE_XKBCOMMON 0 + #include "hook/x11/input_c.h" + #include "hook/x11/hook_c.h" + #include "hook/x11/event_c.h" + #include "hook/x11/properties_c.h" +#elif defined(IS_WINDOWS) + #include "hook/windows/input_c.h" + #include "hook/windows/hook_c.h" + #include "hook/windows/event_c.h" + #include "hook/windows/properties_c.h" +#endif + +#include +#include +#include +#include +#include +#include "hook/iohook.h" + + +int vccode[100]; +int codesz; + +char *cevent; +int rrevent; +// uint16_t *cevent; +int cstatus = 1; + + +int aStop(); +int aEvent(char *aevent); +// int allEvent(char *aevent); +int allEvent(char *aevent, int vcode[], int size); + +// NOTE: The following callback executes on the same thread that hook_run() is called +// from. + +struct _MEvent { + uint8_t id; + size_t mask; + uint16_t keychar; + // char *keychar; + size_t x; + uint8_t y; + uint8_t bytesPerPixel; +}; + +typedef struct _MEvent MEvent; +// typedef MMBitmap *MMBitmapRef; + +MEvent mEvent; + + +bool loggerProc(unsigned int level, const char *format, ...) { + bool status = false; + + va_list args; + switch (level) { + #ifdef USE_DEBUG + case LOG_LEVEL_DEBUG: + case LOG_LEVEL_INFO: + va_start(args, format); + status = vfprintf(stdout, format, args) >= 0; + va_end(args); + break; + #endif + + case LOG_LEVEL_WARN: + case LOG_LEVEL_ERROR: + va_start(args, format); + status = vfprintf(stderr, format, args) >= 0; + va_end(args); + break; + } + + return status; +} \ No newline at end of file