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