From fa49f35b14b4395617c42aa351cba846ed1cec8c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 25 Nov 2020 09:47:35 +0100 Subject: [PATCH] fix(indev): in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too Fixes https://forum.lvgl.io/t/bug-in-indev-button-proc-misses-buttons-that-are-pressed-for-a-single-callback/3699 --- CHANGELOG.md | 1 + src/lv_core/lv_indev.c | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2308ada3c..fe575f96e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - fix(textarea) support Arabic letter connections - fix(dropdown) support Arabic letter connections - fix(value_str) support Arabic letter connections in value string property +- fix(indev) in LV_INDEV_TYPE_BUTTON recognize 1 cycle long presses too ## v7.7.2 (17.11.2020) ### Bugfixes diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 217e712e4..597a0ae6f 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -807,19 +807,28 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) return; } - i->proc.types.pointer.act_point.x = i->btn_points[data->btn_id].x; - i->proc.types.pointer.act_point.y = i->btn_points[data->btn_id].y; + lv_coord_t x = i->btn_points[data->btn_id].x; + lv_coord_t y = i->btn_points[data->btn_id].y; - /*Still the same point is pressed*/ - if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x && - i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && data->state == LV_INDEV_STATE_PR) { - indev_proc_press(&i->proc); - } - else { - /*If a new point comes always make a release*/ - indev_proc_release(&i->proc); + /*If a new point comes always make a release*/ + if(data->state == LV_INDEV_STATE_PR) { + if(i->proc.types.pointer.last_point.x != x || + i->proc.types.pointer.last_point.y != y) { + indev_proc_release(&i->proc); + } } + if(indev_reset_check(&i->proc)) return; + + /*Save the new points*/ + i->proc.types.pointer.act_point.x = x; + i->proc.types.pointer.act_point.y = y; + + if(data->state == LV_INDEV_STATE_PR) indev_proc_press(&i->proc); + else indev_proc_release(&i->proc); + + if(indev_reset_check(&i->proc)) return; + i->proc.types.pointer.last_point.x = i->proc.types.pointer.act_point.x; i->proc.types.pointer.last_point.y = i->proc.types.pointer.act_point.y; }