From 6cd86d794287c1bd62277b034c78caa33988bf77 Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Sun, 22 Sep 2024 21:16:02 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0drag=E6=8E=A7=E5=88=B6?= =?utf8?q?=E6=8C=87=E4=BB=A4=EF=BC=8C=E7=81=B5=E6=B4=BB=E6=8E=A7=E5=88=B6U?= =?utf8?q?I=20X=E5=92=8CY=E7=9A=84drag=E6=9D=A1=E4=BB=B6=EF=BC=8C=E5=8F=AF?= =?utf8?q?=E5=8A=A8=E6=80=81=E5=BC=80=E5=90=AF=E5=92=8C=E5=85=B3=E9=97=ADd?= =?utf8?q?rag=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../drivers/peripheral/utils/custom_utils.h | 16 +++++ .../peripheral/utils/custom_utils_at_cmd.c | 60 ++++++++++++++++++- .../frameworks/dock/pointer_input_device.cpp | 57 +++++++++++++++++- .../interfaces/innerkits/graphic_config.h | 2 +- 4 files changed, 132 insertions(+), 3 deletions(-) diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index a9ff72de0..db43ae516 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -311,6 +311,22 @@ bool uapi_custom_uart_rx_enable_flag(void); */ void uapi_custom_set_uart_rx_enable_flag(bool enable_uart); + + +/** + * param direction 0 = X , 1 = Y +*/ +void enable_drag(uint8_t direction, uint8_t enable); + +/** + * param direction 0 = X , 1 = Y +*/ +void set_drag_limit(uint8_t direction, uint16_t limit); +/** + * param direction 0 = X , 1 = Y +*/ +uint16_t get_drag_limit(uint8_t direction); + #include "custom_utilscpp.h" diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index c06bad92f..b4a9de5d5 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -1231,6 +1231,62 @@ static uint32_t custom_resfiles_checksum(uint8_t *para, uint32_t paraLen, char * return ERRCODE_SUCC; } +static uint32_t enabledrag(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + uint8_t send_data[8] = {0}; + + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) { + wstp_print("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 2) { + wstp_print("CUSTOM_UTILSTEST enabledrag ATCMD Set Parameter Failed argc %d\r\n",argc); + return ERRCODE_FAIL; + } + uint8_t direction = atol((char*)argv[0]); + uint8_t enable = atol((char*)argv[1]); + + enable_drag(direction,enable); + uint8_t limit=get_drag_limit(direction); + wstp_print("%s %s , current limit %d\r\n",enable==1?"enable":"disable",direction==0?"x":"y",limit); + + return ERRCODE_SUCC; +} + + +static uint32_t setdraglimit(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + UNUSED(strCommonCmd); + uint8_t argv[CUSTOM_UTILS_MAX_ARGC][CUSTOM_UTILS_MAX_ARGV_LEN] = { 0 }; + uint32_t argc = 0; + uint8_t send_data[8] = {0}; + + + int ret = ConvertCmdToParam(para, paraLen, argv, &argc); + if (ret != CUSTOM_UTILS_SUCCESS) { + wstp_print("CUSTOM_UTILSTEST ATCMD Convert Command Failed\n"); + return ERRCODE_FAIL; + } + + if (argc != 2) { + wstp_print("CUSTOM_UTILSTEST enabledrag ATCMD Set Parameter Failed argc %d\r\n",argc); + return ERRCODE_FAIL; + } + uint8_t direction = atol((char*)argv[0]); + uint8_t value = atol((char*)argv[1]); + + set_drag_limit(direction,value); + uint8_t limit=get_drag_limit(direction); + wstp_print("set drag %s limit %d (current limit %d) \r\n",direction==0?"x":"y",value,limit); + + return ERRCODE_SUCC; +} static uint32_t leantest(uint8_t *para, uint32_t paraLen, char *strCommonCmd) { @@ -1342,7 +1398,9 @@ static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^SETVOLUME", custom_volume_test, (char *)" " }, { (char *)"AT^CYWEESAVEKEY", custom_cywee_save_mac_key, (char *)" " }, { (char *)"AT^RESFILECHECK", custom_resfiles_checksum, (char *)" " }, - { (char *)"AT^LEANTEST", leantest, (char *)" " }, + { (char *)"AT^LEANTEST", leantest, (char *)" " }, + { (char *)"AT^ENABLEDRAG", enabledrag, (char *)" " }, + { (char *)"AT^SETDRAGLIMIT", setdraglimit, (char *)" " }, }; diff --git a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp index c4d04f3c7..5f3b0ae72 100755 --- a/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp +++ b/code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp @@ -196,6 +196,56 @@ void PointerInputDevice::DispatchReleaseEvent(UIViewGroup* rootView) touchableView_ = nullptr; } +extern "C" { + +static uint16_t DRAG_LIMIT_X = INDEV_DRAG_LIMIT; +static uint16_t DRAG_LIMIT_Y = INDEV_DRAG_LIMIT; +/** + * param direction 0 = X , 1 = Y +*/ +void enable_drag(uint8_t direction, uint8_t enable) +{ + if (enable == 0 ) //disable drag + { + if (direction == 0) //X + { + DRAG_LIMIT_X = 0xFFFF; + }else{ //Y + DRAG_LIMIT_Y= 0xFFFF; + } + }else{ //enable drag + if (direction == 0) //X + { + DRAG_LIMIT_X = INDEV_DRAG_LIMIT; + }else{ //Y + DRAG_LIMIT_Y= INDEV_DRAG_LIMIT; + } + } + +} + +void set_drag_limit(uint8_t direction, uint16_t limit) +{ + + if (direction == 0) //X + { + DRAG_LIMIT_X = limit; + }else{ //Y + DRAG_LIMIT_Y= limit; + } +} + +uint16_t get_drag_limit(uint8_t direction) +{ + if (direction == 0) + { + return DRAG_LIMIT_X; + }else{ + return DRAG_LIMIT_Y; + } +} + +} void PointerInputDevice::DispatchDragStartEvent() { if (draggableView_ == nullptr) { @@ -206,7 +256,12 @@ void PointerInputDevice::DispatchDragStartEvent() dragLen_.x += dragStep_.x; dragLen_.y += dragStep_.y; if (!isDragging_) { - if ((MATH_ABS(dragLen_.x) >= INDEV_DRAG_LIMIT) || (MATH_ABS(dragLen_.y) >= INDEV_DRAG_LIMIT)) { + if ((MATH_ABS(dragLen_.x) >= DRAG_LIMIT_X) || (MATH_ABS(dragLen_.y) >= DRAG_LIMIT_Y)) { + + printf("=====PointerInputDevice::DispatchDragStartEvent absx(%d) limitx(%d) absy(%d) limity(%d) \r\n", + MATH_ABS(dragLen_.x),DRAG_LIMIT_X, + MATH_ABS(dragLen_.y),DRAG_LIMIT_Y); + if ((touchableView_ != nullptr) && !cancelSent_) { DispatchCancelEvent(); } diff --git a/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h b/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h index 9d65c36e7..881714304 100755 --- a/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h +++ b/code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h @@ -626,7 +626,7 @@ static constexpr uint8_t WMS_MAIN_TASK_PERIOD = 16; static constexpr uint8_t IMG_CACHE_SIZE = 64; /* Maximum number of cached images. The default value is 64. */ static constexpr uint8_t INDEV_READ_PERIOD = 10; /* Input event read cycle. The default value is 10 ms. */ /* Drag distance threshold of a drag event. The default value is 10px. */ -static constexpr uint8_t INDEV_DRAG_LIMIT = 10; +static constexpr uint8_t INDEV_DRAG_LIMIT = 20; /* Maximum depth of view nesting. The default value is 64. */ static constexpr uint8_t COMPONENT_NESTING_DEPTH = 64; /* Long-press event threshold. The default value is 1000 ms. */ -- 2.17.1