diff --git a/service/mouse_event_handler/include/mouse_event_handler.h b/service/mouse_event_handler/include/mouse_event_handler.h index 9661a9e837289c202b654c1b1994a452b6877e1f..f37b85035502cb5673301ed1139f1bb43a815cbe 100755 --- a/service/mouse_event_handler/include/mouse_event_handler.h +++ b/service/mouse_event_handler/include/mouse_event_handler.h @@ -49,21 +49,17 @@ private: void HandlePostMoveMouse(PointerEvent::PointerItem& pointerItem); #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING int32_t HandleButtonValueInner(libinput_event_pointer* data); - int32_t HandleMotionCorrection(libinput_event_pointer* data); - double GetSpeedGain(const double &speed) const; void DumpInner(); void InitAbsolution(); private: - std::shared_ptr pointerEvent_ { nullptr }; - int32_t timerId_ { -1 }; - double absolutionX_ { -1.0 }; - double absolutionY_ { -1.0 }; - int32_t buttonId_ { -1 }; - bool isPressed_ { false }; - int32_t currentDisplayId_ { -1 }; - int32_t speed_ { 10 }; - uint64_t lastEventTime_ { 0 }; + std::shared_ptr pointerEvent_ = nullptr; + int32_t timerId_ = -1; + double absolutionX_ = -1; + double absolutionY_ = -1; + int32_t buttonId_ = -1; + bool isPressed_ = false; + int32_t currentDisplayId_ = -1; }; #define MouseEventHdr MouseEventHandler::GetInstance() diff --git a/service/mouse_event_handler/src/mouse_event_handler.cpp b/service/mouse_event_handler/src/mouse_event_handler.cpp index 8418f80b5472716f2d0e7ee3706483fde20061c7..c285aafa1f58d31ac195b77642e7bff7193bd4b4 100755 --- a/service/mouse_event_handler/src/mouse_event_handler.cpp +++ b/service/mouse_event_handler/src/mouse_event_handler.cpp @@ -32,8 +32,6 @@ namespace OHOS { namespace MMI { namespace { constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, MMI_LOG_DOMAIN, "MouseEventHandler"}; -const std::array SPEED_NUMS { 5, 16, 23, 32, 41, 128 }; -const std::array SPEED_GAINS { 0.6, 1.0, 1.2, 1.8, 2.1, 2.8 }; } // namespace MouseEventHandler::MouseEventHandler() { @@ -46,17 +44,6 @@ std::shared_ptr MouseEventHandler::GetPointerEvent() const return pointerEvent_; } -double MouseEventHandler::GetSpeedGain(const double &speed) const -{ - int32_t num = static_cast(ceil(abs(speed))); - for (size_t i = 0; i < SPEED_NUMS.size(); ++i) { - if (num <= SPEED_NUMS[i]) { - return SPEED_GAINS[i]; - } - } - return SPEED_GAINS.back(); -} - int32_t MouseEventHandler::HandleMotionInner(libinput_event_pointer* data) { CALL_DEBUG_ENTER; @@ -73,44 +60,11 @@ int32_t MouseEventHandler::HandleMotionInner(libinput_event_pointer* data) return RET_ERR; } - int32_t ret = HandleMotionCorrection(data); - if (ret != RET_OK) { - MMI_HILOGE("Failed to handle motion correction"); - return ret; - } - + absolutionX_ += libinput_event_pointer_get_dx(data); + absolutionY_ += libinput_event_pointer_get_dy(data); WinMgr->UpdateAndAdjustMouseLocation(currentDisplayId_, absolutionX_, absolutionY_); pointerEvent_->SetTargetDisplayId(currentDisplayId_); - MMI_HILOGD("Change Coordinate : x:%{public}lf,y:%{public}lf", absolutionX_, absolutionY_); - return RET_OK; -} - -int32_t MouseEventHandler::HandleMotionCorrection(libinput_event_pointer* data) -{ - CALL_DEBUG_ENTER; - CHKPR(data, ERROR_NULL_POINTER); - - uint64_t usec = libinput_event_pointer_get_time_usec(data); - if (usec <= lastEventTime_) { - MMI_HILOGE("The new time less than or equal to the last time"); - return RET_ERR; - } - uint64_t timeDiff = usec - lastEventTime_; - - double dx = libinput_event_pointer_get_dx(data); - double dy = libinput_event_pointer_get_dy(data); - DisplayGroupInfo displayGroupInfo = WinMgr->GetDisplayGroupInfo(); - double correctionX = (dx / static_cast(timeDiff)) * (static_cast(speed_) / 10.0) * - GetSpeedGain(dx) * static_cast(displayGroupInfo.displaysInfo[0].width); - double correctionY = (dy / static_cast(timeDiff)) * (static_cast(speed_) / 10.0) * - GetSpeedGain(dy) * static_cast(displayGroupInfo.displaysInfo[0].height); - MMI_HILOGD("dx:%{public}lf, dy:%{public}lf, correctionX:%{public}lf, correctionY:%{public}lf," - "timeDiff:%{public}ju, width:%{public}d, height:%{public}d", - dx, dy, correctionX, correctionY, - timeDiff, displayGroupInfo.displaysInfo[0].width, displayGroupInfo.displaysInfo[0].height); - absolutionX_ += correctionX; - absolutionY_ += correctionY; - lastEventTime_ = usec; + MMI_HILOGD("Change Coordinate : x:%{public}lf,y:%{public}lf", absolutionX_, absolutionY_); return RET_OK; }