Add logic to handle button presses.
This commit is contained in:
parent
c814b85d59
commit
9ddb1a9529
2 changed files with 52 additions and 17 deletions
19
Joystick.h
19
Joystick.h
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue