xref: /OK3568_Linux_fs/app/lvgl_demo/hal/evdev.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /**
2  * @file evdev.h
3  *
4  */
5 
6 #ifndef EVDEV_H
7 #define EVDEV_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*-------------------------------------------------
14  * Mouse or touchpad as evdev interface (for Linux based systems)
15  *------------------------------------------------*/
16 #ifndef USE_EVDEV
17 #  define USE_EVDEV           1
18 #endif
19 
20 #ifndef USE_BSD_EVDEV
21 #  define USE_BSD_EVDEV       0
22 #endif
23 
24 #if USE_EVDEV || USE_BSD_EVDEV
25 #  define EVDEV_NAME   "/dev/input/event2"        /*You can use the "evtest" Linux tool to get the list of devices and test them*/
26 #  define EVDEV_SWAP_AXES         0               /*Swap the x and y axes of the touchscreen*/
27 
28 #  define EVDEV_CALIBRATE         1               /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/
29 
30 #  if EVDEV_CALIBRATE
31 #    define EVDEV_HOR_MIN         0               /*to invert axis swap EVDEV_XXX_MIN by EVDEV_XXX_MAX*/
32 #    define EVDEV_HOR_MAX      720               /*"evtest" Linux tool can help to get the correct calibraion values>*/
33 #    define EVDEV_VER_MIN         0
34 #    define EVDEV_VER_MAX      1280
35 #  endif  /*EVDEV_CALIBRATE*/
36 #endif  /*USE_EVDEV*/
37 
38 #if USE_EVDEV || USE_BSD_EVDEV
39 
40 #include "lvgl.h"
41 
42 /*********************
43  *      DEFINES
44  *********************/
45 
46 /**********************
47  *      TYPEDEFS
48  **********************/
49 
50 /**********************
51  * GLOBAL PROTOTYPES
52  **********************/
53 
54 /**
55  * Initialize the evdev
56  */
57 void evdev_init(int rot);
58 /**
59  * reconfigure the device file for evdev
60  * @param dev_name set the evdev device filename
61  * @return true: the device file set complete
62  *         false: the device file doesn't exist current system
63  */
64 bool evdev_set_file(char* dev_name);
65 /**
66  * Get the current position and state of the evdev
67  * @param data store the evdev data here
68  * @return false: because the points are not buffered, so no more data to be read
69  */
70 void evdev_read(lv_indev_drv_t * drv, lv_indev_data_t * data);
71 
72 
73 /**********************
74  *      MACROS
75  **********************/
76 
77 #endif /* USE_EVDEV */
78 
79 #ifdef __cplusplus
80 } /* extern "C" */
81 #endif
82 
83 #endif /* EVDEV_H */
84