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 TOUCH_TRANSFORM_PROCESSOR_H 17 #define TOUCH_TRANSFORM_PROCESSOR_H 18 19 #include "aggregator.h" 20 #include "fingersense_manager.h" 21 #include "timer_manager.h" 22 #include "transform_processor.h" 23 24 namespace OHOS { 25 namespace MMI { 26 class TouchTransformProcessor final : public TransformProcessor { 27 public: 28 explicit TouchTransformProcessor(int32_t deviceId); 29 DISALLOW_COPY_AND_MOVE(TouchTransformProcessor); 30 ~TouchTransformProcessor() = default; 31 std::shared_ptr<PointerEvent> OnEvent(struct libinput_event *event) override; GetPointerEvent()32 std::shared_ptr<PointerEvent> GetPointerEvent() override { return nullptr; } 33 34 private: 35 bool OnEventTouchDown(struct libinput_event *event); 36 bool OnEventTouchMotion(struct libinput_event *event); 37 bool OnEventTouchUp(struct libinput_event *event); 38 bool OnEventTouchCancel(struct libinput_event *event); 39 int32_t GetTouchToolType(struct libinput_event_touch *data, struct libinput_device *device); 40 int32_t GetTouchToolType(struct libinput_device *device); 41 void TransformTouchProperties(TouchType &rawTouch, PointerEvent::PointerItem &pointerItem); 42 void NotifyFingersenseProcess(PointerEvent::PointerItem &pointerItem, int32_t &toolType); 43 void UpdatePointerItemProperties(PointerEvent::PointerItem &item, EventTouch &touchInfo); 44 void InitToolTypes(); 45 bool DumpInner(); 46 private: 47 const int32_t deviceId_ { -1 }; 48 int32_t processedCount_ { 0 }; 49 std::shared_ptr<PointerEvent> pointerEvent_ { nullptr }; 50 std::vector<std::pair<int32_t, int32_t>> vecToolType_; 51 std::unordered_map<int32_t, bool> pointerItemCancelMarks_; 52 Aggregator aggregator_ { 53 [](int32_t intervalMs, int32_t repeatCount, std::function<void()> callback) -> int32_t { 54 return TimerMgr->AddTimer(intervalMs, repeatCount, std::move(callback)); 55 }, 56 [](int32_t timerId) -> int32_t 57 { 58 return TimerMgr->ResetTimer(timerId); 59 } 60 }; 61 #ifdef OHOS_BUILD_ENABLE_FINGERSENSE_WRAPPER 62 TouchType rawTouch_; 63 #endif // OHOS_BUILD_ENABLE_FINGERSENSE_WRAPPER 64 }; 65 } // namespace MMI 66 } // namespace OHOS 67 #endif // TOUCH_TRANSFORM_PROCESSOR_H