Add tap count support to simu

This commit is contained in:
Peter Feerick
2021-09-14 19:33:37 +10:00
parent 954eeaedc0
commit 6167d93651
+21
View File
@@ -42,6 +42,13 @@
#define W2 LCD_W*LCD_ZOOM
#define H2 LCD_H*LCD_ZOOM
#define TAP_TIME 25
tmr10ms_t now = 0;
tmr10ms_t downTime = 0;
tmr10ms_t tapTime = 0;
short tapCount = 0;
class OpenTxSim: public FXMainWindow
{
FXDECLARE(OpenTxSim)
@@ -259,10 +266,14 @@ long OpenTxSim::onMouseDown(FXObject *, FXSelector, void * v)
TRACE_WINDOWS("[Mouse Press] %d %d", evt->win_x, evt->win_y);
now = get_tmr10ms();
touchState.tapCount = 0;
#if defined(HARDWARE_TOUCH)
touchState.event = TE_DOWN;
touchState.startX = touchState.x = evt->win_x;
touchState.startY = touchState.y = evt->win_y;
downTime = now;
#endif
return 0;
@@ -275,11 +286,21 @@ long OpenTxSim::onMouseUp(FXObject*,FXSelector,void*v)
TRACE_WINDOWS("[Mouse Release] %d %d", evt->win_x, evt->win_y);
now = get_tmr10ms();
#if defined(HARDWARE_TOUCH)
if (touchState.event == TE_DOWN) {
touchState.event = TE_UP;
touchState.x = touchState.startX;
touchState.y = touchState.startY;
if (now - downTime <= TAP_TIME) {
if (now - tapTime > TAP_TIME)
tapCount = 1;
else
tapCount++;
touchState.tapCount = tapCount;
tapTime = now;
}
}
else {
touchState.event = TE_SLIDE_END;