Add logic to handle button presses.

This commit is contained in:
Anna Rose Wiggins 2015-11-11 00:10:45 -05:00
parent c814b85d59
commit 9ddb1a9529
2 changed files with 52 additions and 17 deletions

View file

@ -20,10 +20,17 @@ enum ButtonType {
BUTTON_PULSED_DOUBLE_ACTION = 0x4
};
typedef struct JoyReport {
struct JoyReport {
int16_t axis[JOYSTICK_NUM_AXES];
uint8_t button[JOYSTICK_NUM_BYTES];
} ;
};
struct Button {
uint8_t pin;
ButtonType type;
uint8_t last_state;
bool pullup;
};
bool operator ==(JoyReport a, JoyReport b);
bool operator !=(JoyReport a, JoyReport b);
@ -47,12 +54,10 @@ class Joystick {
private:
void _ReleasePulsedButtons();
void _UpdateButton(Button& button, uint8_t index);
void _UpdateAxis(uint8_t index);
struct {
uint8_t pin;
ButtonType type;
uint8_t last_state;
} _buttons[JOYSTICK_NUM_BUTTONS];
Button _buttons[JOYSTICK_NUM_BUTTONS];
uint8_t _num_buttons;
bool _have_pulsed_button;