@@ -18,8 +18,8 @@ int mouseDelay = 10;
18
18
int keyboardDelay = 10 ;
19
19
20
20
/*
21
- __ __
22
- | \/ | ___ _ _ ___ ___
21
+ __ __
22
+ | \/ | ___ _ _ ___ ___
23
23
| |\/| |/ _ \| | | / __|/ _ \
24
24
| | | | (_) | |_| \__ \ __/
25
25
|_| |_|\___/ \__,_|___/\___|
@@ -238,21 +238,21 @@ NAN_METHOD(setMouseDelay)
238
238
info.GetReturnValue ().Set (Nan::New (1 ));
239
239
}
240
240
241
- NAN_METHOD (scrollMouse)
241
+ NAN_METHOD (scrollMouse)
242
242
{
243
243
Nan::HandleScope scope;
244
244
245
245
// Get the values of magnitude and direction from the arguments list.
246
- if (info.Length () == 2 )
246
+ if (info.Length () == 2 )
247
247
{
248
248
int scrollMagnitude = info[0 ]->Int32Value ();
249
249
char *s;
250
250
251
251
Nan::Utf8String sstr (info[1 ]);
252
252
s = *sstr;
253
-
253
+
254
254
MMMouseWheelDirection scrollDirection;
255
-
255
+
256
256
if (strcmp (s, " up" ) == 0 )
257
257
{
258
258
scrollDirection = DIRECTION_UP;
@@ -265,26 +265,26 @@ NAN_METHOD(scrollMouse)
265
265
{
266
266
return Nan::ThrowError (" Invalid scroll direction specified." );
267
267
}
268
-
268
+
269
269
scrollMouse (scrollMagnitude, scrollDirection);
270
270
microsleep (mouseDelay);
271
-
271
+
272
272
info.GetReturnValue ().Set (Nan::New (1 ));
273
- }
274
- else
273
+ }
274
+ else
275
275
{
276
276
return Nan::ThrowError (" Invalid number of arguments." );
277
277
}
278
278
}
279
279
/*
280
- _ __ _ _
280
+ _ __ _ _
281
281
| |/ /___ _ _| |__ ___ __ _ _ __ __| |
282
282
| ' // _ \ | | | '_ \ / _ \ / _` | '__/ _` |
283
283
| . \ __/ |_| | |_) | (_) | (_| | | | (_| |
284
284
|_|\_\___|\__, |_.__/ \___/ \__,_|_| \__,_|
285
- |___/
285
+ |___/
286
286
*/
287
- struct KeyNames
287
+ struct KeyNames
288
288
{
289
289
const char * name;
290
290
MMKeyCode key;
@@ -324,7 +324,7 @@ static KeyNames key_names[] =
324
324
{ " space" , K_SPACE },
325
325
{ " printscreen" , K_PRINTSCREEN },
326
326
{ " insert" , K_INSERT },
327
-
327
+
328
328
{ " audio_mute" , K_AUDIO_VOLUME_MUTE },
329
329
{ " audio_vol_down" , K_AUDIO_VOLUME_DOWN },
330
330
{ " audio_vol_up" , K_AUDIO_VOLUME_UP },
@@ -337,7 +337,7 @@ static KeyNames key_names[] =
337
337
{ " audio_forward" , K_AUDIO_FORWARD },
338
338
{ " audio_repeat" , K_AUDIO_REPEAT },
339
339
{ " audio_random" , K_AUDIO_RANDOM },
340
-
340
+
341
341
{ " lights_mon_up" , K_LIGHTS_MON_UP },
342
342
{ " lights_mon_down" , K_LIGHTS_MON_DOWN },
343
343
{ " lights_kbd_toggle" ,K_LIGHTS_KBD_TOGGLE },
@@ -360,7 +360,7 @@ int CheckKeyCodes(char* k, MMKeyCode *key)
360
360
*key = K_NOT_A_KEY;
361
361
362
362
KeyNames* kn = key_names;
363
- while (kn->name )
363
+ while (kn->name )
364
364
{
365
365
if (strcmp (k, kn->name ) == 0 )
366
366
{
@@ -370,7 +370,7 @@ int CheckKeyCodes(char* k, MMKeyCode *key)
370
370
kn++;
371
371
}
372
372
373
- if (*key == K_NOT_A_KEY)
373
+ if (*key == K_NOT_A_KEY)
374
374
{
375
375
return -2 ;
376
376
}
@@ -578,9 +578,9 @@ NAN_METHOD(typeStringDelayed)
578
578
{
579
579
char *str;
580
580
Nan::Utf8String string (info[0 ]);
581
-
581
+
582
582
str = *string;
583
-
583
+
584
584
size_t cpm = info[1 ]->Int32Value ();
585
585
586
586
typeStringDelayed (str, cpm);
@@ -601,12 +601,12 @@ NAN_METHOD(setKeyboardDelay)
601
601
}
602
602
603
603
/*
604
- ____
605
- / ___| ___ _ __ ___ ___ _ __
606
- \___ \ / __| '__/ _ \/ _ \ '_ \
604
+ ____
605
+ / ___| ___ _ __ ___ ___ _ __
606
+ \___ \ / __| '__/ _ \/ _ \ '_ \
607
607
___) | (__| | | __/ __/ | | |
608
608
|____/ \___|_| \___|\___|_| |_|
609
-
609
+
610
610
*/
611
611
612
612
/* *
@@ -627,7 +627,7 @@ NAN_METHOD(getPixelColor)
627
627
{
628
628
return Nan::ThrowError (" Invalid number of arguments." );
629
629
}
630
-
630
+
631
631
MMBitmapRef bitmap;
632
632
MMRGBHex color;
633
633
@@ -642,9 +642,9 @@ NAN_METHOD(getPixelColor)
642
642
bitmap = copyMMBitmapFromDisplayInRect (MMRectMake (x, y, 1 , 1 ));
643
643
644
644
color = MMRGBHexAtPoint (bitmap, 0 , 0 );
645
-
645
+
646
646
char hex[7 ];
647
-
647
+
648
648
padHex (color, hex);
649
649
650
650
destroyMMBitmap (bitmap);
@@ -666,18 +666,18 @@ NAN_METHOD(getScreenSize)
666
666
info.GetReturnValue ().Set (obj);
667
667
}
668
668
669
- NAN_METHOD (captureScreen)
669
+ NAN_METHOD (captureScreen)
670
670
{
671
671
size_t x;
672
672
size_t y;
673
673
size_t w;
674
674
size_t h;
675
-
676
- // If user has provided screen coords, use them!
675
+
676
+ // If user has provided screen coords, use them!
677
677
if (info.Length () == 4 )
678
678
{
679
679
// TODO: Make sure requested coords are within the screen bounds, or we get a seg fault.
680
- // An error message is much nicer!
680
+ // An error message is much nicer!
681
681
682
682
x = info[0 ]->Int32Value ();
683
683
y = info[1 ]->Int32Value ();
@@ -689,15 +689,15 @@ NAN_METHOD(captureScreen)
689
689
// We're getting the full screen.
690
690
x = 0 ;
691
691
y = 0 ;
692
-
692
+
693
693
// Get screen size.
694
694
MMSize displaySize = getMainDisplaySize ();
695
695
w = displaySize.width ;
696
696
h = displaySize.height ;
697
697
}
698
-
698
+
699
699
MMBitmapRef bitmap = copyMMBitmapFromDisplayInRect (MMRectMake (x, y, w, h));
700
-
700
+
701
701
uint32_t bufferSize = bitmap->bytewidth * bitmap->height ;
702
702
Local<Object> buffer = Nan::NewBuffer ((char *)bitmap->imageBuffer , bufferSize, destroyMMBitmapBuffer, NULL ).ToLocalChecked ();
703
703
@@ -708,17 +708,17 @@ NAN_METHOD(captureScreen)
708
708
Nan::Set (obj, Nan::New (" bitsPerPixel" ).ToLocalChecked (), Nan::New<Number>(bitmap->bitsPerPixel ));
709
709
Nan::Set (obj, Nan::New (" bytesPerPixel" ).ToLocalChecked (), Nan::New<Number>(bitmap->bytesPerPixel ));
710
710
Nan::Set (obj, Nan::New (" image" ).ToLocalChecked (), buffer);
711
-
711
+
712
712
info.GetReturnValue ().Set (obj);
713
713
}
714
714
715
715
/*
716
- ____ _ _
717
- | __ )(_) |_ _ __ ___ __ _ _ __
718
- | _ \| | __| '_ ` _ \ / _` | '_ \
716
+ ____ _ _
717
+ | __ )(_) |_ _ __ ___ __ _ _ __
718
+ | _ \| | __| '_ ` _ \ / _` | '_ \
719
719
| |_) | | |_| | | | | | (_| | |_) |
720
- |____/|_|\__|_| |_| |_|\__,_| .__/
721
- |_|
720
+ |____/|_|\__|_| |_| |_|\__,_| .__/
721
+ |_|
722
722
*/
723
723
724
724
class BMP
@@ -733,7 +733,7 @@ class BMP
733
733
};
734
734
735
735
// Convert object from Javascript to a C++ class (BMP).
736
- BMP buildBMP (Local<Object> info)
736
+ BMP buildBMP (Local<Object> info)
737
737
{
738
738
Local<Object> obj = Nan::To<v8::Object>(info).ToLocalChecked ();
739
739
@@ -805,7 +805,7 @@ NAN_MODULE_INIT(InitAll)
805
805
806
806
Nan::Set (target, Nan::New (" mouseToggle" ).ToLocalChecked (),
807
807
Nan::GetFunction (Nan::New<FunctionTemplate>(mouseToggle)).ToLocalChecked ());
808
-
808
+
809
809
Nan::Set (target, Nan::New (" scrollMouse" ).ToLocalChecked (),
810
810
Nan::GetFunction (Nan::New<FunctionTemplate>(scrollMouse)).ToLocalChecked ());
811
811
@@ -832,10 +832,10 @@ NAN_MODULE_INIT(InitAll)
832
832
833
833
Nan::Set (target, Nan::New (" getScreenSize" ).ToLocalChecked (),
834
834
Nan::GetFunction (Nan::New<FunctionTemplate>(getScreenSize)).ToLocalChecked ());
835
-
835
+
836
836
Nan::Set (target, Nan::New (" captureScreen" ).ToLocalChecked (),
837
837
Nan::GetFunction (Nan::New<FunctionTemplate>(captureScreen)).ToLocalChecked ());
838
-
838
+
839
839
Nan::Set (target, Nan::New (" getColor" ).ToLocalChecked (),
840
840
Nan::GetFunction (Nan::New<FunctionTemplate>(getColor)).ToLocalChecked ());
841
841
}
0 commit comments