1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef EVENT_HUB_H
10 #define EVENT_HUB_H
11 
12 #include "input-event-codes.h"
13 #include "hdf_input_device_manager.h"
14 #include "osal_time.h"
15 
16 #define input_report_abs    ReportAbs
17 #define input_report_key    ReportKey
18 #define input_report_rel    ReportRel
19 #define input_sync          ReportSync
20 #define input_mt_sync       ReportMtSync
21 
22 typedef struct {
23     uint32_t type;
24     uint32_t code;
25     int32_t value;
26     uint64_t time;
27 } EventPackage;
28 
29 void PushOnePackage(InputDevice *inputDev, uint32_t type, uint32_t code, int32_t value);
30 void EventQueueWorkEntry(void *arg);
31 
ReportAbs(InputDevice * inputDev,uint32_t code,int32_t value)32 static inline void ReportAbs(InputDevice *inputDev, uint32_t code, int32_t value)
33 {
34     PushOnePackage(inputDev, EV_ABS, code, value);
35 }
36 
ReportKey(InputDevice * inputDev,uint32_t code,int32_t value)37 static inline void ReportKey(InputDevice *inputDev, uint32_t code, int32_t value)
38 {
39     PushOnePackage(inputDev, EV_KEY, code, !!value);
40 }
41 
ReportRel(InputDevice * inputDev,uint32_t code,int32_t value)42 static inline void ReportRel(InputDevice *inputDev, uint32_t code, int32_t value)
43 {
44     PushOnePackage(inputDev, EV_REL, code, value);
45 }
46 
ReportSync(InputDevice * inputDev)47 static inline void ReportSync(InputDevice *inputDev)
48 {
49     PushOnePackage(inputDev, EV_SYN, SYN_REPORT, 0);
50 }
51 
ReportMtSync(InputDevice * inputDev)52 static inline void ReportMtSync(InputDevice *inputDev)
53 {
54     PushOnePackage(inputDev, EV_SYN, SYN_MT_REPORT, 0);
55 }
56 
57 #endif
58