1 /**
2  * @file lv_libinput.h
3  *
4  */
5 
6 #ifndef LV_LIBINPUT_H
7 #define LV_LIBINPUT_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /*********************
14  *      INCLUDES
15  *********************/
16 
17 #include "../../indev/lv_indev.h"
18 
19 #if LV_USE_LIBINPUT
20 
21 #include <poll.h>
22 #include <pthread.h>
23 
24 #if LV_LIBINPUT_XKB
25 #include "lv_xkb.h"
26 #endif /* LV_LIBINPUT_XKB */
27 
28 /*********************
29  *      DEFINES
30  *********************/
31 
32 /**********************
33  *      TYPEDEFS
34  **********************/
35 typedef enum {
36     LV_LIBINPUT_CAPABILITY_NONE     = 0,
37     LV_LIBINPUT_CAPABILITY_KEYBOARD = 1U << 0,
38     LV_LIBINPUT_CAPABILITY_POINTER  = 1U << 1,
39     LV_LIBINPUT_CAPABILITY_TOUCH    = 1U << 2
40 } lv_libinput_capability;
41 
42 struct libinput_device;
43 
44 #define LV_LIBINPUT_MAX_EVENTS 32
45 
46 /**********************
47  * GLOBAL PROTOTYPES
48  **********************/
49 
50 /**
51  * Determine the capabilities of a specific libinput device.
52  * @param device the libinput device to query
53  * @return the supported input capabilities
54  */
55 lv_libinput_capability lv_libinput_query_capability(struct libinput_device * device);
56 
57 /**
58  * Find connected input device with specific capabilities
59  * @param capabilities required device capabilities
60  * @param force_rescan erase the device cache (if any) and rescan the file system for available devices
61  * @return device node path (e.g. /dev/input/event0) for the first matching device or NULL if no device was found.
62  *         The pointer is safe to use until the next forceful device search.
63  */
64 char * lv_libinput_find_dev(lv_libinput_capability capabilities, bool force_rescan);
65 
66 /**
67  * Find connected input devices with specific capabilities
68  * @param capabilities required device capabilities
69  * @param devices pre-allocated array to store the found device node paths (e.g. /dev/input/event0). The pointers are
70  *                safe to use until the next forceful device search.
71  * @param count maximum number of devices to find (the devices array should be at least this long)
72  * @param force_rescan erase the device cache (if any) and rescan the file system for available devices
73  * @return number of devices that were found
74  */
75 size_t lv_libinput_find_devs(lv_libinput_capability capabilities, char ** found, size_t count, bool force_rescan);
76 
77 /**
78  * Create a new libinput input device
79  * @param type LV_INDEV_TYPE_POINTER or LV_INDEV_TYPE_KEYPAD
80  * @param dev_path device path, e.g. /dev/input/event0
81  * @return pointer to input device or NULL if opening failed
82  */
83 lv_indev_t * lv_libinput_create(lv_indev_type_t indev_type, const char * dev_path);
84 
85 /**
86  * Delete a libinput input device
87  * @param indev pointer to input device
88  */
89 void lv_libinput_delete(lv_indev_t * indev);
90 
91 /**********************
92  *      MACROS
93  **********************/
94 
95 #endif /* LV_USE_LIBINPUT */
96 
97 #ifdef __cplusplus
98 } /* extern "C" */
99 #endif
100 
101 #endif /* LV_LIBINPUT_H */
102