Add tap count support to simulator (#719)

* Removed unused #define
* Added touchState.tapCount for double taps etc. to simulator
This commit is contained in:
Jesper Frickmann
2021-09-14 16:30:39 +10:00
committed by GitHub
parent cc0c530f3f
commit 8d04b5112d
2 changed files with 17 additions and 1 deletions
-1
View File
@@ -34,7 +34,6 @@
#if defined(HARDWARE_TOUCH)
#include "touch.h"
#define EVT_TOUCH_TAP_TIME 25
#define EVT_TOUCH_SWIPE_LOCK 4
#define EVT_TOUCH_SWIPE_SPEED 60
#define EVT_TOUCH_SWIPE_TIMEOUT 50
@@ -32,6 +32,11 @@
int16_t g_anas[Analogs::NUM_ANALOGS];
QVector<QIODevice *> OpenTxSimulator::tracebackDevices;
tmr10ms_t downTime = 0;
tmr10ms_t tapTime = 0;
short tapCount = 0;
#define TAP_TIME 25
uint16_t anaIn(uint8_t chan)
{
return g_anas[chan];
@@ -301,6 +306,9 @@ void OpenTxSimulator::rotaryEncoderEvent(int steps)
void OpenTxSimulator::touchEvent(int type, int x, int y)
{
tmr10ms_t now = get_tmr10ms();
touchState.tapCount = 0;
switch (type) {
case TouchDown:
TRACE_WINDOWS("[Mouse Press] %d %d", x, y);
@@ -309,6 +317,7 @@ void OpenTxSimulator::touchEvent(int type, int x, int y)
touchState.event = TE_DOWN;
touchState.startX = touchState.x = x;
touchState.startY = touchState.y = y;
downTime = now;
#endif
break;
@@ -320,6 +329,14 @@ void OpenTxSimulator::touchEvent(int type, int x, int y)
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;
}