Update widgets

This commit is contained in:
IlyaShurupov 2024-05-07 12:04:36 +03:00 committed by Ilya Shurupov
parent 35cb553ecb
commit 0f8fb5c580
18 changed files with 171 additions and 124 deletions

View file

@ -21,16 +21,16 @@ bool EventHandler::isEvents() {
InputState::State transitions[4][4] = {
{ InputState::State::NONE, InputState::State::PRESSED, InputState::State::PRESSED, InputState::State::NONE },
{ InputState::State::PRESSED, InputState::State::PRESSED, InputState::State::HOLD, InputState::State::PRESSED },
{ InputState::State::HOLD, InputState::State::RELEASED, InputState::State::RELEASED, InputState::State::HOLD },
{ InputState::State::RELEASED, InputState::State::NONE, InputState::State::NONE, InputState::State::RELEASED },
{ InputState::State::PRESSED, InputState::State::HOLD, InputState::State::HOLD, InputState::State::HOLD },
{ InputState::State::HOLD, InputState::State::HOLD, InputState::State::HOLD, InputState::State::RELEASED },
{ InputState::State::NONE, InputState::State::NONE, InputState::State::NONE, InputState::State::NONE },
};
bool transitionsReduce[4][4] = {
{ true, true, false, true },
{ true, true, false, true },
{ true, false, false, true },
{ true, false, true, true },
{ true, true, true, false },
{ true, true, true, false },
{ true, true, true, true },
};
void EventHandler::processEvent() {
@ -55,6 +55,8 @@ void EventHandler::processEvent() {
mInputStates[(int) inputId].mCurrentState = transitions[currentState][reportedEvent];
// printf("%i - %i \n", reportedEvent, mInputStates[(int) InputID::A].mCurrentState);
if (transitionsReduce[currentState][reportedEvent]) {
mEventQueue.popFront();
}

View file

@ -20,6 +20,7 @@ namespace tp {
enum class ButtonAction {
NONE = 0,
PRESS,
HOLD,
RELEASE,
REPEAT,
} buttonAction = ButtonAction::NONE;
@ -42,7 +43,7 @@ namespace tp {
// Transitions from state to state is strict and defined by state order in the enum
// If posted event conflicts with that automata, we need to emulate intermediate states
enum State {
NONE = 0, // Button is inactive
NONE = 0, // Button is inactive
PRESSED, // Button is pressed
HOLD, // Button is still pressed
RELEASED, // Button is released
@ -61,7 +62,6 @@ namespace tp {
~EventHandler();
public: // Event Poster Interface
// Record event
void postEvent(InputID inputID, InputEvent inputEvent);