From fc60b81371cccb7c9af49e637e20b196a9bd182a Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 3 Oct 2024 20:18:55 +0800 Subject: [PATCH] =?utf8?q?=E6=B3=A8=E5=86=8CfunctionKey=E7=9A=848=E6=AC=A1?= =?utf8?q?=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6=EF=BC=8C=E8=AF=A5=E4=BA=8B?= =?utf8?q?=E4=BB=B6=E4=BC=9A=E8=BF=9B=E5=85=A5=E5=BC=80=E5=8F=91=E8=B0=83?= =?utf8?q?=E8=AF=95=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/RebootAndShutdownModel.h | 3 +- .../src/RebootAndShutdownModel.cpp | 32 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h index c830bc074..acd86ab07 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h @@ -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}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp index 958358535..ea676e07e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -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 -- 2.17.1