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 PROCESSING_TOUCH_SCREEN_DEVICE_H
17 #define PROCESSING_TOUCH_SCREEN_DEVICE_H
18 
19 #include "device_base.h"
20 #include "msg_head.h"
21 
22 namespace OHOS {
23 namespace MMI {
24 class ProcessingTouchScreenDevice : public DeviceBase {
25     struct TouchSingleEventData {
26         int32_t trackingId { 0 };
27         int32_t xPos { 0 };
28         int32_t yPos { 0 };
29         int64_t blockTime { 0 };
30         std::string eventType;
31         std::string reportType;
32     };
33 
34     struct TouchScreenCoordinates {
35         int32_t xPos { 0 };
36         int32_t yPos { 0 };
37     };
38 
39     struct TouchScreenInputEvent {
40         uint32_t groupNumber { 0 };
41         std::vector<TouchScreenCoordinates> events;
42     };
43 
44     struct TouchScreenInputEvents {
45         uint32_t eventNumber { 0 };
46         std::vector<TouchScreenInputEvent> eventArray;
47     };
48 public:
49     ProcessingTouchScreenDevice() = default;
50     ~ProcessingTouchScreenDevice() = default;
51     DISALLOW_COPY_AND_MOVE(ProcessingTouchScreenDevice);
52     int32_t TransformJsonDataSingleTouchScreen(const DeviceItem &inputEventArrays, InputEventArray &inputEventArray);
53     int32_t TransformJsonDataToInputData(const DeviceItem &inputEventArrays, InputEventArray &inputEventArray);
54 private:
55     void AnalysisTouchScreenDate(const std::vector<DeviceEvent> &inputData,
56         TouchScreenInputEvents &touchScreenInputEvents);
57     void AnalysisSingleTouchScreenDate(const std::vector<DeviceEvent> &inputData,
58                                        std::vector<TouchSingleEventData> &touchSingleEventDatas);
59     void AnalysisTouchScreenPressData(InputEventArray &inputEventArray,
60         const TouchScreenInputEvent &touchScreenInputEvent);
61     void AnalysisTouchScreenMoveData(InputEventArray &inputEventArray,
62         const TouchScreenInputEvent &touchScreenInputEvent);
63     void AnalysisTouchScreenReleaseData(InputEventArray &inputEventArray,
64         const TouchScreenInputEvent &touchScreenInputEvent);
65     void AnalysisTouchScreenPressData(InputEventArray &inputEventArray,
66         const TouchSingleEventData &touchSingleEventData);
67     void AnalysisTouchScreenMoveData(InputEventArray &inputEventArray,
68         const TouchSingleEventData &touchSingleEventData);
69     void AnalysisTouchScreenReleaseData(InputEventArray &inputEventArray,
70         const TouchSingleEventData &touchSingleEventData);
71     void AnalysisTouchScreenToInputData(InputEventArray &inputEventArray,
72                                         const TouchSingleEventData &touchSingleEventData);
73 };
74 } // namespace MMI
75 } // namespace OHOS
76 #endif // PROCESSING_TOUCH_SCREEN_DEVICE_H