Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lua): deliver EVT_TOUCH_RELEASE event #5587

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions radio/src/lua/lua_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void LuaEventHandler::event_cb(lv_event_t* e)
auto win = (Window*)lv_obj_get_user_data(obj);
if (!win) return;

lv_event_code_t code = lv_event_get_code(e);
const lv_event_code_t code = lv_event_get_code(e);
if (code == LV_EVENT_KEY) {
uint32_t key = *(uint32_t*)lv_event_get_param(e);
if (key == LV_KEY_LEFT) {
Expand Down Expand Up @@ -90,9 +90,7 @@ void LuaEventHandler::event_cb(lv_event_t* e)

// If we already have a SLIDE going, then accumulate slide values instead
// of allocating an empty slot
LuaEventData* es = luaGetEventSlot(EVT_TOUCH_SLIDE);

if (es) {
if (LuaEventData* const es = luaGetEventSlot(EVT_TOUCH_SLIDE); es) {
es->event = EVT_TOUCH_SLIDE;
es->touchX = rel_pos.x;
es->touchY = rel_pos.y;
Expand All @@ -103,8 +101,7 @@ void LuaEventHandler::event_cb(lv_event_t* e)
TRACE("EVT_TOUCH_SLIDE [%d,%d]", rel_pos.x, rel_pos.y);
}
} else {
LuaEventData* es = luaGetEventSlot();
if (es) {
if (LuaEventData* const es = luaGetEventSlot(); es) {
es->event = EVT_TOUCH_FIRST;
es->touchX = rel_pos.x;
es->touchY = rel_pos.y;
Expand All @@ -117,6 +114,11 @@ void LuaEventHandler::event_cb(lv_event_t* e)
downTime = RTOS_GET_MS();
}
} else if (code == LV_EVENT_RELEASED) {
if (LuaEventData* const es = luaGetEventSlot(); es) {
es->event = EVT_TOUCH_BREAK;
TRACE("EVT_TOUCH_BREAK");
}

// tap count handling
uint32_t now = RTOS_GET_MS();
if (now - downTime <= LUA_TAP_TIME) {
Expand All @@ -142,19 +144,16 @@ void LuaEventHandler::onClicked()
lv_point_t point_act;
lv_indev_get_point(click_source, &point_act);

LuaEventData* es = luaGetEventSlot();
LuaEventData* const es = luaGetEventSlot();
if (!es) return;

if (tapCount > 0) {
es->event = EVT_TOUCH_TAP;
es->tapCount = tapCount;
} else {
es->event = EVT_TOUCH_BREAK;
es->touchX = point_act.x;
es->touchY = point_act.y;
}

es->touchX = point_act.x;
es->touchY = point_act.y;

_sliding = false;
return;
}
Expand Down