Add tap count support to simulator (#719)
* Removed unused #define * Added touchState.tapCount for double taps etc. to simulator
This commit is contained in:
@@ -34,7 +34,6 @@
|
|||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#define EVT_TOUCH_TAP_TIME 25
|
|
||||||
#define EVT_TOUCH_SWIPE_LOCK 4
|
#define EVT_TOUCH_SWIPE_LOCK 4
|
||||||
#define EVT_TOUCH_SWIPE_SPEED 60
|
#define EVT_TOUCH_SWIPE_SPEED 60
|
||||||
#define EVT_TOUCH_SWIPE_TIMEOUT 50
|
#define EVT_TOUCH_SWIPE_TIMEOUT 50
|
||||||
|
|||||||
@@ -32,6 +32,11 @@
|
|||||||
int16_t g_anas[Analogs::NUM_ANALOGS];
|
int16_t g_anas[Analogs::NUM_ANALOGS];
|
||||||
QVector<QIODevice *> OpenTxSimulator::tracebackDevices;
|
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)
|
uint16_t anaIn(uint8_t chan)
|
||||||
{
|
{
|
||||||
return g_anas[chan];
|
return g_anas[chan];
|
||||||
@@ -301,6 +306,9 @@ void OpenTxSimulator::rotaryEncoderEvent(int steps)
|
|||||||
|
|
||||||
void OpenTxSimulator::touchEvent(int type, int x, int y)
|
void OpenTxSimulator::touchEvent(int type, int x, int y)
|
||||||
{
|
{
|
||||||
|
tmr10ms_t now = get_tmr10ms();
|
||||||
|
touchState.tapCount = 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TouchDown:
|
case TouchDown:
|
||||||
TRACE_WINDOWS("[Mouse Press] %d %d", x, y);
|
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.event = TE_DOWN;
|
||||||
touchState.startX = touchState.x = x;
|
touchState.startX = touchState.x = x;
|
||||||
touchState.startY = touchState.y = y;
|
touchState.startY = touchState.y = y;
|
||||||
|
downTime = now;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -320,6 +329,14 @@ void OpenTxSimulator::touchEvent(int type, int x, int y)
|
|||||||
touchState.event = TE_UP;
|
touchState.event = TE_UP;
|
||||||
touchState.x = touchState.startX;
|
touchState.x = touchState.startX;
|
||||||
touchState.y = touchState.startY;
|
touchState.y = touchState.startY;
|
||||||
|
if (now - downTime <= TAP_TIME) {
|
||||||
|
if (now - tapTime > TAP_TIME)
|
||||||
|
tapCount = 1;
|
||||||
|
else
|
||||||
|
tapCount++;
|
||||||
|
touchState.tapCount = tapCount;
|
||||||
|
tapTime = now;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
touchState.event = TE_SLIDE_END;
|
touchState.event = TE_SLIDE_END;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user