From 52b3c3efcc0ef4c93ce24e068b68e797e8863aee Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 May 2022 22:58:35 +0200 Subject: [PATCH] LVGL: Add SetNewTap to generate tap events This function sends a tap down and tap up event to LVGL, despite being called only once. --- src/displayapp/DummyLittleVgl.h | 2 ++ src/displayapp/LittleVgl.cpp | 14 ++++++++++++++ src/displayapp/LittleVgl.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/displayapp/DummyLittleVgl.h b/src/displayapp/DummyLittleVgl.h index 05355a97..cf105cc5 100644 --- a/src/displayapp/DummyLittleVgl.h +++ b/src/displayapp/DummyLittleVgl.h @@ -33,6 +33,8 @@ namespace Pinetime { } void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) { } + void SetNewTap(uint16_t x, uint16_t y) { + } }; } } diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 64c99261..e282d933 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -180,6 +180,14 @@ void LittleVgl::SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) { tap_x = x; tap_y = y; tapped = contact; + simulate_tap_release = false; +} + +void LittleVgl::SetNewTap(uint16_t x, uint16_t y) { + tap_x = x; + tap_y = y; + tapped = true; + simulate_tap_release = true; } bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { @@ -187,6 +195,12 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { ptr->point.y = tap_y; if (tapped) { ptr->state = LV_INDEV_STATE_PR; + if (simulate_tap_release) { + // If a tap consists of only a single event, enqueue a synthetic release state update + tapped = false; + simulate_tap_release = false; + return true; + } } else { ptr->state = LV_INDEV_STATE_REL; } diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 45826165..e35da7fb 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -25,6 +25,7 @@ namespace Pinetime { bool GetTouchPadInfo(lv_indev_data_t* ptr); void SetFullRefresh(FullRefreshDirections direction); void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact); + void SetNewTap(uint16_t x, uint16_t y); bool GetFullRefresh() { bool returnValue = fullRefresh; @@ -62,6 +63,7 @@ namespace Pinetime { uint16_t tap_x = 0; uint16_t tap_y = 0; bool tapped = false; + bool simulate_tap_release = false; }; } }