Skip to content

Commit

Permalink
Use cross platform microsleep instead of mssleep.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Jul 23, 2015
1 parent fc4016d commit a511724
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "screengrab.h"
#include "MMBitmap.h"
#include "snprintf.h"
#include "microsleep.h"

using namespace v8;

Expand Down Expand Up @@ -288,18 +289,6 @@ int CheckKeyFlags(char* f, MMKeyFlags* flags)
return 0;
}

int mssleep(unsigned long millisecond)
{
struct timespec req;
time_t sec=(int)(millisecond/1000);
millisecond=millisecond-(sec*1000);
req.tv_sec=sec;
req.tv_nsec=millisecond*1000000L;
while(nanosleep(&req,&req)==-1)
continue;
return 1;
}

NAN_METHOD(keyTap)
{
NanScope();
Expand Down Expand Up @@ -349,7 +338,7 @@ NAN_METHOD(keyTap)
break;
default:
tapKeyCode(key, flags);
mssleep(10);
microsleep(10);
}

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

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

0 comments on commit a511724

Please sign in to comment.