Fix code to compile, now that I am in an environment where I can compile. This commit not tested.
This commit is contained in:
17
Joystick.cpp
17
Joystick.cpp
@ -1,11 +1,20 @@
|
||||
#include "Joystick.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
bool operator ==(JoyReport a, JoyReport b){
|
||||
return a.axis == b.axis && a.button == b.button;
|
||||
}
|
||||
|
||||
bool operator !=(JoyReport a, JoyReport b){
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
Joystick::Joystick(bool debug) {
|
||||
_debug = debug;
|
||||
_num_buttons = 0;
|
||||
_num_axes = 0;
|
||||
|
||||
_have_pulsed_button = false;
|
||||
|
||||
for (uint8_t i=0; i < JOYSTICK_NUM_AXES; i++) {
|
||||
_joyReport.axis[i] = 0;
|
||||
}
|
||||
@ -29,6 +38,10 @@ void Joystick::AddButton(uint8_t pin, ButtonType type, bool pullup) {
|
||||
_buttons[_num_buttons].type = type;
|
||||
_buttons[_num_buttons].last_state = digitalRead(pin);
|
||||
_num_buttons++;
|
||||
|
||||
if (type == BUTTON_PULSED || type == BUTTON_PULSED_DOUBLE_ACTION) {
|
||||
_have_pulsed_button = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Joystick::AddAxis(uint8_t pin) {
|
||||
@ -51,7 +64,7 @@ void Joystick::Update() {
|
||||
}
|
||||
|
||||
if (_joyReport != oldReport) {
|
||||
Serial.write(_joyReport);
|
||||
Write();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user