LVGL: Add SetNewTap to generate tap events

This function sends a tap down and tap up event to LVGL,
despite being called only once.
This commit is contained in:
Christoph Honal 2022-05-10 22:58:35 +02:00
parent 825c7cebf5
commit 52b3c3efcc
3 changed files with 18 additions and 0 deletions

View File

@ -33,6 +33,8 @@ namespace Pinetime {
}
void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
}
void SetNewTap(uint16_t x, uint16_t y) {
}
};
}
}

View File

@ -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;
}

View File

@ -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;
};
}
}