-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHID-Bridge_USB.ino
More file actions
66 lines (62 loc) · 1.32 KB
/
HID-Bridge_USB.ino
File metadata and controls
66 lines (62 loc) · 1.32 KB
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
#include "HID-Project.h"
#define INPUT_SIZE 80
void setup() {
Serial1.begin(115200);
Gamepad.begin();
}
/*
* DU,DD,DL,DR,LXAXIS,LYAXIS,RAXIS,RYAXIS,L1,L2,L3,R1,R2,R3,X,S,C,T,SEL,STR
* 0,000,000,000,000,0,0,0,0,0,0,0,0,0,0,0,0\n
*/
void loop() {
if(Serial1.available() > 0){
char input[INPUT_SIZE];
byte size = Serial1.readBytesUntil('\n', input, INPUT_SIZE);
char* command = strtok(input, ",\n");
unsigned short int count = 0;
while (command != NULL)
{
switch(count){
case 0:
Gamepad.xAxis(atoi(command));
break;
case 1:
Gamepad.yAxis(atoi(command));
break;
case 2:
Gamepad.rxAxis(atoi(command));
break;
case 3:
Gamepad.ryAxis(atoi(command));
break;
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
if(atoi(command) == 1){
Gamepad.press(count);
} else {
Gamepad.release(count);
}
default:
break;
}
command = strtok(NULL, ",\n");
count++;
}
Gamepad.write();
}
}