注册functionKey的8次点击事件,该事件会进入开发调试窗口 1090/1 1090/head 1091/target/1 1092/target/1
authorluozheng <1732036298@qq.com>
Thu, 3 Oct 2024 12:18:55 +0000 (20:18 +0800)
committerluozheng <1732036298@qq.com>
Thu, 3 Oct 2024 12:18:55 +0000 (20:18 +0800)
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp

index c830bc0..acd86ab 100644 (file)
@@ -8,7 +8,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-07-18 14:55:21
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-22 10:28:51
+ * @LastEditTime: 2024-10-03 19:59:14
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h
  */
 
@@ -39,6 +39,7 @@ namespace OHOS
         bool RegisterFuncKeyClickEvent(void);
         bool RegisterFuncKeyDoubleClickEvent(void);
         bool RegisterPowerAndFuncKeyPressEvent(void);
+        bool RegisterFuncKeyOtherOnClickEvent(void);
         bool powerKeyPressed{false};
         bool funcKeyPressed{false};
     };
index 9583585..ea676e0 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-07-18 14:55:27
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-29 15:35:47
+ * @LastEditTime: 2024-10-03 20:04:53
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
  */
 
@@ -20,8 +20,9 @@
 #include "bleService.h"
 #include "ui_service.h"
 #include "dial_sos_c.h"
-
+#include "broadcast_feature.h"
 #define SAVEMODE 0
+#define DEBUGOUTPUT 1
 
 extern "C" uint8_t uapi_dev_runtime_get_lock_status(void);
 namespace OHOS
@@ -530,6 +531,30 @@ namespace OHOS
 
         return true;
     }
+
+    static void FuncKeyOtherOnClickEventCallBack(void)
+    {
+        CustomEventPublish(TOPIC_EVENT_DEBUGOUTPUT, NULL, 0);
+        return;
+    }
+    static void HandFuncKeyOtherOnClickEvent(void)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyOtherOnClickEventCallBack));
+    }
+
+    bool RebootAndShutdownModel::RegisterFuncKeyOtherOnClickEvent(void)
+    {
+        // 注册按键按下8次事件
+        int32_t powerret = uapi_button_register_event_cb(HandFuncKeyOtherOnClickEvent, BUTTON1_CLICKUP_OTHER);
+        if (powerret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to register Power Button Press Event, ret = %d", powerret);
+            return false;
+        }
+
+        return true;
+    }
+
     /*注册所有按键事件*/
     void RebootAndShutdownModel::RegisterAllKeyEvents(void)
     {
@@ -539,6 +564,9 @@ namespace OHOS
         RegisterFuncKeyLongPressEvent();
         // RegisterFuncKeyClickEvent();
         RegisterFuncKeyDoubleClickEvent();
+#if DEBUGOUTPUT
+        RegisterFuncKeyOtherOnClickEvent();
+#endif
 #if SAVEMODE
         RegisterPowerAndFuncKeyPressEvent();
 #endif