1 /** 2 * @file lv_evdev.h 3 * 4 */ 5 6 #ifndef LV_EVDEV_H 7 #define LV_EVDEV_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_EVDEV 20 21 /********************** 22 * TYPEDEFS 23 **********************/ 24 25 typedef enum { 26 LV_EVDEV_TYPE_REL, /**< mice */ 27 LV_EVDEV_TYPE_ABS, /**< touch screens, mousepads */ 28 LV_EVDEV_TYPE_KEY /**< keyboards, keypads, buttons */ 29 } lv_evdev_type_t; 30 31 /** 32 * @param indev the indev created for the newly discovered evdev 33 * @param type the type of the evdev 34 * @param user_data a custom parameter 35 */ 36 typedef void (*lv_evdev_discovery_cb_t)(lv_indev_t * indev, lv_evdev_type_t type, void * user_data); 37 38 /********************** 39 * GLOBAL PROTOTYPES 40 **********************/ 41 42 /** 43 * Create evdev input device. 44 * @param type LV_INDEV_TYPE_POINTER or LV_INDEV_TYPE_KEYPAD 45 * @param dev_path device path, e.g., /dev/input/event0 46 * @return pointer to input device or NULL if opening failed 47 */ 48 lv_indev_t * lv_evdev_create(lv_indev_type_t indev_type, const char * dev_path); 49 50 /** 51 * Begin automatically creating evdev indevs for all new and existing 52 * evdev devices found in /dev/input/ 53 * @param cb function to call when a new evdev indev is discovered, or `NULL` 54 * @param user_data parameter to pass to the callback 55 * @return the success or failure status. It will fail if it's 56 * already running or resources could not be initialized. 57 */ 58 lv_result_t lv_evdev_discovery_start(lv_evdev_discovery_cb_t cb, void * user_data); 59 60 /** 61 * Stop automatically creating evdev indevs. Safe to call from the 62 * discovery callback. 63 * @return the success or failure status. It will fail if it's already running. 64 */ 65 lv_result_t lv_evdev_discovery_stop(void); 66 67 /** 68 * Set whether coordinates of pointer device should be swapped. Defaults to 69 * false. 70 * @param indev evdev input device 71 * @param swap_axes whether to swap x and y axes 72 */ 73 void lv_evdev_set_swap_axes(lv_indev_t * indev, bool swap_axes); 74 75 /** 76 * Configure a coordinate transformation for pointer devices. Applied after 77 * axis swap, if any. Defaults to apply no transformation. 78 * @param indev evdev input device 79 * @param min_x pointer coordinate mapped to min x of display 80 * @param min_y pointer coordinate mapped to min y of display 81 * @param max_x pointer coordinate mapped to max x of display 82 * @param max_y pointer coordinate mapped to max y of display 83 */ 84 void lv_evdev_set_calibration(lv_indev_t * indev, int min_x, int min_y, int max_x, int max_y); 85 86 /** 87 * Remove evdev input device. 88 * @param indev evdev input device to close and free 89 */ 90 void lv_evdev_delete(lv_indev_t * indev); 91 92 #endif /*LV_USE_EVDEV*/ 93 94 #ifdef __cplusplus 95 } /*extern "C"*/ 96 #endif 97 98 #endif /*LV_EVDEV_H*/ 99