mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Simplify api & Add Move
This commit is contained in:
parent
c23bca9eca
commit
62a37bb9e2
1
doc.md
1
doc.md
@ -15,6 +15,7 @@
|
||||
|
||||
#####[SetMouseDelay](#SetMouseDelay)
|
||||
#####[MoveMouse](#MoveMouse)
|
||||
#####[Move](#MoveMouse)(Equivalent to MoveMouse)
|
||||
#####[MoveMouseSmooth](#MoveMouseSmooth)
|
||||
#####[MouseClick](#MouseClick)
|
||||
#####[Click](#MouseClick)(Equivalent to MouseClick)
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "hook/uiohook.h"
|
||||
#include "hook/iohook.h"
|
||||
|
||||
int aStop();
|
||||
int aEvent(char *aevent);
|
||||
@ -87,7 +87,7 @@ char *cevent;
|
||||
int cstatus=1;
|
||||
|
||||
MEvent mEvent;
|
||||
void dispatch_proc(uiohook_event * const event) {
|
||||
void dispatch_proc(iohook_event * const event) {
|
||||
char buffer[256] = { 0 };
|
||||
size_t length = snprintf(buffer, sizeof(buffer),
|
||||
"id=%i,when=%" PRIu64 ",mask=0x%X",
|
||||
@ -100,17 +100,17 @@ void dispatch_proc(uiohook_event * const event) {
|
||||
int status = hook_stop();
|
||||
switch (status) {
|
||||
// System level errors.
|
||||
case UIOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
case IOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to allocate memory. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_X_RECORD_GET_CONTEXT:
|
||||
case IOHOOK_ERROR_X_RECORD_GET_CONTEXT:
|
||||
// NOTE This is the only platform specific error that occurs on hook_stop().
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to get XRecord context. (%#X)", status);
|
||||
break;
|
||||
|
||||
// Default error.
|
||||
case UIOHOOK_FAILURE:
|
||||
case IOHOOK_FAILURE:
|
||||
default:
|
||||
logger_proc(LOG_LEVEL_ERROR, "An unknown hook error occurred. (%#X)", status);
|
||||
break;
|
||||
@ -205,74 +205,74 @@ int aEvent(char *aevent) {
|
||||
// Set the logger callback for library output.
|
||||
hook_set_logger_proc(&logger_proc);
|
||||
|
||||
// Set the event callback for uiohook events.
|
||||
// Set the event callback for IOhook events.
|
||||
hook_set_dispatch_proc(&dispatch_proc);
|
||||
// Start the hook and block.
|
||||
// NOTE If EVENT_HOOK_ENABLED was delivered, the status will always succeed.
|
||||
int status = hook_run();
|
||||
|
||||
switch (status) {
|
||||
case UIOHOOK_SUCCESS:
|
||||
case IOHOOK_SUCCESS:
|
||||
// Everything is ok.
|
||||
break;
|
||||
|
||||
// System level errors.
|
||||
case UIOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
case IOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to allocate memory. (%#X)", status);
|
||||
break;
|
||||
|
||||
|
||||
// X11 specific errors.
|
||||
case UIOHOOK_ERROR_X_OPEN_DISPLAY:
|
||||
case IOHOOK_ERROR_X_OPEN_DISPLAY:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to open X11 display. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_X_RECORD_NOT_FOUND:
|
||||
case IOHOOK_ERROR_X_RECORD_NOT_FOUND:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Unable to locate XRecord extension. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_X_RECORD_ALLOC_RANGE:
|
||||
case IOHOOK_ERROR_X_RECORD_ALLOC_RANGE:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Unable to allocate XRecord range. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_X_RECORD_CREATE_CONTEXT:
|
||||
case IOHOOK_ERROR_X_RECORD_CREATE_CONTEXT:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Unable to allocate XRecord context. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT:
|
||||
case IOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to enable XRecord context. (%#X)", status);
|
||||
break;
|
||||
|
||||
|
||||
// Windows specific errors.
|
||||
case UIOHOOK_ERROR_SET_WINDOWS_HOOK_EX:
|
||||
case IOHOOK_ERROR_SET_WINDOWS_HOOK_EX:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to register low level windows hook. (%#X)", status);
|
||||
break;
|
||||
|
||||
|
||||
// Darwin specific errors.
|
||||
case UIOHOOK_ERROR_AXAPI_DISABLED:
|
||||
case IOHOOK_ERROR_AXAPI_DISABLED:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to enable access for assistive devices. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_CREATE_EVENT_PORT:
|
||||
case IOHOOK_ERROR_CREATE_EVENT_PORT:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to create apple event port. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE:
|
||||
case IOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to create apple run loop source. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_GET_RUNLOOP:
|
||||
case IOHOOK_ERROR_GET_RUNLOOP:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to acquire apple run loop. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_CREATE_OBSERVER:
|
||||
case IOHOOK_ERROR_CREATE_OBSERVER:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to create apple run loop observer. (%#X)", status);
|
||||
break;
|
||||
|
||||
// Default error.
|
||||
case UIOHOOK_FAILURE:
|
||||
case IOHOOK_FAILURE:
|
||||
default:
|
||||
logger_proc(LOG_LEVEL_ERROR, "An unknown hook error occurred. (%#X)", status);
|
||||
break;
|
||||
@ -287,17 +287,17 @@ int aStop(){
|
||||
int status = hook_stop();
|
||||
switch (status) {
|
||||
// System level errors.
|
||||
case UIOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
case IOHOOK_ERROR_OUT_OF_MEMORY:
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to allocate memory. (%#X)", status);
|
||||
break;
|
||||
|
||||
case UIOHOOK_ERROR_X_RECORD_GET_CONTEXT:
|
||||
case IOHOOK_ERROR_X_RECORD_GET_CONTEXT:
|
||||
// NOTE This is the only platform specific error that occurs on hook_stop().
|
||||
logger_proc(LOG_LEVEL_ERROR, "Failed to get XRecord context. (%#X)", status);
|
||||
break;
|
||||
|
||||
// Default error.
|
||||
case UIOHOOK_FAILURE:
|
||||
case IOHOOK_FAILURE:
|
||||
default:
|
||||
// logger_proc(LOG_LEVEL_ERROR, "An unknown hook error occurred. (%#X)", status);
|
||||
break;
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
|
||||
#include "input.h"
|
||||
// #include "../logger_c.h"
|
||||
|
||||
// TODO Possibly relocate to input helper.
|
||||
static inline CGEventFlags get_key_event_mask(uiohook_event * const event) {
|
||||
static inline CGEventFlags get_key_event_mask(iohook_event * const event) {
|
||||
CGEventFlags native_mask = 0x00;
|
||||
|
||||
if (event->mask & (MASK_SHIFT)) { native_mask |= kCGEventFlagMaskShift; }
|
||||
@ -50,7 +50,7 @@ static inline CGEventFlags get_key_event_mask(uiohook_event * const event) {
|
||||
return native_mask;
|
||||
}
|
||||
|
||||
static inline void post_key_event(uiohook_event * const event) {
|
||||
static inline void post_key_event(iohook_event * const event) {
|
||||
bool is_pressed = event->type == EVENT_KEY_PRESSED;
|
||||
|
||||
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
@ -64,7 +64,7 @@ static inline void post_key_event(uiohook_event * const event) {
|
||||
CFRelease(src);
|
||||
}
|
||||
|
||||
static inline void post_mouse_button_event(uiohook_event * const event, bool is_pressed) {
|
||||
static inline void post_mouse_button_event(iohook_event * const event, bool is_pressed) {
|
||||
CGMouseButton mouse_button;
|
||||
CGEventType mouse_type;
|
||||
if (event->data.mouse.button == MOUSE_BUTTON1) {
|
||||
@ -109,7 +109,7 @@ static inline void post_mouse_button_event(uiohook_event * const event, bool is_
|
||||
CFRelease(src);
|
||||
}
|
||||
|
||||
static inline void post_mouse_wheel_event(uiohook_event * const event) {
|
||||
static inline void post_mouse_wheel_event(iohook_event * const event) {
|
||||
// FIXME Should I create a source event with the coords?
|
||||
// It seems to automagically use the current location of the cursor.
|
||||
// Two options: Query the mouse, move it to x/y, scroll, then move back
|
||||
@ -136,7 +136,7 @@ static inline void post_mouse_wheel_event(uiohook_event * const event) {
|
||||
CFRelease(src);
|
||||
}
|
||||
|
||||
static inline void post_mouse_motion_event(uiohook_event * const event) {
|
||||
static inline void post_mouse_motion_event(iohook_event * const event) {
|
||||
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
CGEventRef cg_event;
|
||||
if (event->mask >> 8 == 0x00) {
|
||||
@ -187,7 +187,7 @@ static inline void post_mouse_motion_event(uiohook_event * const event) {
|
||||
CFRelease(src);
|
||||
}
|
||||
|
||||
UIOHOOK_API void hook_post_event(uiohook_event * const event) {
|
||||
IOHOOK_API void hook_post_event(iohook_event * const event) {
|
||||
switch (event->type) {
|
||||
case EVENT_KEY_PRESSED:
|
||||
case EVENT_KEY_RELEASED:
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/time.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
|
||||
#include "input.h"
|
||||
// #include "../logger_c.h"
|
||||
@ -78,12 +78,12 @@ static bool mouse_dragged = false;
|
||||
static struct timeval system_time;
|
||||
|
||||
// Virtual event pointer.
|
||||
static uiohook_event event;
|
||||
static iohook_event event;
|
||||
|
||||
// Event dispatch callback.
|
||||
static dispatcher_t dispatcher = NULL;
|
||||
|
||||
UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
IOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Setting new dispatch callback to %#p.\n",
|
||||
__FUNCTION__, __LINE__, dispatch_proc);
|
||||
|
||||
@ -91,7 +91,7 @@ UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
}
|
||||
|
||||
// Send out an event if a dispatcher was set.
|
||||
static inline void dispatch_event(uiohook_event *const event) {
|
||||
static inline void dispatch_event(iohook_event *const event) {
|
||||
if (dispatcher != NULL) {
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Dispatching event type %u.\n",
|
||||
__FUNCTION__, __LINE__, event->type);
|
||||
@ -217,7 +217,7 @@ static void message_port_proc(void *info) {
|
||||
}
|
||||
|
||||
static int start_message_port_runloop() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
if (tis_message != NULL) {
|
||||
// Create a runloop observer for the main runloop.
|
||||
@ -256,13 +256,13 @@ static int start_message_port_runloop() {
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Successful.\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_SUCCESS;
|
||||
status = IOHOOK_SUCCESS;
|
||||
}
|
||||
else {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: CFRunLoopSourceCreate failure!\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE;
|
||||
status = IOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&msg_port_mutex);
|
||||
@ -271,7 +271,7 @@ static int start_message_port_runloop() {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: CFRunLoopObserverCreate failure!\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_ERROR_CREATE_OBSERVER;
|
||||
status = IOHOOK_ERROR_CREATE_OBSERVER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1100,8 +1100,8 @@ CGEventRef hook_event_proc(CGEventTapProxy tap_proxy, CGEventType type, CGEventR
|
||||
return result_ref;
|
||||
}
|
||||
|
||||
UIOHOOK_API int hook_run() {
|
||||
int status = UIOHOOK_SUCCESS;
|
||||
IOHOOK_API int hook_run() {
|
||||
int status = IOHOOK_SUCCESS;
|
||||
|
||||
do {
|
||||
// Reset the restart flag...
|
||||
@ -1213,7 +1213,7 @@ UIOHOOK_API int hook_run() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
int runloop_status = start_message_port_runloop();
|
||||
if (runloop_status != UIOHOOK_SUCCESS) {
|
||||
if (runloop_status != IOHOOK_SUCCESS) {
|
||||
return runloop_status;
|
||||
}
|
||||
#endif
|
||||
@ -1269,7 +1269,7 @@ UIOHOOK_API int hook_run() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
status = IOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Invalidate and free hook observer.
|
||||
@ -1283,7 +1283,7 @@ UIOHOOK_API int hook_run() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_CREATE_OBSERVER;
|
||||
status = IOHOOK_ERROR_CREATE_OBSERVER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1291,7 +1291,7 @@ UIOHOOK_API int hook_run() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_GET_RUNLOOP;
|
||||
status = IOHOOK_ERROR_GET_RUNLOOP;
|
||||
}
|
||||
|
||||
// Clean up the event source.
|
||||
@ -1302,7 +1302,7 @@ UIOHOOK_API int hook_run() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE;
|
||||
status = IOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE;
|
||||
}
|
||||
|
||||
// Stop the CFMachPort from receiving any more messages.
|
||||
@ -1314,14 +1314,14 @@ UIOHOOK_API int hook_run() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_CREATE_EVENT_PORT;
|
||||
status = IOHOOK_ERROR_CREATE_EVENT_PORT;
|
||||
}
|
||||
|
||||
// Free the hook structure.
|
||||
free(hook);
|
||||
}
|
||||
else {
|
||||
status = UIOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
status = IOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1329,7 +1329,7 @@ UIOHOOK_API int hook_run() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_AXAPI_DISABLED;
|
||||
status = IOHOOK_ERROR_AXAPI_DISABLED;
|
||||
}
|
||||
} while (restart_tap);
|
||||
|
||||
@ -1339,8 +1339,8 @@ UIOHOOK_API int hook_run() {
|
||||
return status;
|
||||
}
|
||||
|
||||
UIOHOOK_API int hook_stop() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
IOHOOK_API int hook_stop() {
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
CFStringRef mode = CFRunLoopCopyCurrentMode(event_loop);
|
||||
if (mode != NULL) {
|
||||
@ -1352,7 +1352,7 @@ UIOHOOK_API int hook_stop() {
|
||||
// Stop the run loop.
|
||||
CFRunLoopStop(event_loop);
|
||||
|
||||
status = UIOHOOK_SUCCESS;
|
||||
status = IOHOOK_SUCCESS;
|
||||
}
|
||||
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Status: %#X.\n",
|
||||
|
@ -77,11 +77,11 @@ extern bool is_accessibility_enabled();
|
||||
*/
|
||||
extern UniCharCount keycode_to_unicode(CGEventRef event_ref, UniChar *buffer, UniCharCount size);
|
||||
|
||||
/* Converts an OSX keycode to the appropriate UIOHook scancode constant.
|
||||
/* Converts an OSX keycode to the appropriate IOHook scancode constant.
|
||||
*/
|
||||
extern uint16_t keycode_to_scancode(UInt64 keycode);
|
||||
|
||||
/* Converts a UIOHook scancode constant to the appropriate OSX keycode.
|
||||
/* Converts a IOHook scancode constant to the appropriate OSX keycode.
|
||||
*/
|
||||
extern UInt64 scancode_to_keycode(uint16_t keycode);
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
|
||||
#include "input.h"
|
||||
#include "../logger_c.h"
|
||||
|
@ -14,12 +14,12 @@
|
||||
#include <IOKit/hidsystem/IOHIDParameter.h>
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
|
||||
// #include "../logger_c.h"
|
||||
#include "input.h"
|
||||
|
||||
UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
IOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
CGError status = kCGErrorFailure;
|
||||
screen_data* screens = NULL;
|
||||
|
||||
@ -123,7 +123,7 @@ UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
* CharSec = 66 / (MS / 15)
|
||||
*/
|
||||
|
||||
UIOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
IOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
#if defined USE_IOKIT || defined USE_COREFOUNDATION || defined USE_CARBON_LEGACY
|
||||
bool successful = false;
|
||||
SInt64 rate;
|
||||
@ -205,7 +205,7 @@ UIOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
IOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
#if defined USE_IOKIT || defined USE_COREFOUNDATION || defined USE_CARBON_LEGACY
|
||||
bool successful = false;
|
||||
SInt64 delay;
|
||||
@ -287,7 +287,7 @@ UIOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
#if defined USE_IOKIT || defined USE_COREFOUNDATION
|
||||
bool successful = false;
|
||||
double multiplier;
|
||||
@ -348,7 +348,7 @@ UIOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
#if defined USE_COREFOUNDATION
|
||||
bool successful = false;
|
||||
SInt32 threshold;
|
||||
@ -373,7 +373,7 @@ UIOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
IOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
#ifdef USE_IOKIT
|
||||
bool successful = false;
|
||||
double sensitivity;
|
||||
@ -420,7 +420,7 @@ UIOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_multi_click_time() {
|
||||
IOHOOK_API long int hook_get_multi_click_time() {
|
||||
#if defined USE_IOKIT || defined USE_COREFOUNDATION || defined USE_CARBON_LEGACY
|
||||
bool successful = false;
|
||||
#if defined USE_IOKIT || defined USE_CARBON_LEGACY
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#ifndef __UIOHOOK_H
|
||||
#define __UIOHOOK_H
|
||||
#ifndef __IOHOOK_H
|
||||
#define __IOHOOK_H
|
||||
|
||||
// #include "../../base/os.h"
|
||||
|
||||
@ -9,30 +9,30 @@
|
||||
#include <stdint.h>
|
||||
|
||||
/* Begin Error Codes */
|
||||
#define UIOHOOK_SUCCESS 0x00
|
||||
#define UIOHOOK_FAILURE 0x01
|
||||
#define IOHOOK_SUCCESS 0x00
|
||||
#define IOHOOK_FAILURE 0x01
|
||||
|
||||
// System level errors.
|
||||
#define UIOHOOK_ERROR_OUT_OF_MEMORY 0x02
|
||||
#define IOHOOK_ERROR_OUT_OF_MEMORY 0x02
|
||||
|
||||
// Unix specific errors.
|
||||
#define UIOHOOK_ERROR_X_OPEN_DISPLAY 0x20
|
||||
#define UIOHOOK_ERROR_X_RECORD_NOT_FOUND 0x21
|
||||
#define UIOHOOK_ERROR_X_RECORD_ALLOC_RANGE 0x22
|
||||
#define UIOHOOK_ERROR_X_RECORD_CREATE_CONTEXT 0x23
|
||||
#define UIOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT 0x24
|
||||
#define UIOHOOK_ERROR_X_RECORD_GET_CONTEXT 0x25
|
||||
#define IOHOOK_ERROR_X_OPEN_DISPLAY 0x20
|
||||
#define IOHOOK_ERROR_X_RECORD_NOT_FOUND 0x21
|
||||
#define IOHOOK_ERROR_X_RECORD_ALLOC_RANGE 0x22
|
||||
#define IOHOOK_ERROR_X_RECORD_CREATE_CONTEXT 0x23
|
||||
#define IOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT 0x24
|
||||
#define IOHOOK_ERROR_X_RECORD_GET_CONTEXT 0x25
|
||||
|
||||
// Windows specific errors.
|
||||
#define UIOHOOK_ERROR_SET_WINDOWS_HOOK_EX 0x30
|
||||
#define UIOHOOK_ERROR_GET_MODULE_HANDLE 0x31
|
||||
#define IOHOOK_ERROR_SET_WINDOWS_HOOK_EX 0x30
|
||||
#define IOHOOK_ERROR_GET_MODULE_HANDLE 0x31
|
||||
|
||||
// Darwin specific errors.
|
||||
#define UIOHOOK_ERROR_AXAPI_DISABLED 0x40
|
||||
#define UIOHOOK_ERROR_CREATE_EVENT_PORT 0x41
|
||||
#define UIOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE 0x42
|
||||
#define UIOHOOK_ERROR_GET_RUNLOOP 0x43
|
||||
#define UIOHOOK_ERROR_CREATE_OBSERVER 0x44
|
||||
#define IOHOOK_ERROR_AXAPI_DISABLED 0x40
|
||||
#define IOHOOK_ERROR_CREATE_EVENT_PORT 0x41
|
||||
#define IOHOOK_ERROR_CREATE_RUN_LOOP_SOURCE 0x42
|
||||
#define IOHOOK_ERROR_GET_RUNLOOP 0x43
|
||||
#define IOHOOK_ERROR_CREATE_OBSERVER 0x44
|
||||
/* End Error Codes */
|
||||
|
||||
/* Begin Log Levels and Function Prototype */
|
||||
@ -100,7 +100,7 @@ typedef struct _mouse_wheel_event_data {
|
||||
uint8_t direction;
|
||||
} mouse_wheel_event_data;
|
||||
|
||||
typedef struct _uiohook_event {
|
||||
typedef struct _iohook_event {
|
||||
event_type type;
|
||||
uint64_t time;
|
||||
uint16_t mask;
|
||||
@ -110,9 +110,9 @@ typedef struct _uiohook_event {
|
||||
mouse_event_data mouse;
|
||||
mouse_wheel_event_data wheel;
|
||||
} data;
|
||||
} uiohook_event;
|
||||
} iohook_event;
|
||||
|
||||
typedef void (*dispatcher_t)(uiohook_event *const);
|
||||
typedef void (*dispatcher_t)(iohook_event *const);
|
||||
/* End Virtual Event Types and Data Structures */
|
||||
|
||||
|
||||
@ -390,9 +390,9 @@ typedef void (*dispatcher_t)(uiohook_event *const);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define UIOHOOK_API __declspec(dllexport)
|
||||
#define IOHOOK_API __declspec(dllexport)
|
||||
#else
|
||||
#define UIOHOOK_API
|
||||
#define IOHOOK_API
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -400,40 +400,40 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Set the logger callback functions.
|
||||
UIOHOOK_API void hook_set_logger_proc(logger_t logger_proc);
|
||||
IOHOOK_API void hook_set_logger_proc(logger_t logger_proc);
|
||||
|
||||
// Send a virtual event back to the system.
|
||||
UIOHOOK_API void hook_post_event(uiohook_event * const event);
|
||||
IOHOOK_API void hook_post_event(iohook_event * const event);
|
||||
|
||||
// Set the event callback function.
|
||||
UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc);
|
||||
IOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc);
|
||||
|
||||
// Insert the event hook.
|
||||
UIOHOOK_API int hook_run();
|
||||
IOHOOK_API int hook_run();
|
||||
|
||||
// Withdraw the event hook.
|
||||
UIOHOOK_API int hook_stop();
|
||||
IOHOOK_API int hook_stop();
|
||||
|
||||
// Retrieves an array of screen data for each available monitor.
|
||||
UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count);
|
||||
IOHOOK_API screen_data* hook_create_screen_info(unsigned char *count);
|
||||
|
||||
// Retrieves the keyboard auto repeat rate.
|
||||
UIOHOOK_API long int hook_get_auto_repeat_rate();
|
||||
IOHOOK_API long int hook_get_auto_repeat_rate();
|
||||
|
||||
// Retrieves the keyboard auto repeat delay.
|
||||
UIOHOOK_API long int hook_get_auto_repeat_delay();
|
||||
IOHOOK_API long int hook_get_auto_repeat_delay();
|
||||
|
||||
// Retrieves the mouse acceleration multiplier.
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_multiplier();
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_multiplier();
|
||||
|
||||
// Retrieves the mouse acceleration threshold.
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_threshold();
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_threshold();
|
||||
|
||||
// Retrieves the mouse sensitivity.
|
||||
UIOHOOK_API long int hook_get_pointer_sensitivity();
|
||||
IOHOOK_API long int hook_get_pointer_sensitivity();
|
||||
|
||||
// Retrieves the double/triple click interval.
|
||||
UIOHOOK_API long int hook_get_multi_click_time();
|
||||
IOHOOK_API long int hook_get_multi_click_time();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
#ifndef _included_logger
|
||||
#define _included_logger
|
||||
|
||||
// #include <uiohook.h>
|
||||
#include "uiohook.h"
|
||||
// #include <iohook.h>
|
||||
#include "iohook.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef __FUNCTION__
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
// #include <uiohook.h>
|
||||
#include "uiohook.h"
|
||||
// #include <iohook.h>
|
||||
#include "iohook.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
@ -44,7 +44,7 @@ static bool default_logger(unsigned int level, const char *format, ...) {
|
||||
logger_t logger = &default_logger;
|
||||
|
||||
|
||||
UIOHOOK_API void hook_set_logger_proc(logger_t logger_proc) {
|
||||
IOHOOK_API void hook_set_logger_proc(logger_t logger_proc) {
|
||||
if (logger_proc == NULL) {
|
||||
logger = &default_logger;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
#include "input.h"
|
||||
@ -48,7 +48,7 @@ static UINT keymask_lookup[8] = {
|
||||
VK_RMENU
|
||||
};
|
||||
|
||||
UIOHOOK_API void hook_post_event(uiohook_event * const event) {
|
||||
IOHOOK_API void hook_post_event(iohook_event * const event) {
|
||||
//FIXME implement multiple monitor support
|
||||
uint16_t screen_width = GetSystemMetrics( SM_CXSCREEN );
|
||||
uint16_t screen_height = GetSystemMetrics( SM_CYSCREEN );
|
||||
|
@ -4,7 +4,7 @@
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
#include "input.h"
|
||||
@ -28,12 +28,12 @@ static unsigned short int click_button = MOUSE_NOBUTTON;
|
||||
static POINT last_click;
|
||||
|
||||
// Static event memory.
|
||||
static uiohook_event event;
|
||||
static iohook_event event;
|
||||
|
||||
// Event dispatch callback.
|
||||
static dispatcher_t dispatcher = NULL;
|
||||
|
||||
UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
IOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Setting new dispatch callback to %#p.\n",
|
||||
__FUNCTION__, __LINE__, dispatch_proc);
|
||||
|
||||
@ -41,7 +41,7 @@ UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
}
|
||||
|
||||
// Send out an event if a dispatcher was set.
|
||||
static inline void dispatch_event(uiohook_event *const event) {
|
||||
static inline void dispatch_event(iohook_event *const event) {
|
||||
if (dispatcher != NULL) {
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Dispatching event type %u.\n",
|
||||
__FUNCTION__, __LINE__, event->type);
|
||||
@ -650,8 +650,8 @@ void CALLBACK win_hook_event_proc(HWINEVENTHOOK hook, DWORD event, HWND hWnd, LO
|
||||
}
|
||||
|
||||
|
||||
UIOHOOK_API int hook_run() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
IOHOOK_API int hook_run() {
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
// Set the thread id we want to signal later.
|
||||
hook_thread_id = GetCurrentThreadId();
|
||||
@ -671,7 +671,7 @@ UIOHOOK_API int hook_run() {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: Could not determine hInst for SetWindowsHookEx()! (%#lX)\n",
|
||||
__FUNCTION__, __LINE__, (unsigned long) GetLastError());
|
||||
|
||||
status = UIOHOOK_ERROR_GET_MODULE_HANDLE;
|
||||
status = IOHOOK_ERROR_GET_MODULE_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -701,7 +701,7 @@ UIOHOOK_API int hook_run() {
|
||||
initialize_modifiers();
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_SUCCESS;
|
||||
status = IOHOOK_SUCCESS;
|
||||
|
||||
// Windows does not have a hook start event or callback so we need to
|
||||
// manually fake it.
|
||||
@ -718,7 +718,7 @@ UIOHOOK_API int hook_run() {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: SetWindowsHookEx() failed! (%#lX)\n",
|
||||
__FUNCTION__, __LINE__, (unsigned long) GetLastError());
|
||||
|
||||
status = UIOHOOK_ERROR_SET_WINDOWS_HOOK_EX;
|
||||
status = IOHOOK_ERROR_SET_WINDOWS_HOOK_EX;
|
||||
}
|
||||
|
||||
|
||||
@ -732,12 +732,12 @@ UIOHOOK_API int hook_run() {
|
||||
return status;
|
||||
}
|
||||
|
||||
UIOHOOK_API int hook_stop() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
IOHOOK_API int hook_stop() {
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
// Try to exit the thread naturally.
|
||||
if (PostThreadMessage(hook_thread_id, WM_QUIT, (WPARAM) NULL, (LPARAM) NULL)) {
|
||||
status = UIOHOOK_SUCCESS;
|
||||
status = IOHOOK_SUCCESS;
|
||||
}
|
||||
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Status: %#X.\n",
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
#include "../logger_c.h"
|
||||
@ -383,7 +383,7 @@ static BOOL is_wow64() {
|
||||
|
||||
// Locate the DLL that contains the current keyboard layout.
|
||||
static int get_keyboard_layout_file(char *layoutFile, DWORD bufferSize) {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
int status = IOHOOK_FAILURE;
|
||||
HKEY hKey;
|
||||
DWORD varType = REG_SZ;
|
||||
|
||||
@ -395,7 +395,7 @@ static int get_keyboard_layout_file(char *layoutFile, DWORD bufferSize) {
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR) kbdKeyPath, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
|
||||
if (RegQueryValueEx(hKey, "Layout File", NULL, &varType, (LPBYTE) layoutFile, &bufferSize) == ERROR_SUCCESS) {
|
||||
RegCloseKey(hKey);
|
||||
status = UIOHOOK_SUCCESS;
|
||||
status = IOHOOK_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -496,7 +496,7 @@ static int refresh_locale_list() {
|
||||
|
||||
// Try to pull the current keyboard layout DLL from the registry.
|
||||
char layoutFile[MAX_PATH];
|
||||
if (get_keyboard_layout_file(layoutFile, sizeof(layoutFile)) == UIOHOOK_SUCCESS) {
|
||||
if (get_keyboard_layout_file(layoutFile, sizeof(layoutFile)) == IOHOOK_SUCCESS) {
|
||||
// You can't trust the %SYSPATH%, look it up manually.
|
||||
char systemDirectory[MAX_PATH];
|
||||
if (GetSystemDirectory(systemDirectory, MAX_PATH) != 0) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
#include <windows.h>
|
||||
|
||||
// #include "logger.h"
|
||||
@ -55,7 +55,7 @@ static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
IOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
// Initialize count to zero.
|
||||
*count = 0;
|
||||
|
||||
@ -98,7 +98,7 @@ UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
return screens.data;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
IOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
long int value = -1;
|
||||
long int rate;
|
||||
|
||||
@ -112,7 +112,7 @@ UIOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
IOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
long int value = -1;
|
||||
long int delay;
|
||||
|
||||
@ -126,7 +126,7 @@ UIOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
long int value = -1;
|
||||
int mouse[3]; // 0-Threshold X, 1-Threshold Y and 2-Speed.
|
||||
|
||||
@ -140,7 +140,7 @@ UIOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
long int value = -1;
|
||||
int mouse[3]; // 0-Threshold X, 1-Threshold Y and 2-Speed.
|
||||
|
||||
@ -157,7 +157,7 @@ UIOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
IOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
long int value = -1;
|
||||
int sensitivity;
|
||||
|
||||
@ -171,7 +171,7 @@ UIOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_multi_click_time() {
|
||||
IOHOOK_API long int hook_get_multi_click_time() {
|
||||
long int value = -1;
|
||||
UINT clicktime;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef USE_XTEST
|
||||
@ -59,7 +59,7 @@ static unsigned int convert_to_native_mask(unsigned int mask) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void post_key_event(uiohook_event * const event) {
|
||||
static inline void post_key_event(iohook_event * const event) {
|
||||
#ifdef USE_XTEST
|
||||
// FIXME Currently ignoring EVENT_KEY_TYPED.
|
||||
if (event->type == EVENT_KEY_PRESSED) {
|
||||
@ -112,7 +112,7 @@ static inline void post_key_event(uiohook_event * const event) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void post_mouse_button_event(uiohook_event * const event) {
|
||||
static inline void post_mouse_button_event(iohook_event * const event) {
|
||||
#ifdef USE_XTEST
|
||||
Window ret_root;
|
||||
Window ret_child;
|
||||
@ -227,7 +227,7 @@ static inline void post_mouse_button_event(uiohook_event * const event) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void post_mouse_motion_event(uiohook_event * const event) {
|
||||
static inline void post_mouse_motion_event(iohook_event * const event) {
|
||||
#ifdef USE_XTEST
|
||||
XTestFakeMotionEvent(properties_disp, -1, event->data.mouse.x, event->data.mouse.y, 0);
|
||||
#else
|
||||
@ -313,7 +313,7 @@ static inline void post_mouse_motion_event(uiohook_event * const event) {
|
||||
#endif
|
||||
}
|
||||
|
||||
UIOHOOK_API void hook_post_event(uiohook_event * const event) {
|
||||
IOHOOK_API void hook_post_event(iohook_event * const event) {
|
||||
XLockDisplay(properties_disp);
|
||||
|
||||
#ifdef USE_XTEST
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xlibint.h>
|
||||
@ -86,12 +86,12 @@ static struct xkb_state *state = NULL;
|
||||
#endif
|
||||
|
||||
// Virtual event pointer.
|
||||
static uiohook_event event;
|
||||
static iohook_event event;
|
||||
|
||||
// Event dispatch callback.
|
||||
static dispatcher_t dispatcher = NULL;
|
||||
|
||||
UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
IOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Setting new dispatch callback to %#p.\n",
|
||||
__FUNCTION__, __LINE__, dispatch_proc);
|
||||
|
||||
@ -99,7 +99,7 @@ UIOHOOK_API void hook_set_dispatch_proc(dispatcher_t dispatch_proc) {
|
||||
}
|
||||
|
||||
// Send out an event if a dispatcher was set.
|
||||
static inline void dispatch_event(uiohook_event *const event) {
|
||||
static inline void dispatch_event(iohook_event *const event) {
|
||||
if (dispatcher != NULL) {
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Dispatching event type %u.\n",
|
||||
__FUNCTION__, __LINE__, event->type);
|
||||
@ -811,7 +811,7 @@ static inline bool enable_key_repeate() {
|
||||
|
||||
|
||||
static inline int xrecord_block() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
// Save the data display associated with this hook so it is passed to each event.
|
||||
//XPointer closeure = (XPointer) (ctrl_display);
|
||||
@ -856,7 +856,7 @@ static inline int xrecord_block() {
|
||||
#else
|
||||
// Sync blocks until XRecordDisableContext() is called.
|
||||
if (XRecordEnableContext(hook->data.display, hook->ctrl.context, hook_event_proc, closeure) != 0) {
|
||||
status = UIOHOOK_SUCCESS;
|
||||
status = IOHOOK_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
@ -871,14 +871,14 @@ static inline int xrecord_block() {
|
||||
#endif
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT;
|
||||
status = IOHOOK_ERROR_X_RECORD_ENABLE_CONTEXT;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int xrecord_alloc() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
// Make sure the data display is synchronized to prevent late event delivery!
|
||||
// See Bug 42356 for more information.
|
||||
@ -915,7 +915,7 @@ static int xrecord_alloc() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_X_RECORD_CREATE_CONTEXT;
|
||||
status = IOHOOK_ERROR_X_RECORD_CREATE_CONTEXT;
|
||||
}
|
||||
|
||||
// Free the XRecord range.
|
||||
@ -926,14 +926,14 @@ static int xrecord_alloc() {
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
// Set the exit status.
|
||||
status = UIOHOOK_ERROR_X_RECORD_ALLOC_RANGE;
|
||||
status = IOHOOK_ERROR_X_RECORD_ALLOC_RANGE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int xrecord_query() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
// Check to make sure XRecord is installed and enabled.
|
||||
int major, minor;
|
||||
@ -947,14 +947,14 @@ static int xrecord_query() {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: XRecord is not currently available!\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_ERROR_X_RECORD_NOT_FOUND;
|
||||
status = IOHOOK_ERROR_X_RECORD_NOT_FOUND;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int xrecord_start() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
// Open the control display for XRecord.
|
||||
hook->ctrl.display = XOpenDisplay(NULL);
|
||||
@ -1027,7 +1027,7 @@ static int xrecord_start() {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: XOpenDisplay failure!\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_ERROR_X_OPEN_DISPLAY;
|
||||
status = IOHOOK_ERROR_X_OPEN_DISPLAY;
|
||||
}
|
||||
|
||||
// Close down the XRecord data display.
|
||||
@ -1045,8 +1045,8 @@ static int xrecord_start() {
|
||||
return status;
|
||||
}
|
||||
|
||||
UIOHOOK_API int hook_run() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
IOHOOK_API int hook_run() {
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
// Hook data for future cleanup.
|
||||
hook = malloc(sizeof(hook_info));
|
||||
@ -1067,7 +1067,7 @@ UIOHOOK_API int hook_run() {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to allocate memory for hook structure!\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
status = IOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
logger(LOG_LEVEL_DEBUG, "%s [%u]: Something, something, something, complete.\n",
|
||||
@ -1076,8 +1076,8 @@ UIOHOOK_API int hook_run() {
|
||||
return status;
|
||||
}
|
||||
|
||||
UIOHOOK_API int hook_stop() {
|
||||
int status = UIOHOOK_FAILURE;
|
||||
IOHOOK_API int hook_stop() {
|
||||
int status = IOHOOK_FAILURE;
|
||||
|
||||
if (hook != NULL && hook->ctrl.display != NULL && hook->ctrl.context != 0) {
|
||||
// We need to make sure the context is still valid.
|
||||
@ -1102,14 +1102,14 @@ UIOHOOK_API int hook_stop() {
|
||||
hook->ctrl.display = NULL;
|
||||
}
|
||||
|
||||
status = UIOHOOK_SUCCESS;
|
||||
status = IOHOOK_SUCCESS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: XRecordGetContext failure!\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_ERROR_X_RECORD_GET_CONTEXT;
|
||||
status = IOHOOK_ERROR_X_RECORD_GET_CONTEXT;
|
||||
}
|
||||
|
||||
free(state);
|
||||
@ -1118,7 +1118,7 @@ UIOHOOK_API int hook_stop() {
|
||||
logger(LOG_LEVEL_ERROR, "%s [%u]: Failed to allocate memory for XRecordState!\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
|
||||
status = UIOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
status = IOHOOK_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../uiohook.h"
|
||||
#include "../iohook.h"
|
||||
#include <X11/Xlib.h>
|
||||
#ifdef USE_XKB
|
||||
#include <X11/XKBlib.h>
|
||||
@ -109,7 +109,7 @@ static void *settings_thread_proc(void *arg) {
|
||||
}
|
||||
#endif
|
||||
|
||||
UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
IOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
*count = 0;
|
||||
screen_data *screens = NULL;
|
||||
|
||||
@ -207,7 +207,7 @@ UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) {
|
||||
return screens;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
IOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
bool successful = false;
|
||||
long int value = -1;
|
||||
unsigned int delay = 0, rate = 0;
|
||||
@ -253,7 +253,7 @@ UIOHOOK_API long int hook_get_auto_repeat_rate() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
IOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
bool successful = false;
|
||||
long int value = -1;
|
||||
unsigned int delay = 0, rate = 0;
|
||||
@ -299,7 +299,7 @@ UIOHOOK_API long int hook_get_auto_repeat_delay() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
long int value = -1;
|
||||
int accel_numerator, accel_denominator, threshold;
|
||||
|
||||
@ -321,7 +321,7 @@ UIOHOOK_API long int hook_get_pointer_acceleration_multiplier() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
IOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
long int value = -1;
|
||||
int accel_numerator, accel_denominator, threshold;
|
||||
|
||||
@ -343,7 +343,7 @@ UIOHOOK_API long int hook_get_pointer_acceleration_threshold() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
IOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
long int value = -1;
|
||||
int accel_numerator, accel_denominator, threshold;
|
||||
|
||||
@ -365,7 +365,7 @@ UIOHOOK_API long int hook_get_pointer_sensitivity() {
|
||||
return value;
|
||||
}
|
||||
|
||||
UIOHOOK_API long int hook_get_multi_click_time() {
|
||||
IOHOOK_API long int hook_get_multi_click_time() {
|
||||
long int value = 200;
|
||||
int click_time;
|
||||
bool successful = false;
|
||||
@ -468,7 +468,7 @@ void on_library_load() {
|
||||
|
||||
int argc = 0;
|
||||
char ** argv = { NULL };
|
||||
xt_disp = XtOpenDisplay(xt_context, NULL, "UIOHook", "libuiohook", NULL, 0, &argc, argv);
|
||||
xt_disp = XtOpenDisplay(xt_context, NULL, "IOHook", "libIOhook", NULL, 0, &argc, argv);
|
||||
#endif
|
||||
|
||||
// Initialize.
|
||||
|
15
robotgo.go
15
robotgo.go
@ -182,6 +182,13 @@ func MoveMouse(x, y int) {
|
||||
C.aMoveMouse(cx, cy)
|
||||
}
|
||||
|
||||
//Move Move the Mouse
|
||||
func Move(x, y int) {
|
||||
cx := C.size_t(x)
|
||||
cy := C.size_t(y)
|
||||
C.aMoveMouse(cx, cy)
|
||||
}
|
||||
|
||||
//DragMouse Drag the Mouse
|
||||
func DragMouse(x, y int) {
|
||||
cx := C.size_t(x)
|
||||
@ -221,8 +228,8 @@ func GetMousePos() (int, int) {
|
||||
return x, y
|
||||
}
|
||||
|
||||
//Click Click the Mouse
|
||||
func Click(args ...interface{}) {
|
||||
//MouseClick Click the Mouse
|
||||
func MouseClick(args ...interface{}) {
|
||||
var button C.MMMouseButton
|
||||
var double C.bool
|
||||
Try(func() {
|
||||
@ -245,8 +252,8 @@ func Click(args ...interface{}) {
|
||||
C.aMouseClick(button, double)
|
||||
}
|
||||
|
||||
//MouseClick Click the Mouse
|
||||
func MouseClick(args ...interface{}) {
|
||||
//Click Click the Mouse
|
||||
func Click(args ...interface{}) {
|
||||
var button C.MMMouseButton
|
||||
var double C.bool
|
||||
Try(func() {
|
||||
|
Loading…
Reference in New Issue
Block a user