From af947f5b5d083d1cfaaa1e17fa465d48d463b06e Mon Sep 17 00:00:00 2001 From: lixianjing Date: Mon, 21 Sep 2020 12:10:30 +0800 Subject: [PATCH] add TK_KEY_LONG_PRESS_TIME --- docs/changes.md | 4 ++++ src/base/input_device_status.c | 4 ++-- src/base/types_def.h | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index 169a99c0f..427ce21f9 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,9 @@ # 最新动态 +* 2020/09/19 + * 更新 dll 导出函数列表。 + * 增加 TK\_KEY\_LONG\_PRESS\_TIME,让触屏长按和键盘长按可以设置为不同的时间。 + * 2020/09/18 * EVT\_VALUE\_WILL\_CHANGE、EVT\_VALUE\_CHANGING 和 EVT\_VALUE\_CHANGED 事件结构改为 value\_change\_event\_t,从中可以获得旧值和新值。 * EVT\_VALUE\_WILL\_CHANGE 事件返回 RET\_STOP 可以阻止修改值。 diff --git a/src/base/input_device_status.c b/src/base/input_device_status.c index 2ad439c7d..b29d42c4b 100644 --- a/src/base/input_device_status.c +++ b/src/base/input_device_status.c @@ -67,7 +67,7 @@ static ret_t input_device_status_dispatch_long_press(input_device_status_t* ids) key_pressed_info_t* iter = ids->pressed_info + i; if (iter->key && !iter->emitted) { uint64_t t = now - iter->time; - if (t >= TK_LONG_PRESS_TIME) { + if (t >= TK_KEY_LONG_PRESS_TIME) { key_event_init(&evt, EVT_KEY_LONG_PRESS, widget, iter->key); widget_on_keydown(widget, &evt); log_debug("long press:%d\n", iter->key); @@ -105,7 +105,7 @@ static ret_t input_device_status_update_key_press_info(input_device_status_t* id } if (ids->long_press_check_timer == TK_INVALID_ID) { - ids->long_press_check_timer = timer_add(long_press_check_on_timer, ids, TK_LONG_PRESS_TIME); + ids->long_press_check_timer = timer_add(long_press_check_on_timer, ids, TK_KEY_LONG_PRESS_TIME); } } else { return_value_if_fail(info != NULL, RET_BAD_PARAMS); diff --git a/src/base/types_def.h b/src/base/types_def.h index b80e6d430..26d847e74 100644 --- a/src/base/types_def.h +++ b/src/base/types_def.h @@ -267,6 +267,9 @@ typedef struct _widget_animator_t widget_animator_t; } #define TK_LONG_PRESS_TIME 1000 +#ifndef TK_KEY_LONG_PRESS_TIME +#define TK_KEY_LONG_PRESS_TIME TK_LONG_PRESS_TIME +#endif/*TK_KEY_LONG_PRESS_TIME*/ #ifdef WITH_WIDGET_TYPE_CHECK #define TK_REF_VTABLE(vt) &(g_##vt##_vtable)