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