From 6167d9365173fd0c3f76603f30aa1848c86ab60a Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Tue, 14 Sep 2021 19:33:37 +1000 Subject: [PATCH] Add tap count support to `simu` --- radio/src/simu.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index fc663fc9f..87fe7f778 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -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;