提交 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;
#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_) {
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_) {
......
......@@ -39,6 +39,7 @@ protected:
bool rotateStart_;
int16_t threshold_;
int16_t cachedRotation_;
uint8_t zeroCount_;
};
} // namespace OHOS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册