PFW-1404 Only create button event when the button is released
parent
0e625dc551
commit
b750cc21f4
|
|
@ -38,6 +38,8 @@ public:
|
|||
/// @param index of the button to check
|
||||
inline bool ButtonPressed(uint8_t index) const { return buttons[index].Pressed(); }
|
||||
|
||||
inline bool ButtonReleased(uint8_t index) const { return buttons[index].Released(); }
|
||||
|
||||
/// @returns true if any of the button is pressed
|
||||
inline bool AnyButtonPressed() const {
|
||||
for (uint8_t i = 0; i < config::buttonCount; ++i) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public:
|
|||
|
||||
/// @returns true if debounced value is currently considered as pressed
|
||||
inline bool Pressed() const { return f.state == State::WaitForRelease; }
|
||||
inline bool Released() const { return f.state == State::Update; }
|
||||
|
||||
/// State machine stepping routine
|
||||
void Step(uint16_t time, bool press);
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ namespace user_input {
|
|||
UserInput userInput;
|
||||
|
||||
void UserInput::Step() {
|
||||
if (buttons::buttons.ButtonPressed(mb::Left))
|
||||
if (buttons::buttons.ButtonReleased(mb::Left))
|
||||
eventQueue.push(Event::Left);
|
||||
if (buttons::buttons.ButtonPressed(mb::Middle))
|
||||
if (buttons::buttons.ButtonReleased(mb::Middle))
|
||||
eventQueue.push(Event::Middle);
|
||||
if (buttons::buttons.ButtonPressed(mb::Right))
|
||||
if (buttons::buttons.ButtonReleased(mb::Right))
|
||||
eventQueue.push(Event::Right);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue