-
Notifications
You must be signed in to change notification settings - Fork 4
/
razar_logitech_other_mouse.ino
100 lines (82 loc) · 1.82 KB
/
razar_logitech_other_mouse.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <Mouse.h>
#include <hiduniversal.h>
#include "hidmouserptparser.h"
USB Usb;
HIDUniversal Hid(&Usb);
HIDMouseReportParser Mou(nullptr);
void setup() {
Mouse.begin();
Serial.begin(115200);
Serial.println("Start");
if (Usb.Init() == -1)
Serial.println("OSC did not start.");
delay(200);
if (!Hid.SetReportParser(0, &Mou))
ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
}
void loop() {
Usb.Task();
}
void onButtonDown(uint16_t buttonId) {
Mouse.press(buttonId);
Serial.print("Button ");
switch (buttonId) {
case MOUSE_LEFT:
Serial.print("MOUSE_LEFT");
break;
case MOUSE_RIGHT:
Serial.print("MOUSE_RIGHT");
break;
case MOUSE_MIDDLE:
Serial.print("MOUSE_MIDDLE");
break;
case MOUSE_BUTTON4:
Serial.print("MOUSE_BUTTON4");
break;
case MOUSE_BUTTON5:
Serial.print("MOUSE_BUTTON5");
break;
default:
Serial.print("OTHER_BUTTON");
break;
}
Serial.println(" pressed");
}
void onButtonUp(uint16_t buttonId) {
Mouse.release(buttonId);
Serial.print("Button ");
switch (buttonId) {
case MOUSE_LEFT:
Serial.print("MOUSE_LEFT");
break;
case MOUSE_RIGHT:
Serial.print("MOUSE_RIGHT");
break;
case MOUSE_MIDDLE:
Serial.print("MOUSE_MIDDLE");
break;
case MOUSE_BUTTON4:
Serial.print("MOUSE_BUTTON4");
break;
case MOUSE_BUTTON5:
Serial.print("MOUSE_BUTTON5");
break;
default:
Serial.print("OTHER_BUTTON");
break;
}
Serial.println(" released");
}
void onTiltPress(int8_t tiltValue) {
Serial.print("Tilt pressed: ");
Serial.println(tiltValue);
}
void onMouseMove(int8_t xMovement, int8_t yMovement, int8_t scrollValue) {
Mouse.move(xMovement, yMovement, scrollValue);
Serial.print("Mouse moved:\t");
Serial.print(xMovement);
Serial.print("\t");
Serial.print(yMovement);
Serial.print("\t");
Serial.println(scrollValue);
}