提交 eee7740a 编写于 作者: L lancer

Description: check zero count when dispatch rotate end event

IssueNo: https://gitee.com/openharmony/graphic_ui/issues/I6NDKY
Feature or Bugfix: Feature
Binary Source:No
Signed-off-by: Nlancer <haoshuo@huawei.com>
上级 e650e052
...@@ -25,10 +25,14 @@ constexpr int16_t ROTATE_INPUT_THRESHOLD = 1; ...@@ -25,10 +25,14 @@ constexpr int16_t ROTATE_INPUT_THRESHOLD = 1;
#else #else
constexpr int16_t ROTATE_INPUT_THRESHOLD = 10; constexpr int16_t ROTATE_INPUT_THRESHOLD = 10;
#endif #endif
constexpr uint8_t ROTATE_END_ZERO_COUNT = 2;
} }
namespace OHOS { 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) void RotateInputDevice::DispatchEvent(const DeviceData& data)
{ {
...@@ -65,9 +69,13 @@ void RotateInputDevice::DispatchEvent(const DeviceData& data) ...@@ -65,9 +69,13 @@ void RotateInputDevice::DispatchEvent(const DeviceData& data)
} }
if (data.rotate == 0 && rotateStart_) { if (data.rotate == 0 && rotateStart_) {
view->OnRotateEndEvent(0); zeroCount_++;
rotateStart_ = false; if (zeroCount_ >= ROTATE_END_ZERO_COUNT) {
GRAPHIC_LOGW("RotateInputDevice dispatched 0-value event!\n"); view->OnRotateEndEvent(0);
zeroCount_ = 0;
rotateStart_ = false;
GRAPHIC_LOGW("RotateInputDevice dispatched 0-value event!\n");
}
return; return;
} }
if (!rotateStart_) { if (!rotateStart_) {
......
...@@ -39,6 +39,7 @@ protected: ...@@ -39,6 +39,7 @@ protected:
bool rotateStart_; bool rotateStart_;
int16_t threshold_; int16_t threshold_;
int16_t cachedRotation_; int16_t cachedRotation_;
uint8_t zeroCount_;
}; };
} // namespace OHOS } // namespace OHOS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册