Add tap count support to simu
This commit is contained in:
@@ -42,6 +42,13 @@
|
|||||||
#define W2 LCD_W*LCD_ZOOM
|
#define W2 LCD_W*LCD_ZOOM
|
||||||
#define H2 LCD_H*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
|
class OpenTxSim: public FXMainWindow
|
||||||
{
|
{
|
||||||
FXDECLARE(OpenTxSim)
|
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);
|
TRACE_WINDOWS("[Mouse Press] %d %d", evt->win_x, evt->win_y);
|
||||||
|
|
||||||
|
now = get_tmr10ms();
|
||||||
|
touchState.tapCount = 0;
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
touchState.event = TE_DOWN;
|
touchState.event = TE_DOWN;
|
||||||
touchState.startX = touchState.x = evt->win_x;
|
touchState.startX = touchState.x = evt->win_x;
|
||||||
touchState.startY = touchState.y = evt->win_y;
|
touchState.startY = touchState.y = evt->win_y;
|
||||||
|
downTime = now;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
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);
|
TRACE_WINDOWS("[Mouse Release] %d %d", evt->win_x, evt->win_y);
|
||||||
|
|
||||||
|
now = get_tmr10ms();
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
if (touchState.event == TE_DOWN) {
|
if (touchState.event == TE_DOWN) {
|
||||||
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