-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
77 lines (73 loc) · 1.6 KB
/
main.cpp
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
#include "main.h"
#define NUM_BUTTONS 9
const uint8_t BUTTON_PINS[NUM_BUTTONS] = {2, 3, 4, 5, 6, 7, 8, 9, 18};
Bounce * buttons = new Bounce[NUM_BUTTONS];
void setup() {
Keyboard.begin();
for (int i = 0; i < NUM_BUTTONS; i++) {
buttons[i].attach( BUTTON_PINS[i] , INPUT_PULLUP );//setup the bounce instance for the current button
buttons[i].interval(25); // interval in ms
}
}
void loop() {
for (int i = 0; i < NUM_BUTTONS; i++) {
buttons[i].update();
if ( buttons[i].fell()) {
if(i<8){
buttonPressed(i);
}
if(i==8){
Keyboard.press(KEY_F19);
}
}
if(buttons[i].rose() & (i==8)){
Keyboard.release(KEY_F19);
}
}
}
void buttonPressed(int button){
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(KEY_LEFT_ALT);
Keyboard.press(KEY_LEFT_SHIFT);
switch (button)
{
case 7:
Keyboard.press(KEY_F23);
break;
case 0:
Keyboard.press(KEY_F24);
break;
case 6:
Keyboard.press(KEY_F13);
break;
case 5:
Keyboard.press(KEY_F14);
break;
case 4:
Keyboard.press(KEY_F15);
break;
case 3:
Keyboard.press(KEY_F16);
break;
case 2:
Keyboard.press(KEY_F17);
break;
case 1:
Keyboard.press(KEY_F18);
break;
default:
break;
}
delay(200);
Keyboard.release(KEY_LEFT_CTRL);
Keyboard.release(KEY_LEFT_ALT);
Keyboard.release(KEY_LEFT_SHIFT);
Keyboard.release(KEY_F23);
Keyboard.release(KEY_F24);
Keyboard.release(KEY_F13);
Keyboard.release(KEY_F14);
Keyboard.release(KEY_F15);
Keyboard.release(KEY_F16);
Keyboard.release(KEY_F17);
Keyboard.release(KEY_F18);
}