1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MOUSE_EVENT_HANDLER_H 17 #define MOUSE_EVENT_HANDLER_H 18 19 #include <memory> 20 #include "libinput.h" 21 #include "pointer_event.h" 22 #include "singleton.h" 23 24 namespace OHOS { 25 namespace MMI { 26 class MouseEventHandler : public DelayedSingleton<MouseEventHandler>, 27 public std::enable_shared_from_this<MouseEventHandler> { 28 public: 29 MouseEventHandler(); 30 ~MouseEventHandler() = default; 31 32 std::shared_ptr<PointerEvent> GetPointerEvent(); 33 void Normalize(struct libinput_event *event); 34 private: 35 void HandleMotionInner(libinput_event_pointer* data); 36 void HandleButonInner(libinput_event_pointer* data, PointerEvent::PointerItem& pointerItem); 37 void HandleAxisInner(libinput_event_pointer* data); 38 void HandlePostInner(libinput_event_pointer* data, int32_t deviceId, PointerEvent::PointerItem& pointerItem); 39 void DumpInner(); 40 private: 41 std::shared_ptr<PointerEvent> pointerEvent_ = nullptr; 42 int32_t timerId_ = -1; 43 double absolutionX_ = 0; 44 double absolutionY_ = 0; 45 int32_t buttionId_ = -1; 46 }; 47 } // namespace MMI 48 } // namespace OHOS 49 #define MouseEventHdr OHOS::MMI::MouseEventHandler::GetInstance() 50 51 #endif // MOUSE_EVENT_HANDLER_H