Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nut-tree/robotjs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.5.2
Choose a base ref
...
head repository: nut-tree/robotjs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 14 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 5, 2019

  1. Enabled mouse button press on move

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    014c722 View commit details
  2. Updated null value for move event

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    6885bf8 View commit details
  3. Version bump

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    3166a7f View commit details
  4. Added event source to mouse toggle

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    42c3d6f View commit details
  5. Fixed mouse drag on macOS

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    8b9bdd0 View commit details
  6. Working mouse drag on macOS

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    4407d6f View commit details
  7. Cleanup, removed debug output

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    7426e5c View commit details
  8. v0.5.3

    Simon Hofmann committed Jun 5, 2019
    Copy the full SHA
    9db13c2 View commit details

Commits on Jun 11, 2019

  1. Updated appveyor build

    Simon Hofmann committed Jun 11, 2019
    Copy the full SHA
    f8842da View commit details
  2. Restructured build config

    Simon Hofmann committed Jun 11, 2019
    Copy the full SHA
    a0b6e98 View commit details
  3. Restructured build config

    Simon Hofmann committed Jun 11, 2019
    Copy the full SHA
    948c149 View commit details
  4. Updated platform config

    Simon Hofmann committed Jun 11, 2019
    Copy the full SHA
    d924dc2 View commit details
  5. Added platform to node installation

    Simon Hofmann committed Jun 11, 2019
    Copy the full SHA
    c517c36 View commit details
  6. Version bump to 0.5.4

    Simon Hofmann committed Jun 11, 2019
    Copy the full SHA
    728eb06 View commit details
Showing with 72 additions and 79 deletions.
  1. +4 −4 appveyor.yml
  2. +18 −44 package-lock.json
  3. +1 −1 package.json
  4. +49 −30 src/mouse.c
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# http://www.appveyor.com/docs/appveyor-yml

# Test against these versions of Io.js and Node.js.
environment:
matrix:
# node.js
- nodejs_version: "10"
- nodejs_version: "11"
- nodejs_version: 10
- nodejs_version: 11

cache:
- node_modules

clone_depth: 5

platform:
- x86
- x64

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node 0.STABLE.latest
- ps: Install-Product node $env:nodejs_version
- ps: Install-Product node $env:nodejs_version $env:platform
- npm -g install npm
- set PATH=%APPDATA%\npm;%PATH%
# Typical npm stuff.
62 changes: 18 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "robotjs-node10",
"version": "0.5.2",
"version": "0.5.4",
"description": "This is a fork of octalmage/robotjs with prebuilts for node 10",
"main": "index.js",
"typings": "index.d.ts",
79 changes: 49 additions & 30 deletions src/mouse.c
Original file line number Diff line number Diff line change
@@ -90,49 +90,62 @@ void calculateDeltas(CGEventRef *event, MMPoint point)
*/
void moveMouse(MMPoint point)
{
#if defined(IS_MACOSX)
CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
CGPointFromMMPoint(point),
kCGMouseButtonLeft);

calculateDeltas(&move, point);

CGEventPost(kCGSessionEventTap, move);
CFRelease(move);
#elif defined(USE_X11)
#ifdef USE_X11
Display *display = XGetMainDisplay();
XWarpPointer(display, None, DefaultRootWindow(display),
0, 0, 0, 0, point.x, point.y);
XSync(display, false);
#elif defined(IS_WINDOWS)
//Mouse motion is now done using SendInput with MOUSEINPUT. We use Absolute mouse positioning
#define MOUSE_COORD_TO_ABS(coord, width_or_height) (((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1))
point.x = MOUSE_COORD_TO_ABS(point.x, GetSystemMetrics(SM_CXSCREEN));
point.y = MOUSE_COORD_TO_ABS(point.y, GetSystemMetrics(SM_CYSCREEN));
INPUT mouseInput;
mouseInput.type = INPUT_MOUSE;
mouseInput.mi.dx = point.x;
mouseInput.mi.dy = point.y;
mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
mouseInput.mi.time = 0; //System will provide the timestamp
mouseInput.mi.dwExtraInfo = 0;
mouseInput.mi.mouseData = 0;
SendInput(1, &mouseInput, sizeof(mouseInput));
#endif
#ifdef IS_MACOSX
CGPoint position = CGPointMake (point.x, point.y);
// Create an HID hardware event source
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);

