mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 20:57:01 +08:00
feat(indev): add api to set gesture thresholds (#9641)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
@@ -59,11 +59,14 @@ Simple gestures are always enabled and very easy to use:
|
|||||||
To trigger a gesture, two things need to happen. The movement needs to be:
|
To trigger a gesture, two things need to happen. The movement needs to be:
|
||||||
|
|
||||||
1. fast enough: the difference between the current and the previous point must be
|
1. fast enough: the difference between the current and the previous point must be
|
||||||
greater than ``indev->gesture_min_velocity``
|
greater than Indev's ``gesture_min_velocity``
|
||||||
2. large enough: the difference between the first and the current point must be
|
2. large enough: the difference between the first and the current point must be
|
||||||
greater than ``indev->gesture_limit``
|
greater than Indev's ``gesture_min_distance``
|
||||||
|
|
||||||
|
|
||||||
|
These limits can be set via :cpp:func:`lv_indev_set_gesture_min_velocity` and
|
||||||
|
:cpp:func:`lv_indev_set_gesture_min_distance` accordingly.
|
||||||
|
|
||||||
|
|
||||||
Multi-touch Gestures
|
Multi-touch Gestures
|
||||||
********************
|
********************
|
||||||
|
|||||||
+28
-13
@@ -131,17 +131,17 @@ lv_indev_t * lv_indev_create(void)
|
|||||||
|
|
||||||
indev->read_timer = lv_timer_create(lv_indev_read_timer_cb, LV_DEF_REFR_PERIOD, indev);
|
indev->read_timer = lv_timer_create(lv_indev_read_timer_cb, LV_DEF_REFR_PERIOD, indev);
|
||||||
|
|
||||||
indev->disp = lv_display_get_default();
|
indev->disp = lv_display_get_default();
|
||||||
indev->type = LV_INDEV_TYPE_NONE;
|
indev->type = LV_INDEV_TYPE_NONE;
|
||||||
indev->mode = LV_INDEV_MODE_TIMER;
|
indev->mode = LV_INDEV_MODE_TIMER;
|
||||||
indev->scroll_limit = LV_INDEV_DEF_SCROLL_LIMIT;
|
indev->scroll_limit = LV_INDEV_DEF_SCROLL_LIMIT;
|
||||||
indev->scroll_throw = LV_INDEV_DEF_SCROLL_THROW;
|
indev->scroll_throw = LV_INDEV_DEF_SCROLL_THROW;
|
||||||
indev->long_press_time = LV_INDEV_DEF_LONG_PRESS_TIME;
|
indev->long_press_time = LV_INDEV_DEF_LONG_PRESS_TIME;
|
||||||
indev->long_press_repeat_time = LV_INDEV_DEF_LONG_PRESS_REP_TIME;
|
indev->long_press_repeat_time = LV_INDEV_DEF_LONG_PRESS_REP_TIME;
|
||||||
indev->gesture_limit = LV_INDEV_DEF_GESTURE_LIMIT;
|
indev->gesture_min_distance = LV_INDEV_DEF_GESTURE_LIMIT;
|
||||||
indev->gesture_min_velocity = LV_INDEV_DEF_GESTURE_MIN_VELOCITY;
|
indev->gesture_min_velocity = LV_INDEV_DEF_GESTURE_MIN_VELOCITY;
|
||||||
indev->rotary_sensitivity = LV_INDEV_DEF_ROTARY_SENSITIVITY;
|
indev->rotary_sensitivity = LV_INDEV_DEF_ROTARY_SENSITIVITY;
|
||||||
indev->key_remap_cb = NULL;
|
indev->key_remap_cb = NULL;
|
||||||
#if LV_USE_EXT_DATA
|
#if LV_USE_EXT_DATA
|
||||||
indev->ext_data.free_cb = NULL;
|
indev->ext_data.free_cb = NULL;
|
||||||
indev->ext_data.data = NULL;
|
indev->ext_data.data = NULL;
|
||||||
@@ -414,6 +414,21 @@ void lv_indev_set_scroll_throw(lv_indev_t * indev, uint8_t scroll_throw)
|
|||||||
indev->scroll_throw = scroll_throw;
|
indev->scroll_throw = scroll_throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lv_indev_set_gesture_min_distance(lv_indev_t * indev, uint8_t min_distance)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(indev == NULL) return;
|
||||||
|
|
||||||
|
indev->gesture_min_distance = min_distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lv_indev_set_gesture_min_velocity(lv_indev_t * indev, uint8_t gesture_min_velocity)
|
||||||
|
{
|
||||||
|
if(indev == NULL) return;
|
||||||
|
|
||||||
|
indev->gesture_min_velocity = gesture_min_velocity;
|
||||||
|
}
|
||||||
|
|
||||||
void * lv_indev_get_user_data(const lv_indev_t * indev)
|
void * lv_indev_get_user_data(const lv_indev_t * indev)
|
||||||
{
|
{
|
||||||
if(indev == NULL) return NULL;
|
if(indev == NULL) return NULL;
|
||||||
@@ -1769,8 +1784,8 @@ void indev_gesture(lv_indev_t * indev)
|
|||||||
indev->pointer.gesture_sum.x += indev->pointer.vect.x;
|
indev->pointer.gesture_sum.x += indev->pointer.vect.x;
|
||||||
indev->pointer.gesture_sum.y += indev->pointer.vect.y;
|
indev->pointer.gesture_sum.y += indev->pointer.vect.y;
|
||||||
|
|
||||||
if((LV_ABS(indev->pointer.gesture_sum.x) > indev_act->gesture_limit) ||
|
if((LV_ABS(indev->pointer.gesture_sum.x) > indev_act->gesture_min_distance) ||
|
||||||
(LV_ABS(indev->pointer.gesture_sum.y) > indev_act->gesture_limit)) {
|
(LV_ABS(indev->pointer.gesture_sum.y) > indev_act->gesture_min_distance)) {
|
||||||
|
|
||||||
indev->pointer.gesture_sent = 1;
|
indev->pointer.gesture_sent = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,27 @@ void lv_indev_set_scroll_limit(lv_indev_t * indev, uint8_t scroll_limit);
|
|||||||
*/
|
*/
|
||||||
void lv_indev_set_scroll_throw(lv_indev_t * indev, uint8_t scroll_throw);
|
void lv_indev_set_scroll_throw(lv_indev_t * indev, uint8_t scroll_throw);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the minimum velocity threshold for gesture detection.
|
||||||
|
* The difference between consecutive points must exceed this value (in pixels)
|
||||||
|
* for the movement to be considered fast enough to trigger a gesture.
|
||||||
|
*
|
||||||
|
* @param indev pointer to an input device
|
||||||
|
* @param min_velocity minimum velocity threshold in pixels (default: 3)
|
||||||
|
*/
|
||||||
|
void lv_indev_set_gesture_min_velocity(lv_indev_t * indev, uint8_t min_velocity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the minimum distance threshold for gesture detection.
|
||||||
|
* The total distance from the first point to the current point must exceed
|
||||||
|
* this value (in pixels) for the movement to be considered large enough
|
||||||
|
* to trigger a gesture.
|
||||||
|
*
|
||||||
|
* @param indev pointer to an input device
|
||||||
|
* @param min_distance minimum distance threshold in pixels (default: 50)
|
||||||
|
*/
|
||||||
|
void lv_indev_set_gesture_min_distance(lv_indev_t * indev, uint8_t min_distance);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of an input device
|
* Get the type of an input device
|
||||||
* @param indev pointer to an input device
|
* @param indev pointer to an input device
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ void lv_indev_gesture_detect_two_fingers_swipe(lv_indev_gesture_recognizer_t * r
|
|||||||
to be higher than the threshold to pass it as recognized */
|
to be higher than the threshold to pass it as recognized */
|
||||||
gesture_calculate_factors(r->info, 2);
|
gesture_calculate_factors(r->info, 2);
|
||||||
dist = SQUARE_SUM(r->info->delta_x, r->info->delta_y);
|
dist = SQUARE_SUM(r->info->delta_x, r->info->delta_y);
|
||||||
if(dist > SQUARE(lv_indev_active()->gesture_limit)) {
|
if(dist > SQUARE(lv_indev_active()->gesture_min_distance)) {
|
||||||
r->state = LV_INDEV_GESTURE_STATE_RECOGNIZED;
|
r->state = LV_INDEV_GESTURE_STATE_RECOGNIZED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -71,11 +71,11 @@ struct _lv_indev_t {
|
|||||||
/**< Drag throw slow-down in [%]. Greater value means faster slow-down*/
|
/**< Drag throw slow-down in [%]. Greater value means faster slow-down*/
|
||||||
uint8_t scroll_throw;
|
uint8_t scroll_throw;
|
||||||
|
|
||||||
/**< At least this difference should be between two points to evaluate as gesture*/
|
/**< Minimum velocity: difference between consecutive points must exceed this (in pixels) to detect gesture speed */
|
||||||
uint8_t gesture_min_velocity;
|
uint8_t gesture_min_velocity;
|
||||||
|
|
||||||
/**< At least this difference should be to send a gesture*/
|
/**< Minimum distance: total travel from first to current point must exceed this (in pixels) to trigger gesture */
|
||||||
uint8_t gesture_limit;
|
uint8_t gesture_min_distance;
|
||||||
|
|
||||||
/**< Long press time in milliseconds*/
|
/**< Long press time in milliseconds*/
|
||||||
uint16_t long_press_time;
|
uint16_t long_press_time;
|
||||||
|
|||||||
Reference in New Issue
Block a user