Skip to content

Commit f518d82

Browse files
committed
LVGL: Add SetNewTap to generate tap events
This function sends a tap down and tap up event to LVGL, despite being called only once.
1 parent ecf2f56 commit f518d82

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/displayapp/LittleVgl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,23 @@ void LittleVgl::CancelTap() {
260260
}
261261
}
262262

263+
void LittleVgl::SetNewTap(int16_t x, int16_t y) {
264+
touchPoint = {x, y};
265+
tapped = true;
266+
simulate_tap_release = true;
267+
}
268+
263269
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
264270
ptr->point.x = touchPoint.x;
265271
ptr->point.y = touchPoint.y;
266272
if (tapped) {
267273
ptr->state = LV_INDEV_STATE_PR;
274+
if (simulate_tap_release) {
275+
// If a tap consists of only a single event, enqueue a synthetic release state update
276+
tapped = false;
277+
simulate_tap_release = false;
278+
return true;
279+
}
268280
} else {
269281
ptr->state = LV_INDEV_STATE_REL;
270282
}

src/displayapp/LittleVgl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace Pinetime {
2626
void SetFullRefresh(FullRefreshDirections direction);
2727
void SetNewTouchPoint(int16_t x, int16_t y, bool contact);
2828
void CancelTap();
29+
void SetNewTap(int16_t x, int16_t y);
2930

3031
bool GetFullRefresh() {
3132
bool returnValue = fullRefresh;
@@ -65,6 +66,7 @@ namespace Pinetime {
6566
lv_point_t touchPoint = {};
6667
bool tapped = false;
6768
bool isCancelled = false;
69+
bool simulate_tap_release = false;
6870
};
6971
}
7072
}

0 commit comments

Comments
 (0)