CGEventRef evt = NULL;
if (CGEventSourceButtonState (kCGEventSourceStateHIDSystemState, kCGMouseButtonLeft)) {
// Create a left button drag
evt = CGEventCreateMouseEvent
(src, kCGEventLeftMouseDragged,
position, kCGMouseButtonLeft);
} else {
if (CGEventSourceButtonState (kCGEventSourceStateHIDSystemState, kCGMouseButtonRight)) {
// Create a right button drag
evt = CGEventCreateMouseEvent
(src, kCGEventRightMouseDragged,
position, kCGMouseButtonLeft);
} else {
// Create a mouse move event
evt = CGEventCreateMouseEvent
(src, kCGEventMouseMoved,
position, kCGMouseButtonLeft);
}
}

// Post mouse event and release
CGEventPost (kCGHIDEventTap, evt);
if (evt != NULL) {
CFRelease (evt);
}
CFRelease (src);
#endif
#ifdef IS_WINDOWS
SetCursorPos (point.x, point.y);
#endif
}

void dragMouse(MMPoint point, const MMMouseButton button)
{
#if defined(IS_MACOSX)
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
const CGEventType dragType = MMMouseDragToCGEventType(button);
CGEventRef drag = CGEventCreateMouseEvent(NULL, dragType,
CGEventRef drag = CGEventCreateMouseEvent(src, dragType,
CGPointFromMMPoint(point),
(CGMouseButton)button);
calculateDeltas(&drag, point);

CGEventPost(kCGSessionEventTap, drag);
CGEventPost(kCGHIDEventTap, drag);
CFRelease(drag);
CFRelease(src);
#else
moveMouse(point);
#endif
@@ -141,9 +154,11 @@ void dragMouse(MMPoint point, const MMMouseButton button)
MMPoint getMousePos()
{
#if defined(IS_MACOSX)
CGEventRef event = CGEventCreate(NULL);
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef event = CGEventCreate(src);
CGPoint point = CGEventGetLocation(event);
CFRelease(event);
CFRelease(src);

return MMPointFromCGPoint(point);
#elif defined(USE_X11)
@@ -175,12 +190,14 @@ void toggleMouse(bool down, MMMouseButton button)
#if defined(IS_MACOSX)
const CGPoint currentPos = CGPointFromMMPoint(getMousePos());
const CGEventType mouseType = MMMouseToCGEventType(down, button);
CGEventRef event = CGEventCreateMouseEvent(NULL,
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef event = CGEventCreateMouseEvent(src,
mouseType,
currentPos,
(CGMouseButton)button);
CGEventPost(kCGSessionEventTap, event);
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
CFRelease(src);
#elif defined(USE_X11)
Display *display = XGetMainDisplay();
XTestFakeButtonEvent(display, button, down ? True : False, CurrentTime);
@@ -210,7 +227,8 @@ void doubleClick(MMMouseButton button)
const CGEventType mouseTypeDown = MMMouseToCGEventType(true, button);
const CGEventType mouseTypeUP = MMMouseToCGEventType(false, button);

CGEventRef event = CGEventCreateMouseEvent(NULL, mouseTypeDown, currentPos, kCGMouseButtonLeft);
CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef event = CGEventCreateMouseEvent(src, mouseTypeDown, currentPos, kCGMouseButtonLeft);

/* Set event to double click. */
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 2);
@@ -221,6 +239,7 @@ void doubleClick(MMMouseButton button)
CGEventPost(kCGHIDEventTap, event);

CFRelease(event);
CFRelease(src);

#else