forked from Piorosen/SSvJoy-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSvJoy.ino
More file actions
75 lines (70 loc) · 1.73 KB
/
SSvJoy.ino
File metadata and controls
75 lines (70 loc) · 1.73 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
67
68
69
70
71
72
73
74
75
#include <Joystick.h>
#include "option.h"
#include "parser.h"
Joystick_ Joystick;
void setup() {
Serial.begin(115200);
Joystick.begin();
callback = [](Type type, byte id, Data data, byte checksum, bool chk) {
switch (type) {
case Type::Button:
Joystick.setButton(id, data.Axis);
break;
case Type::AxisX:
Joystick.setXAxis(data.Axis);
break;
case Type::AxisY:
Joystick.setYAxis(data.Axis);
break;
case Type::AxisZ:
Joystick.setZAxis(data.Axis);
break;
case Type::AxisRotX:
Joystick.setRxAxis(data.Axis);
break;
case Type::AxisRotY:
Joystick.setRyAxis(data.Axis);
break;
case Type::AxisRotZ:
Joystick.setRzAxis(data.Axis);
break;
case Type::Rudder:
Joystick.setRudder(data.Axis);
break;
case Type::Throttle:
Joystick.setThrottle(data.Axis);
break;
case Type::Accelerator:
Joystick.setAccelerator(data.Axis);
break;
case Type::Brake:
Joystick.setBrake(data.Axis);
break;
case Type::Steering:
Joystick.setSteering(data.Axis);
break;
}
// 시간 문제로 출력문 주석처리.
// Serial.print("Type : ");
// Serial.print((int)type);
// Serial.print("\tData : ");
// Serial.print(data.Axis);
// Serial.print(" : ");
// Serial.print(data.Value);
// Serial.print("\tCheck : ");
// Serial.print(checksum);
// Serial.print(" : ");
// Serial.print(chk);
// Serial.print("\n");
};
error = []() {
Serial.print("Error !!!\n");
};
}
void loop() {
if (Serial.available() > 0) {
auto key = Serial.read();
read_next(key);
}
delay(50);
}