feat(lua): deliver EVT_TOUCH_RELEASE event (#5587)
This commit is contained in:
@@ -45,7 +45,7 @@ void LuaEventHandler::event_cb(lv_event_t* e)
|
|||||||
auto win = (Window*)lv_obj_get_user_data(obj);
|
auto win = (Window*)lv_obj_get_user_data(obj);
|
||||||
if (!win) return;
|
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) {
|
if (code == LV_EVENT_KEY) {
|
||||||
uint32_t key = *(uint32_t*)lv_event_get_param(e);
|
uint32_t key = *(uint32_t*)lv_event_get_param(e);
|
||||||
if (key == LV_KEY_LEFT) {
|
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
|
// If we already have a SLIDE going, then accumulate slide values instead
|
||||||
// of allocating an empty slot
|
// of allocating an empty slot
|
||||||
LuaEventData* es = luaGetEventSlot(EVT_TOUCH_SLIDE);
|
if (LuaEventData* const es = luaGetEventSlot(EVT_TOUCH_SLIDE); es) {
|
||||||
|
|
||||||
if (es) {
|
|
||||||
es->event = EVT_TOUCH_SLIDE;
|
es->event = EVT_TOUCH_SLIDE;
|
||||||
es->touchX = rel_pos.x;
|
es->touchX = rel_pos.x;
|
||||||
es->touchY = rel_pos.y;
|
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);
|
TRACE("EVT_TOUCH_SLIDE [%d,%d]", rel_pos.x, rel_pos.y);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LuaEventData* es = luaGetEventSlot();
|
if (LuaEventData* const es = luaGetEventSlot(); es) {
|
||||||
if (es) {
|
|
||||||
es->event = EVT_TOUCH_FIRST;
|
es->event = EVT_TOUCH_FIRST;
|
||||||
es->touchX = rel_pos.x;
|
es->touchX = rel_pos.x;
|
||||||
es->touchY = rel_pos.y;
|
es->touchY = rel_pos.y;
|
||||||
@@ -117,6 +114,11 @@ void LuaEventHandler::event_cb(lv_event_t* e)
|
|||||||
downTime = RTOS_GET_MS();
|
downTime = RTOS_GET_MS();
|
||||||
}
|
}
|
||||||
} else if (code == LV_EVENT_RELEASED) {
|
} else if (code == LV_EVENT_RELEASED) {
|
||||||
|
if (LuaEventData* const es = luaGetEventSlot(); es) {
|
||||||
|
es->event = EVT_TOUCH_BREAK;
|
||||||
|
TRACE("EVT_TOUCH_BREAK");
|
||||||
|
}
|
||||||
|
|
||||||
// tap count handling
|
// tap count handling
|
||||||
uint32_t now = RTOS_GET_MS();
|
uint32_t now = RTOS_GET_MS();
|
||||||
if (now - downTime <= LUA_TAP_TIME) {
|
if (now - downTime <= LUA_TAP_TIME) {
|
||||||
@@ -142,19 +144,16 @@ void LuaEventHandler::onClicked()
|
|||||||
lv_point_t point_act;
|
lv_point_t point_act;
|
||||||
lv_indev_get_point(click_source, &point_act);
|
lv_indev_get_point(click_source, &point_act);
|
||||||
|
|
||||||
LuaEventData* es = luaGetEventSlot();
|
LuaEventData* const es = luaGetEventSlot();
|
||||||
if (!es) return;
|
if (!es) return;
|
||||||
|
|
||||||
if (tapCount > 0) {
|
if (tapCount > 0) {
|
||||||
es->event = EVT_TOUCH_TAP;
|
es->event = EVT_TOUCH_TAP;
|
||||||
es->tapCount = tapCount;
|
es->tapCount = tapCount;
|
||||||
} else {
|
es->touchX = point_act.x;
|
||||||
es->event = EVT_TOUCH_BREAK;
|
es->touchY = point_act.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
es->touchX = point_act.x;
|
|
||||||
es->touchY = point_act.y;
|
|
||||||
|
|
||||||
_sliding = false;
|
_sliding = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user