Rework the joystick code to use the Bounce2 library.

This commit is contained in:
2015-11-13 00:45:38 -05:00
parent 9ae0777c6b
commit f0cfcdc90d
3 changed files with 19 additions and 31 deletions

View File

@ -2,6 +2,7 @@
#define _JOYSTICK_H_
#include <Arduino.h>
#include <Bounce2.h>
// If you're using the arduino-big-joystick firmware, these numbers can't be
// changed. If you're writing your own Report Descriptor, tune these to match by
@ -26,10 +27,8 @@ struct JoyReport {
};
struct Button {
uint8_t pin;
ButtonType type;
uint8_t last_state;
bool pullup;
Bounce bouncher;
};
bool operator ==(JoyReport a, JoyReport b);
@ -54,7 +53,7 @@ class Joystick {
private:
void _ReleasePulsedButtons();
void _UpdateButton(Button& button, uint8_t index);
void _UpdateButton(uint8_t index);
void _UpdateAxis(uint8_t index);
Button _buttons[JOYSTICK_NUM_BUTTONS];