From 3c3a2dfb036fa38a8d14bbc08fa865b9570ee52e Mon Sep 17 00:00:00 2001 From: Wilhelm Date: Fri, 18 Oct 2024 01:24:27 +0200 Subject: [PATCH] feat(lua): deliver EVT_TOUCH_RELEASE event (#5587) --- radio/src/lua/lua_widget.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/radio/src/lua/lua_widget.cpp b/radio/src/lua/lua_widget.cpp index 35a696e47..cb3fb3954 100644 --- a/radio/src/lua/lua_widget.cpp +++ b/radio/src/lua/lua_widget.cpp @@ -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) { @@ -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; @@ -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; @@ -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) { @@ -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; }