• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 TOUCHPAD_TRANSFORM_PROCESSOR_H
17 #define TOUCHPAD_TRANSFORM_PROCESSOR_H
18 
19 #include "nocopyable.h"
20 #include "transform_processor.h"
21 
22 namespace OHOS {
23 namespace MMI {
24 class TouchPadTransformProcessor final : public TransformProcessor {
25 public:
26     explicit TouchPadTransformProcessor(int32_t deviceId);
27     DISALLOW_COPY_AND_MOVE(TouchPadTransformProcessor);
28     ~TouchPadTransformProcessor() = default;
29     std::shared_ptr<PointerEvent> OnEvent(struct libinput_event *event) override;
30 
31     static int32_t SetTouchpadPinchSwitch(bool switchFlag);
32     static int32_t GetTouchpadPinchSwitch(bool &switchFlag);
33     static int32_t SetTouchpadSwipeSwitch(bool switchFlag);
34     static int32_t GetTouchpadSwipeSwitch(bool &switchFlag);
35 
36 private:
37     static int32_t PutConfigDataToDatabase(std::string &key, bool value);
38     static int32_t GetConfigDataFromDatabase(std::string &key, bool &value);
39 
40     int32_t OnEventTouchPadDown(struct libinput_event *event);
41     int32_t OnEventTouchPadMotion(struct libinput_event *event);
42     int32_t OnEventTouchPadUp(struct libinput_event *event);
43     int32_t SetTouchPadSwipeData(struct libinput_event *event, int32_t action);
44     int32_t OnEventTouchPadSwipeBegin(struct libinput_event *event);
45     int32_t OnEventTouchPadSwipeUpdate(struct libinput_event *event);
46     int32_t OnEventTouchPadSwipeEnd(struct libinput_event *event);
47     int32_t OnEventTouchPadPinchBegin(struct libinput_event *event);
48     int32_t OnEventTouchPadPinchUpdate(struct libinput_event *event);
49     int32_t OnEventTouchPadPinchEnd(struct libinput_event *event);
50     int32_t SetTouchPadPinchData(struct libinput_event *event, int32_t action);
51     void SetPinchPointerItem(int64_t time);
52     void ProcessTouchPadPinchDataEvent(int32_t fingerCount, int32_t action, double scale);
53 
54     int32_t GetTouchPadToolType(struct libinput_event_touch *data, struct libinput_device *device);
55     int32_t GetTouchPadToolType(struct libinput_device *device);
56     void InitToolType();
57 private:
58     const int32_t deviceId_ { -1 };
59     const int32_t defaultPointerId { 0 };
60     std::shared_ptr<PointerEvent> pointerEvent_ { nullptr };
61     std::vector<std::pair<int32_t, int32_t>> vecToolType_;
62 };
63 } // namespace MMI
64 } // namespace OHOS
65 #endif // TOUCHPAD_TRANSFORM_PROCESSOR_H