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_EVENT_NORMALIZE_H 17 #define TOUCH_EVENT_NORMALIZE_H 18 19 #include <map> 20 #include <memory> 21 22 #include "singleton.h" 23 24 #include "proto.h" 25 #include "transform_processor.h" 26 27 namespace OHOS { 28 namespace MMI { 29 class TouchEventNormalize final { 30 DECLARE_DELAYED_SINGLETON(TouchEventNormalize); 31 32 public: 33 enum class DeviceType : int32_t { 34 KEYBOARD, 35 POINTER, 36 TOUCH, 37 TABLET_TOOL, 38 TABLET_PAD, 39 GESTURE, 40 SWITCH, 41 JOYSTICK, 42 AISENSOR, 43 TOUCH_PAD, 44 REMOTE_CONTROL, 45 TRACK_BALL, 46 KNUCKLE, 47 TRACKPAD5, 48 GAMEPAD, 49 }; 50 51 public: 52 DISALLOW_COPY_AND_MOVE(TouchEventNormalize); 53 std::shared_ptr<PointerEvent> OnLibInput(struct libinput_event *event, DeviceType deviceType); 54 #ifdef OHOS_BUILD_ENABLE_POINTER 55 int32_t SetTouchpadPinchSwitch(bool switchFlag) const; 56 void GetTouchpadPinchSwitch(bool &switchFlag) const; 57 int32_t SetTouchpadSwipeSwitch(bool switchFlag) const; 58 void GetTouchpadSwipeSwitch(bool &switchFlag) const; 59 int32_t SetTouchpadRotateSwitch(bool rotateSwitch) const; 60 void GetTouchpadRotateSwitch(bool &rotateSwitch) const; 61 int32_t SetTouchpadDoubleTapAndDragState(bool switchFlag) const; 62 void GetTouchpadDoubleTapAndDragState(bool &switchFlag) const; 63 #endif // OHOS_BUILD_ENABLE_POINTER 64 std::shared_ptr<PointerEvent> GetPointerEvent(int32_t deviceId); 65 66 private: 67 std::shared_ptr<TransformProcessor> MakeTransformProcessor( 68 int32_t deviceId, DeviceType deviceType) const; 69 70 private: 71 std::map<int32_t, std::shared_ptr<TransformProcessor>> processors_; 72 }; 73 74 #define TOUCH_EVENT_HDR ::OHOS::DelayedSingleton<TouchEventNormalize>::GetInstance() 75 } // namespace MMI 76 } // namespace OHOS 77 #endif // TOUCH_EVENT_NORMALIZE_H