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 MSG_HEAD_H
17 #define MSG_HEAD_H
18 
19 #include <algorithm>
20 #include <ctime>
21 #include <cstdio>
22 #include <cstring>
23 #include <functional>
24 #include <fstream>
25 #include <iostream>
26 #include <vector>
27 
28 #include <fcntl.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <unistd.h>
32 #include <linux/input.h>
33 #include <linux/uinput.h>
34 
35 #include "define_multimodal.h"
36 #include "input_parse.h"
37 
38 /*
39  * Structure for docking libinput
40  */
41 struct InputEvent {
42     uint16_t code;
43     int32_t target;
44     int32_t type;
45     int32_t value;
46     int32_t x;
47     int32_t y;
48     int32_t fp;
49     int32_t devType;
50     int32_t track;
51     int64_t blockTime;
52     int32_t multiReprot;
53 };
54 
55 /*
56  * Click events on devices
57  * such as mouse and keyboard
58  */
59 enum PressEvent {
60     EVENT_RELEASE = 0,
61     EVENT_PRESS = 1,
62     LONG_PRESS = 2,
63     TOUCH_PAD_PRESS = 15
64 };
65 
66 struct DeviceInformation {
67     bool status;
68     int32_t devIndex;
69     int32_t devType;
70     int16_t fd;
71     char chipName[32];
72 };
73 
74 struct InjectEvent {
75     struct input_event event;
76     int64_t blockTime;
77 };
78 
79 struct InputEventArray {
80     std::string deviceName;
81     std::string target;
82     std::vector<InjectEvent> events;
83 };
84 
85 typedef std::function<int32_t (const InputEvent& inputEvent)> WriteDeviceFun;
86 #endif // MSG_HEAD_H