From d2baa9c3e25d9f83f9227814fe57fce1e336c32d Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Fri, 2 Apr 2021 06:51:49 -0400 Subject: [PATCH] fix(indev) provide raw old points to read_cb, not rotated points (#2180) cherry-picked from acf42d39 --- src/core/lv_indev.c | 4 ++++ src/hal/lv_hal_indev.c | 8 ++++---- src/hal/lv_hal_indev.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/lv_indev.c b/src/core/lv_indev.c index ac82b5a7a..5972abdc2 100644 --- a/src/core/lv_indev.c +++ b/src/core/lv_indev.c @@ -325,6 +325,10 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point) static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) { lv_disp_t *disp = i->driver->disp; + /*Save the raw points so they can be used again in _lv_indev_read*/ + i->proc.types.pointer.last_raw_point.x = data->point.x; + i->proc.types.pointer.last_raw_point.y = data->point.y; + if(disp->driver->rotated == LV_DISP_ROT_180 || disp->driver->rotated == LV_DISP_ROT_270) { data->point.x = disp->driver->hor_res - data->point.x - 1; data->point.y = disp->driver->ver_res - data->point.y - 1; diff --git a/src/hal/lv_hal_indev.c b/src/hal/lv_hal_indev.c index f8935ba99..d17fd36d0 100644 --- a/src/hal/lv_hal_indev.c +++ b/src/hal/lv_hal_indev.c @@ -135,11 +135,11 @@ bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) lv_memset_00(data, sizeof(lv_indev_data_t)); - /*For touchpad sometimes users don't set the last pressed coordinate on release. - *So be sure a coordinates are initialized to the last point*/ + /* For touchpad sometimes users don't set the last pressed coordinate on release. + * So be sure a coordinates are initialized to the last point */ if(indev->driver->type == LV_INDEV_TYPE_POINTER) { - data->point.x = indev->proc.types.pointer.act_point.x; - data->point.y = indev->proc.types.pointer.act_point.y; + data->point.x = indev->proc.types.pointer.last_raw_point.x; + data->point.y = indev->proc.types.pointer.last_raw_point.y; } /*Similarly set at least the last key in case of the user doesn't set it on release*/ else if(indev->driver->type == LV_INDEV_TYPE_KEYPAD) { diff --git a/src/hal/lv_hal_indev.h b/src/hal/lv_hal_indev.h index 131905505..4ec3c7fe3 100644 --- a/src/hal/lv_hal_indev.h +++ b/src/hal/lv_hal_indev.h @@ -158,6 +158,7 @@ typedef struct _lv_indev_proc_t { /*Pointer and button data*/ lv_point_t act_point; /**< Current point of input device.*/ lv_point_t last_point; /**< Last point of input device.*/ + lv_point_t last_raw_point; /**< Last point read from read_cb. */ lv_point_t vect; /**< Difference between `act_point` and `last_point`.*/ lv_point_t scroll_sum; /*Count the dragged pixels to check LV_INDEV_DEF_SCROLL_LIMIT*/ lv_point_t scroll_throw_vect;