From d5c553b760f847c2324036fbe7a592bb8568c4bb Mon Sep 17 00:00:00 2001 From: vCaesar <vzvway@gmail.com> Date: Thu, 5 Jan 2017 19:57:03 +0800 Subject: [PATCH] Drop c11 to c99 --- event/hook/darwin/hook_c.h | 4 ++-- event/hook/darwin/properties_c.h | 3 ++- event/hook/x11/event_c.h | 13 ++++++++----- event/hook/x11/hook_c.h | 3 ++- event/hook/x11/input_c.h | 3 ++- event/hook/x11/properties_c.h | 6 ++++-- robotgo.go | 3 ++- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/event/hook/darwin/hook_c.h b/event/hook/darwin/hook_c.h index 94135e5..f2bf6c4 100644 --- a/event/hook/darwin/hook_c.h +++ b/event/hook/darwin/hook_c.h @@ -417,8 +417,8 @@ static inline void process_key_pressed(uint64_t timestamp, CGEventRef event_ref) else { keycode_to_lookup(tis_message); } - - for (unsigned int i = 0; i < tis_message->length; i++) { + unsigned int i; + for (i= 0; i < tis_message->length; i++) { // Populate key typed event. event.time = timestamp; event.reserved = 0x00; diff --git a/event/hook/darwin/properties_c.h b/event/hook/darwin/properties_c.h index ceea967..bee4caf 100644 --- a/event/hook/darwin/properties_c.h +++ b/event/hook/darwin/properties_c.h @@ -44,7 +44,8 @@ IOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) { // Allocate memory for the number of screens found. screens = malloc(sizeof(screen_data) * (*count)); if (screens != NULL) { - for (uint8_t i = 0; i < *count; i++) { + uint8_t i; + for (i = 0; i < *count; i++) { //size_t width = CGDisplayPixelsWide(display_ids[i]); //size_t height = CGDisplayPixelsHigh(display_ids[i]); CGRect boundsDisp = CGDisplayBounds(display_ids[i]); diff --git a/event/hook/x11/event_c.h b/event/hook/x11/event_c.h index 4109780..e469d3d 100644 --- a/event/hook/x11/event_c.h +++ b/event/hook/x11/event_c.h @@ -319,13 +319,15 @@ IOHOOK_API void hook_post_event(iohook_event * const event) { #ifdef USE_XTEST // XTest does not have modifier support, so we fake it by depressing the // appropriate modifier keys. - for (unsigned int i = 0; i < sizeof(keymask_lookup) / sizeof(KeySym); i++) { + unsigned int i; + for (i = 0; i < sizeof(keymask_lookup) / sizeof(KeySym); i++) { if (event->mask & 1 << i) { XTestFakeKeyEvent(properties_disp, XKeysymToKeycode(properties_disp, keymask_lookup[i]), True, 0); } } - for (unsigned int i = 0; i < sizeof(btnmask_lookup) / sizeof(unsigned int); i++) { + unsigned int i; + for (i = 0; i < sizeof(btnmask_lookup) / sizeof(unsigned int); i++) { if (event->mask & btnmask_lookup[i]) { XTestFakeButtonEvent(properties_disp, i + 1, True, 0); } @@ -364,13 +366,14 @@ IOHOOK_API void hook_post_event(iohook_event * const event) { #ifdef USE_XTEST // Release the previously held modifier keys used to fake the event mask. - for (unsigned int i = 0; i < sizeof(keymask_lookup) / sizeof(KeySym); i++) { + unsigned int i ; + for (i= 0; i < sizeof(keymask_lookup) / sizeof(KeySym); i++) { if (event->mask & 1 << i) { XTestFakeKeyEvent(properties_disp, XKeysymToKeycode(properties_disp, keymask_lookup[i]), False, 0); } } - - for (unsigned int i = 0; i < sizeof(btnmask_lookup) / sizeof(unsigned int); i++) { + unsigned int i; + for (i = 0; i < sizeof(btnmask_lookup) / sizeof(unsigned int); i++) { if (event->mask & btnmask_lookup[i]) { XTestFakeButtonEvent(properties_disp, i + 1, False, 0); } diff --git a/event/hook/x11/hook_c.h b/event/hook/x11/hook_c.h index d2a2825..5805da6 100644 --- a/event/hook/x11/hook_c.h +++ b/event/hook/x11/hook_c.h @@ -354,7 +354,8 @@ void hook_event_proc(XPointer closeure, XRecordInterceptData *recorded_data) { count = keysym_to_unicode(keysym, buffer, sizeof(buffer) / sizeof(uint16_t)); #endif - for (unsigned int i = 0; i < count; i++) { + unsigned int i; + for (i = 0; i < count; i++) { // Populate key typed event. event.time = timestamp; event.reserved = 0x00; diff --git a/event/hook/x11/input_c.h b/event/hook/x11/input_c.h index da6c76c..1e77884 100644 --- a/event/hook/x11/input_c.h +++ b/event/hook/x11/input_c.h @@ -1927,7 +1927,8 @@ void load_input_helper(Display *disp) { keysym_per_keycode--; // Loop over the modifier map to find out if/where shift and caps locks are set. - for (int i = LockMapIndex; i < LockMapIndex + modifierMap->max_keypermod && !is_caps_lock; i++) { + int i; + for (i = LockMapIndex; i < LockMapIndex + modifierMap->max_keypermod && !is_caps_lock; i++) { if (capsLock != 0 && modifierMap->modifiermap[i] == capsLock) { is_caps_lock = true; is_shift_lock = false; diff --git a/event/hook/x11/properties_c.h b/event/hook/x11/properties_c.h index 5adbea7..1da328a 100644 --- a/event/hook/x11/properties_c.h +++ b/event/hook/x11/properties_c.h @@ -132,7 +132,8 @@ IOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) { screens = malloc(sizeof(screen_data) * xine_count); if (screens != NULL) { - for (int i = 0; i < xine_count; i++) { + int i; + for (i = 0; i < xine_count; i++) { screens[i] = (screen_data) { .number = xine_info[i].screen_number, .x = xine_info[i].x_org, @@ -163,7 +164,8 @@ IOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) { screens = malloc(sizeof(screen_data) * xrandr_count); if (screens != NULL) { - for (int i = 0; i < xrandr_count; i++) { + int i; + for (i = 0; i < xrandr_count; i++) { XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(properties_disp, xrandr_resources, xrandr_resources->crtcs[i]); if (crtc_info != NULL) { diff --git a/robotgo.go b/robotgo.go index ffa53c3..eb294c1 100644 --- a/robotgo.go +++ b/robotgo.go @@ -15,7 +15,8 @@ package robotgo #cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations -I/usr/local/opt/libpng/include -I/usr/local/opt/zlib/include #cgo darwin LDFLAGS: -framework Cocoa -framework OpenGL -framework IOKit -framework Carbon -framework CoreFoundation -L/usr/local/opt/libpng/lib -lpng -L/usr/local/opt/zlib/lib -lz //#elif defined(USE_X11) - #cgo linux CFLAGS:-std=c11 -I/usr/src + //drop -std=c11 + #cgo linux CFLAGS:-I/usr/src #cgo linux LDFLAGS:-L/usr/src -lpng -lz -lX11 -lXtst -lX11-xcb -lxcb -lxcb-xkb -lxkbcommon -lxkbcommon-x11 -lm //#endif #cgo windows LDFLAGS: -lgdi32 -luser32 -lpng -lz