Skip to content

Commit

Permalink
fix(lua): send EVT_VIRTUAL_EXIT only on short EXIT press (#2573)
Browse files Browse the repository at this point in the history
Fixes #2436
  • Loading branch information
raphaelcoeffic authored and pfeerick committed Oct 18, 2022
1 parent fea52bf commit 9f48769
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions radio/src/gui/colorlcd/LvglWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,12 @@ static bool evt_to_indev_data(event_t evt, lv_indev_data_t *data)
break;

case KEY_EXIT:
if (evt != EVT_KEY_LONG(KEY_EXIT)) {
if (evt == EVT_KEY_BREAK(KEY_EXIT)) {
data->key = LV_KEY_ESC;
} else {
// prevent subsequent RELEASE event
lv_indev_wait_release(lv_indev_get_act());
data->state = LV_INDEV_STATE_PRESSED;
return false;
return true;
}
break;
return false;

default:
// abort LVGL event
Expand All @@ -107,9 +104,9 @@ static void dispatch_kb_event(Window* w, event_t evt)
event_t key = EVT_KEY_MASK(evt);
if (evt == EVT_KEY_BREAK(KEY_ENTER)) {
w->onClicked();
} else if (evt == EVT_KEY_FIRST(KEY_EXIT)) {
} else if (evt == EVT_KEY_BREAK(KEY_EXIT)) {
w->onCancel();
} else if (key != KEY_ENTER /*&& key != KEY_EXIT*/) {
} else if (key != KEY_ENTER) {
w->onEvent(evt);
} else if (evt == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(KEY_ENTER);
Expand Down Expand Up @@ -157,6 +154,12 @@ static void keyboardDriverRead(lv_indev_drv_t *drv, lv_indev_data_t *data)

// no event: send a copy of the last one
copy_kb_data_backup(data);

// simulate EXIT release: necessary to map
// EVT_KEY_BREAK(KEY_EXIT) to LV_EVENT_CANCEL
if (data->key == KEY_EXIT && data->state == LV_INDEV_STATE_PRESSED) {
data->state = LV_INDEV_STATE_RELEASED;
}
}

static void copy_ts_to_indev_data(const TouchState &st, lv_indev_data_t *data)
Expand Down
1 change: 1 addition & 0 deletions radio/src/lua/lua_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ void LuaEventHandler::onCancel()

void LuaEventHandler::onEvent(event_t event)
{
if (event == EVT_KEY_LONG(KEY_EXIT)) killEvents(KEY_EXIT);
luaPushEvent(event);
}

Expand Down

0 comments on commit 9f48769

Please sign in to comment.