From 42b9fd4f07980414656a296fb7f3b757462b3cf3 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 3 Dec 2024 17:50:51 +0800 Subject: [PATCH] =?utf8?q?=E5=B0=86=E4=B8=BB=E7=95=8C=E9=9D=A2=E8=BF=9B?= =?utf8?q?=E5=85=A5applist=E7=95=8C=E9=9D=A2Power=E9=94=AE=E8=A7=A6?= =?utf8?q?=E5=8F=91=E7=94=B1=E9=87=8A=E6=94=BE=E4=BA=8B=E4=BB=B6=E6=94=B9?= =?utf8?q?=E4=B8=BA=E6=8C=89=E4=B8=8B=E4=BA=8B=E4=BB=B6=EF=BC=8C1.?= =?utf8?q?=E5=8A=A0=E5=BF=AB=E7=95=8C=E9=9D=A2=E8=BF=9B=E5=85=A5=E9=80=9F?= =?utf8?q?=E5=BA=A6=EF=BC=9B2,=E8=A7=A3=E5=86=B3=E6=89=8B=E8=A1=A8?= =?utf8?q?=E6=81=AF=E5=B1=8F=E7=8A=B6=E6=80=81=E4=B8=8B(=E4=B8=BB=E7=95=8C?= =?utf8?q?=E9=9D=A2)=E6=8C=89Power=E9=94=AE=E6=A6=82=E7=8E=87=E6=80=A7?= =?utf8?q?=E4=BC=9A=E8=BF=9B=E5=85=A5applist=E7=95=8C=E9=9D=A2=EF=BC=88?= =?utf8?q?=E9=9C=80=E8=A6=81=E5=A4=9A=E5=8F=B0=E6=89=8B=E8=A1=A8=E9=AA=8C?= =?utf8?q?=E8=AF=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/key/include/KeyInputListener.h | 2 +- .../nativeui/key/src/KeyInputListener.cpp | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h b/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h index 9d3eb281c..d9338e69c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h +++ b/code/sdk/application/wearable/fd230app/nativeui/key/include/KeyInputListener.h @@ -24,7 +24,7 @@ namespace OHOS bool OnKeyAct(UIView &view, const KeyEvent &event) override; private: - void OnKeyPress(void); + void OnKeyPress(const KeyEvent &event); void OnKeyLongPress(const KeyEvent &event); void OnKeyRelease(const KeyEvent &event); void CallVolumeDipSwitchControl(VolumeChangeStatus status); diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index be019477e..2defe02da 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -53,10 +53,27 @@ namespace OHOS } } - void KeyInputListener::OnKeyPress() + void KeyInputListener::OnKeyPress(const KeyEvent &event) { pressFlag = 1; // 短按标志 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnKeyPress: pressFlag = %d", pressFlag); + uint16 keyID = event.GetKeyId(); + uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + { + if (longPressFlag == 0 && pressFlag == 1) + { + HandlePowerKeyPress(currentViewId); + } + } + else if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_FUNC)) + { + if (longPressFlag == 0 && pressFlag == 1) + { + HandleFuncKeyPress(currentViewId); + } + } + return; } void KeyInputListener::OnKeyLongPress(const KeyEvent &event) @@ -120,7 +137,7 @@ namespace OHOS uint16 keyID = event.GetKeyId(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnKeyRelease: keyID = %d, currentViewId = %d, longPressFlag = %d, pressFlag = %d", keyID, currentViewId, longPressFlag, pressFlag); - + #if 0 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { if (longPressFlag == 0 && pressFlag == 1) @@ -135,6 +152,7 @@ namespace OHOS HandleFuncKeyPress(currentViewId); } } + #endif // 重置标志 pressFlag = 0; @@ -216,7 +234,7 @@ namespace OHOS switch (state) { case InputDevice::STATE_PRESS: - OnKeyPress(); + OnKeyPress(event); break; #ifdef __LITEOS_M__ case InputDevice::STATE_LONG_PRESS: -- 2.17.1