diff --git a/frameworks/dock/rotate_input_device.cpp b/frameworks/dock/rotate_input_device.cpp index d8e56b536322a7651dcf26d0ebc30557dc735834..d836eb228e95d4d7b112aaf163e95a2386ff640b 100644 --- a/frameworks/dock/rotate_input_device.cpp +++ b/frameworks/dock/rotate_input_device.cpp @@ -25,10 +25,14 @@ constexpr int16_t ROTATE_INPUT_THRESHOLD = 1; #else constexpr int16_t ROTATE_INPUT_THRESHOLD = 10; #endif +constexpr uint8_t ROTATE_END_ZERO_COUNT = 2; } namespace OHOS { -RotateInputDevice::RotateInputDevice() : rotateStart_(false), threshold_(ROTATE_INPUT_THRESHOLD), cachedRotation_(0) {} +RotateInputDevice::RotateInputDevice() + : rotateStart_(false), threshold_(ROTATE_INPUT_THRESHOLD), cachedRotation_(0), zeroCount_(0) +{ +} void RotateInputDevice::DispatchEvent(const DeviceData& data) { @@ -65,9 +69,13 @@ void RotateInputDevice::DispatchEvent(const DeviceData& data) } if (data.rotate == 0 && rotateStart_) { - view->OnRotateEndEvent(0); - rotateStart_ = false; - GRAPHIC_LOGW("RotateInputDevice dispatched 0-value event!\n"); + zeroCount_++; + if (zeroCount_ >= ROTATE_END_ZERO_COUNT) { + view->OnRotateEndEvent(0); + zeroCount_ = 0; + rotateStart_ = false; + GRAPHIC_LOGW("RotateInputDevice dispatched 0-value event!\n"); + } return; } if (!rotateStart_) { diff --git a/interfaces/innerkits/dock/rotate_input_device.h b/interfaces/innerkits/dock/rotate_input_device.h index 706e41ea64d26629c19375163f147e2320345602..496a318f8780a384dacfb5f8e6f2e674c7b78fe8 100644 --- a/interfaces/innerkits/dock/rotate_input_device.h +++ b/interfaces/innerkits/dock/rotate_input_device.h @@ -39,6 +39,7 @@ protected: bool rotateStart_; int16_t threshold_; int16_t cachedRotation_; + uint8_t zeroCount_; }; } // namespace OHOS