@@ -30,6 +30,9 @@
|
|||||||
#define MAX_INSTRUCTIONS (20000/100)
|
#define MAX_INSTRUCTIONS (20000/100)
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
uint32_t LuaEventHandler::downTime = 0;
|
||||||
|
uint32_t LuaEventHandler::tapTime = 0;
|
||||||
|
uint32_t LuaEventHandler::tapCount = 0;
|
||||||
tmr10ms_t LuaEventHandler::swipeTimeOut = 0;
|
tmr10ms_t LuaEventHandler::swipeTimeOut = 0;
|
||||||
coord_t LuaEventHandler::_startX;
|
coord_t LuaEventHandler::_startX;
|
||||||
coord_t LuaEventHandler::_startY;
|
coord_t LuaEventHandler::_startY;
|
||||||
@@ -108,6 +111,21 @@ void LuaEventHandler::event_cb(lv_event_t* e)
|
|||||||
|
|
||||||
_startX = rel_pos.x;
|
_startX = rel_pos.x;
|
||||||
_startY = rel_pos.y;
|
_startY = rel_pos.y;
|
||||||
|
|
||||||
|
downTime = RTOS_GET_MS();
|
||||||
|
}
|
||||||
|
} else if (code == LV_EVENT_RELEASED) {
|
||||||
|
// tap count handling
|
||||||
|
uint32_t now = RTOS_GET_MS();
|
||||||
|
if (now - downTime <= LUA_TAP_TIME) {
|
||||||
|
if (now - tapTime > LUA_TAP_TIME) {
|
||||||
|
tapCount = 1;
|
||||||
|
} else {
|
||||||
|
tapCount++;
|
||||||
|
}
|
||||||
|
tapTime = now;
|
||||||
|
} else {
|
||||||
|
tapCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -126,10 +144,16 @@ void LuaEventHandler::onClicked()
|
|||||||
LuaEventData* es = luaGetEventSlot();
|
LuaEventData* es = luaGetEventSlot();
|
||||||
if (!es) return;
|
if (!es) return;
|
||||||
|
|
||||||
es->event = EVT_TOUCH_TAP;
|
if (tapCount > 0) {
|
||||||
|
es->event = EVT_TOUCH_TAP;
|
||||||
|
es->tapCount = tapCount;
|
||||||
|
} else {
|
||||||
|
es->event = EVT_TOUCH_BREAK;
|
||||||
|
}
|
||||||
|
|
||||||
es->touchX = point_act.x;
|
es->touchX = point_act.x;
|
||||||
es->touchY = point_act.y;
|
es->touchY = point_act.y;
|
||||||
es->tapCount = 1;
|
|
||||||
_sliding = false;
|
_sliding = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,16 @@
|
|||||||
|
|
||||||
#include "opentx_types.h"
|
#include "opentx_types.h"
|
||||||
|
|
||||||
|
#define LUA_TAP_TIME 250 // 250 ms
|
||||||
|
|
||||||
class LuaEventHandler
|
class LuaEventHandler
|
||||||
{
|
{
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
|
// "tap" handling
|
||||||
|
static uint32_t downTime;
|
||||||
|
static uint32_t tapTime;
|
||||||
|
static uint32_t tapCount;
|
||||||
|
// "swipe" / "slide" handling
|
||||||
static tmr10ms_t swipeTimeOut;
|
static tmr10ms_t swipeTimeOut;
|
||||||
static bool _sliding;
|
static bool _sliding;
|
||||||
static coord_t _startX;
|
static coord_t _startX;
|
||||||
|
|||||||
Reference in New Issue
Block a user