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