|
@@ -36,6 +36,7 @@ JoystickEventsCPPM::JoystickEventsCPPM(JoystickEvents* client) : JoystickEvents(
|
36
|
36
|
}
|
37
|
37
|
|
38
|
38
|
void JoystickEventsCPPM::OnGamePadChanged(const GamePadEventData& evt) {
|
|
39
|
+ // up to CHANNEL_AUX2 we are using axes
|
39
|
40
|
for (uint8_t i = 0; i < (CHANNEL_AUX2 + 1); i++) {
|
40
|
41
|
uint16_t value = ((int32_t)getJoystickAxis(evt, i)) + trim[i];
|
41
|
42
|
values[i] = map(value, 0, getJoystickMax(i),
|
|
@@ -49,6 +50,31 @@ void JoystickEventsCPPM::OnGamePadChanged(const GamePadEventData& evt) {
|
49
|
50
|
}
|
50
|
51
|
}
|
51
|
52
|
|
|
53
|
+void JoystickEventsCPPM::OnButtonUp(uint8_t but_id) {
|
|
54
|
+ // if you want to do something when a button is released
|
|
55
|
+ // do it here...
|
|
56
|
+
|
|
57
|
+ if (client) {
|
|
58
|
+ client->OnButtonUp(but_id);
|
|
59
|
+ }
|
|
60
|
+}
|
|
61
|
+
|
|
62
|
+void JoystickEventsCPPM::OnButtonDown(uint8_t but_id) {
|
|
63
|
+ // called when a button is pressed
|
|
64
|
+ if (but_id == 42) { // TODO proper button id
|
|
65
|
+ // set CHANNEL_AUX3 according to button
|
|
66
|
+ values[CHANNEL_AUX3] = 1000;
|
|
67
|
+ } else if (but_id == 23) { // TODO proper button id
|
|
68
|
+ values[CHANNEL_AUX3] = 2000;
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ CPPM::instance().copy(values);
|
|
72
|
+
|
|
73
|
+ if (client) {
|
|
74
|
+ client->OnButtonDown(but_id);
|
|
75
|
+ }
|
|
76
|
+}
|
|
77
|
+
|
52
|
78
|
uint16_t JoystickEventsCPPM::getJoystickAxis(const GamePadEventData& evt, uint8_t ch) {
|
53
|
79
|
if (ch == CHANNEL_ROLL) {
|
54
|
80
|
return evt.X;
|