Fix code to compile, now that I am in an environment where I can compile. This commit not tested.
This commit is contained in:
parent
f2d7f48d43
commit
9af6a589f8
15
Joystick.cpp
15
Joystick.cpp
|
@ -1,10 +1,19 @@
|
|||
#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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ typedef struct JoyReport {
|
|||
uint8_t button[JOYSTICK_NUM_BYTES];
|
||||
} ;
|
||||
|
||||
bool operator ==(JoyReport a, JoyReport b);
|
||||
bool operator !=(JoyReport a, JoyReport b);
|
||||
|
||||
class Joystick {
|
||||
public:
|
||||
Joystick(bool debug=false);
|
||||
|
@ -49,6 +52,7 @@ class Joystick {
|
|||
uint8_t last_state;
|
||||
} _buttons[JOYSTICK_NUM_BUTTONS];
|
||||
uint8_t _num_buttons;
|
||||
bool _have_pulsed_button;
|
||||
|
||||
uint8_t _axes[JOYSTICK_NUM_AXES];
|
||||
uint8_t _num_axes;
|
||||
|
|
Loading…
Reference in New Issue
Block a user