-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (37 loc) · 844 Bytes
/
main.cpp
File metadata and controls
49 lines (37 loc) · 844 Bytes
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
// Compile with PlatformIO / leonardo board
// Adjust platformio.ini as needed
// Hardware: CJMCU BEETLE Keyboard BadUSB
#include <Arduino.h>
#include <HID-Project.h>
signed char mouseData[] = {2,0,45, 2,0,48, 0,2,36, 0,2,40, -2,0,48, -2,0,45, 0,-2,45, 0,-2,46};
int steps = sizeof(mouseData);
int toggle = 0;
int count = 50;
void move();
void setup() {
Mouse.begin();
randomSeed(analogRead(0));
}
void loop() {
if(count-- < 0) {
move();
count = random(40, 50);
}
delay(1000);
}
void move() {
int inx = 0;
while(inx < steps) {
int x = mouseData[inx];
int y = mouseData[inx+1];
int wait = mouseData[inx+2];
if(toggle) {
x = -x;
y = -y;
}
Mouse.move(x, y, 0);
delay(wait);
inx += 3;
}
toggle = toggle ^ 1;
}