-
-
Notifications
You must be signed in to change notification settings - Fork 406
/
Copy pathAbsoluteMouse.ino
69 lines (53 loc) · 1.64 KB
/
AbsoluteMouse.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.
AbsoluteMouse example
Press a button to click, moveTo the mouse.
You may also use SingleAbsoluteMouse to use a single report.
See HID Project documentation for more infos
https://github.com/NicoHood/HID/wiki/Mouse-API
https://github.com/NicoHood/HID/wiki/AbsoluteMouse-API
*/
#include "HID-Project.h"
const int pinLed = LED_BUILTIN;
const int pinButtonClick = 2;
const int pinButtonCenter = 3;
const int pinButtonMove = 1;
void setup() {
// Prepare led + buttons
pinMode(pinLed, OUTPUT);
pinMode(pinButtonClick, INPUT_PULLUP);
pinMode(pinButtonCenter, INPUT_PULLUP);
pinMode(pinButtonMove, INPUT_PULLUP);
// Sends a clean report to the host. This is important on any Arduino type.
AbsoluteMouse.begin();
}
void loop() {
if (!digitalRead(pinButtonClick)) {
digitalWrite(pinLed, HIGH);
// Same use as the official library, pretty much self explaining
AbsoluteMouse.click();
//AbsoluteMouse.click(MOUSE_RIGHT);
// Simple debounce
delay(300);
digitalWrite(pinLed, LOW);
}
if (!digitalRead(pinButtonCenter)) {
digitalWrite(pinLed, HIGH);
// Move to coordinate (16bit signed, -32768 - 32767)
// Moving to the same position twice will not work!
// X and Y start in the upper left corner.
AbsoluteMouse.moveTo(0, 0);
// Simple debounce
delay(300);
digitalWrite(pinLed, LOW);
}
if (!digitalRead(pinButtonMove)) {
digitalWrite(pinLed, HIGH);
// Move relative to last coordinate
AbsoluteMouse.move(1000, 1000);
// Simple debounce
delay(300);
digitalWrite(pinLed, LOW);
}
}