添加drag控制指令,灵活控制UI X和Y的drag条件,可动态开启和关闭drag指令 1004/1 1004/head 1005/target/1 1006/target/1 1007/target/1 1008/target/1
authorSnickerSun <snickersun@163.com>
Sun, 22 Sep 2024 13:16:02 +0000 (21:16 +0800)
committerSnickerSun <snickersun@163.com>
Sun, 22 Sep 2024 13:16:02 +0000 (21:16 +0800)
code/sdk/drivers/peripheral/utils/custom_utils.h
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c
code/sdk/middleware/services/gui/uikit/ui/frameworks/dock/pointer_input_device.cpp
code/sdk/middleware/services/gui/uikit/utils/interfaces/innerkits/graphic_config.h

index a9ff72d..db43ae5 100644 (file)
@@ -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"
 
 
index c06bad9..b4a9de5 100644 (file)
@@ -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 *)" " },
 };
 
 
index c4d04f3..5f3b0ae 100755 (executable)
@@ -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();
             }
index 9d65c36..8817143 100755 (executable)
@@ -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 <b>64</b>. */
 static constexpr uint8_t INDEV_READ_PERIOD = 10; /* Input event read cycle. The default value is <b>10</b> ms. */
 /* Drag distance threshold of a drag event. The default value is <b>10px</b>. */
-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 <b>64</b>. */
 static constexpr uint8_t COMPONENT_NESTING_DEPTH = 64;
 /* Long-press event threshold. The default value is <b>1000</b> ms. */