• 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 #ifndef DEVICE_BASE_H
16 #define DEVICE_BASE_H
17 
18 #include "msg_head.h"
19 
20 namespace OHOS {
21 namespace MMI {
22 class DeviceBase {
23 public:
24     DeviceBase() = default;
25     virtual ~DeviceBase() = default;
26     virtual int32_t TransformJsonDataToInputData(const Json& inputEventArrays,
27                                                  InputEventArray& inputEventArray) = 0;
28     void SetTimeToLibinputEvent(InjectEvent& injectEvent);
29     void SetSynReport(InputEventArray& inputEventArray, int32_t blockTime = 0);
30     void SetSynConfigReport(InputEventArray& inputEventArray, int32_t blockTime);
31     void SetKeyPressEvent(InputEventArray& inputEventArray, int32_t blockTime, uint16_t code);
32     void SetKeyLongPressEvent(InputEventArray& inputEventArray, int32_t blockTime, int32_t code);
33     void SetKeyReleaseEvent(InputEventArray& inputEventArray, int32_t blockTime, uint16_t code);
34     void SetMtSlot(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
35     void SetTrackingId(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
36     void SetPositionX(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
37     void SetPositionY(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
38     void SetMtTouchMajor(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
39     void SetMtTouchMinor(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
40     void SetMtOrientation(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
41     void SetBtnTouch(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
42     void SetEvAbsX(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
43     void SetEvAbsY(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
44     void SetEvAbsZ(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
45     void SetMtTouchFingerType(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0,
46                               int32_t status = 1);
47     void SetEvAbsRx(InputEventArray& inputEventArray, int32_t blockTime, int32_t value);
48     void SetEvAbsRy(InputEventArray& inputEventArray, int32_t blockTime, int32_t value);
49     void SetEvAbsRz(InputEventArray& inputEventArray, int32_t blockTime, int32_t value);
50     void SetEvAbsHat0X(InputEventArray& inputEventArray, int32_t blockTime, int32_t value);
51     void SetEvAbsHat0Y(InputEventArray& inputEventArray, int32_t blockTime, int32_t value);
52     void SetEvAbs(InputEventArray& inputEventArray, int32_t blockTime, uint16_t code, int32_t value);
53     void SetRelX(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
54     void SetRelY(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
55     void SetRelWheel(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
56     void SetRelHwheel(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
57     void SetEvAbsWheel(InputEventArray& inputEventArray, int32_t blockTime, int32_t value);
58     void SetAbsMisc(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
59     void SetAbsTiltX(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
60     void SetAbsTiltY(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
61     void SetAbsPressure(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
62     void SetAbsDistance(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
63     void SetBtnPen(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
64     void SetBtnStylus(InputEventArray& inputEventArray, int32_t blockTime,
65                       uint16_t code = BTN_STYLUS_DEFAULT_CODE, int32_t value = 0);
66     void SetBtnRubber(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
67     void SetMscSerial(InputEventArray& inputEventArray, int32_t blockTime,
68                       int32_t value = BTN_MSC_SERIAL_DEFAULT_VALUE);
69     void SetThrottle(InputEventArray& inputEventArray, int32_t blockTime, int32_t value);
70     void SetSynMtReport(InputEventArray& inputEventArray, int32_t blockTime, int32_t value = 0);
71 private:
72     static constexpr int32_t FIRST_FINGER = 1;
73     static constexpr int32_t SECOND_FINGER = 2;
74     static constexpr int32_t THIRD_FINGER = 3;
75     static constexpr int32_t FOURTH_FINGER = 4;
76     static constexpr int32_t FITTH_FINGER = 5;
77     static constexpr int32_t BTN_STYLUS_DEFAULT_CODE = 331;
78     static constexpr int32_t EV_ABS_MISC_DEFAULT_VALUE = 15;
79     static constexpr int32_t BTN_MSC_SERIAL_DEFAULT_VALUE = 0xA806D21;
80 };
81 } // namespace MMI
82 } // namespace OHOS
83 #endif // DEVICE_BASE_H