diff --git a/include/uiohook.h b/include/uiohook.h index 669e5f6e..6afaad2d 100644 --- a/include/uiohook.h +++ b/include/uiohook.h @@ -100,6 +100,8 @@ typedef struct _mouse_event_data { uint16_t clicks; int16_t x; int16_t y; + int16_t dx; + int16_t dy; } mouse_event_data, mouse_pressed_event_data, mouse_released_event_data, diff --git a/src/darwin/dispatch_event.c b/src/darwin/dispatch_event.c index 123f0124..d080c7cd 100644 --- a/src/darwin/dispatch_event.c +++ b/src/darwin/dispatch_event.c @@ -559,6 +559,12 @@ bool dispatch_mouse_move(uint64_t timestamp, CGEventRef event_ref) { CGPoint event_point = CGEventGetLocation(event_ref); + + logger(LOG_LEVEL_WARN, "#### %s [%u]: Mouse %s to %i, %i.\n", + __FUNCTION__, __LINE__, is_mouse_dragged() ? "dragged" : "moved", + CGEventGetIntegerValueField(event_ref, kCGMouseEventDeltaX), + CGEventGetIntegerValueField(event_ref, kCGMouseEventDeltaY)); + // Populate mouse motion event. uio_event.time = timestamp; if (is_mouse_dragged()) { diff --git a/src/darwin/input_hook.c b/src/darwin/input_hook.c index bc64ec15..437b9ff9 100644 --- a/src/darwin/input_hook.c +++ b/src/darwin/input_hook.c @@ -261,7 +261,7 @@ static int create_event_runloop_info(event_runloop_info **hook) { // Create the event tap. (*hook)->port = CGEventTapCreate( - kCGSessionEventTap, // kCGHIDEventTap + kCGSessionEventTap, // kCGHIDEventTap requires privileges? kCGHeadInsertEventTap, // kCGTailAppendEventTap kCGEventTapOptionDefault, // kCGEventTapOptionListenOnly See https://github.com/kwhat/jnativehook/issues/22 event_mask, diff --git a/src/windows/dispatch_event.c b/src/windows/dispatch_event.c index a41c24d7..da4b9f87 100644 --- a/src/windows/dispatch_event.c +++ b/src/windows/dispatch_event.c @@ -30,6 +30,7 @@ static unsigned short click_count = 0; static uint64_t click_time = 0; static unsigned short int click_button = MOUSE_NOBUTTON; static POINT last_click; +static POINT last_moved; // Event dispatch callback. static dispatcher_t dispatch = NULL; @@ -78,6 +79,12 @@ static void dispatch_event(uiohook_event *const event) { bool dispatch_hook_enable(uint64_t timestamp) { bool consumed = false; + // FIXME I am not sure where this should live, it use to be with the call to load_input_helper() before refactor. + if (!GetCursorPos(&last_moved)) { + logger(LOG_LEVEL_WARN, "%s [%u]: Failed to locate cursor position!\n", + __FUNCTION__, __LINE__); + } + // Populate the hook start event. uio_event.time = timestamp; uio_event.type = EVENT_HOOK_ENABLED; @@ -358,6 +365,12 @@ bool dispatch_mouse_move(uint64_t timestamp, MSLLHOOKSTRUCT *mshook) { uio_event.data.mouse.clicks = click_count; uio_event.data.mouse.x = (int16_t) mshook->pt.x; uio_event.data.mouse.y = (int16_t) mshook->pt.y; +// FIXME This looks like testing logging that should be at LOG_LEVEL_DEBUG like below... + logger(LOG_LEVEL_WARN, "#### %s [%u]: Mouse %s to %i, %i.\n", + __FUNCTION__, __LINE__, + mouse_dragged ? "dragged" : "moved", + last_moved.x - mshook->pt.x, last_moved.y - mshook->pt.y); + last_moved = mshook->pt; logger(LOG_LEVEL_DEBUG, "%s [%u]: Mouse %s to %u, %u.\n", __FUNCTION__, __LINE__,