• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
ReportAbs(InputDevice * inputDev,uint32_t code,int32_t value)31 static inline void ReportAbs(InputDevice *inputDev, uint32_t code, int32_t value)
32 {
33     PushOnePackage(inputDev, EV_ABS, code, value);
34 }
35 
ReportKey(InputDevice * inputDev,uint32_t code,int32_t value)36 static inline void ReportKey(InputDevice *inputDev, uint32_t code, int32_t value)
37 {
38     PushOnePackage(inputDev, EV_KEY, code, !!value);
39 }
40 
ReportRel(InputDevice * inputDev,uint32_t code,int32_t value)41 static inline void ReportRel(InputDevice *inputDev, uint32_t code, int32_t value)
42 {
43     PushOnePackage(inputDev, EV_REL, code, value);
44 }
45 
ReportSync(InputDevice * inputDev)46 static inline void ReportSync(InputDevice *inputDev)
47 {
48     PushOnePackage(inputDev, EV_SYN, SYN_REPORT, 0);
49 }
50 
ReportMtSync(InputDevice * inputDev)51 static inline void ReportMtSync(InputDevice *inputDev)
52 {
53     PushOnePackage(inputDev, EV_SYN, SYN_MT_REPORT, 0);
54 }
55 
56 #endif
57