Skip to content

Commit

Permalink
Use global delays for mouse and keyboard functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Aug 7, 2015
1 parent b6326bc commit 3cbfc50
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

using namespace v8;

//Global delays.
int mouseDelay = 10;
int keyboardDelay = 10;

/*
__ __
| \/ | ___ _ _ ___ ___
Expand All @@ -35,7 +39,7 @@ NAN_METHOD(moveMouse)
MMPoint point;
point = MMPointMake(x, y);
moveMouse(point);
microsleep(10);
microsleep(mouseDelay);

NanReturnValue(NanNew("1"));
}
Expand All @@ -53,7 +57,7 @@ NAN_METHOD(moveMouseSmooth)
MMPoint point;
point = MMPointMake(x, y);
smoothlyMoveMouse(point);
microsleep(10);
microsleep(mouseDelay);

NanReturnValue(NanNew("1"));
}
Expand Down Expand Up @@ -122,7 +126,7 @@ NAN_METHOD(mouseClick)
doubleClick(button);
}

microsleep(10);
microsleep(mouseDelay);

NanReturnValue(NanNew("1"));
}
Expand Down Expand Up @@ -179,7 +183,7 @@ NAN_METHOD(mouseToggle)
}

toggleMouse(down, button);
microsleep(10);
microsleep(mouseDelay);

NanReturnValue(NanNew("1"));
}
Expand Down Expand Up @@ -410,7 +414,7 @@ NAN_METHOD(keyTap)
break;
default:
tapKeyCode(key, flags);
microsleep(10);
microsleep(keyboardDelay);
}

NanReturnValue(NanNew("1"));
Expand Down Expand Up @@ -468,7 +472,7 @@ NAN_METHOD(keyToggle)
break;
default:
toggleKeyCode(key, down, flags);
microsleep(10);
microsleep(keyboardDelay);
}

NanReturnValue(NanNew("1"));
Expand Down

0 comments on commit 3cbfc50

Please sign in to comment.