1 /** 2 * @file lv_indev.h 3 * 4 */ 5 6 #ifndef LV_INDEV_H 7 #define LV_INDEV_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "lv_obj.h" 17 #include "../lv_hal/lv_hal_indev.h" 18 #include "../lv_core/lv_group.h" 19 20 /********************* 21 * DEFINES 22 *********************/ 23 24 /********************** 25 * TYPEDEFS 26 **********************/ 27 28 /********************** 29 * GLOBAL PROTOTYPES 30 **********************/ 31 32 /** 33 * Initialize the display input device subsystem 34 */ 35 void _lv_indev_init(void); 36 37 /** 38 * Called periodically to read the input devices 39 * @param task pointer to the task itself 40 */ 41 void _lv_indev_read_task(lv_task_t * task); 42 43 /** 44 * Get the currently processed input device. Can be used in action functions too. 45 * @return pointer to the currently processed input device or NULL if no input device processing 46 * right now 47 */ 48 lv_indev_t * lv_indev_get_act(void); 49 50 /** 51 * Get the type of an input device 52 * @param indev pointer to an input device 53 * @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`) 54 */ 55 lv_indev_type_t lv_indev_get_type(const lv_indev_t * indev); 56 57 /** 58 * Reset one or all input devices 59 * @param indev pointer to an input device to reset or NULL to reset all of them 60 * @param obj pointer to an object which triggers the reset. 61 */ 62 void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj); 63 64 /** 65 * Reset the long press state of an input device 66 * @param indev_proc pointer to an input device 67 */ 68 void lv_indev_reset_long_press(lv_indev_t * indev); 69 70 /** 71 * Enable or disable an input devices 72 * @param indev pointer to an input device 73 * @param en true: enable; false: disable 74 */ 75 void lv_indev_enable(lv_indev_t * indev, bool en); 76 77 /** 78 * Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON) 79 * @param indev pointer to an input device 80 * @param cur_obj pointer to an object to be used as cursor 81 */ 82 void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj); 83 84 #if LV_USE_GROUP 85 /** 86 * Set a destination group for a keypad input device (for LV_INDEV_TYPE_KEYPAD) 87 * @param indev pointer to an input device 88 * @param group point to a group 89 */ 90 void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group); 91 #endif 92 93 /** 94 * Set the an array of points for LV_INDEV_TYPE_BUTTON. 95 * These points will be assigned to the buttons to press a specific point on the screen 96 * @param indev pointer to an input device 97 * @param group point to a group 98 */ 99 void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t points[]); 100 101 /** 102 * Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) 103 * @param indev pointer to an input device 104 * @param point pointer to a point to store the result 105 */ 106 void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point); 107 108 /** 109 * Get the current gesture direct 110 * @param indev pointer to an input device 111 * @return current gesture direct 112 */ 113 lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev); 114 115 /** 116 * Get the last pressed key of an input device (for LV_INDEV_TYPE_KEYPAD) 117 * @param indev pointer to an input device 118 * @return the last pressed key (0 on error) 119 */ 120 uint32_t lv_indev_get_key(const lv_indev_t * indev); 121 122 /** 123 * Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and 124 * LV_INDEV_TYPE_BUTTON) 125 * @param indev pointer to an input device 126 * @return true: drag is in progress 127 */ 128 bool lv_indev_is_dragging(const lv_indev_t * indev); 129 130 /** 131 * Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and 132 * LV_INDEV_TYPE_BUTTON) 133 * @param indev pointer to an input device 134 * @param point pointer to a point to store the vector 135 */ 136 void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point); 137 138 /** 139 * Manually finish dragging. 140 * `LV_SIGNAL_DRAG_END` and `LV_EVENT_DRAG_END` will be sent. 141 * @param indev pointer to an input device 142 * @return `LV_RES_INV` if the object being dragged was deleted. Else `LV_RES_OK`. 143 */ 144 lv_res_t lv_indev_finish_drag(lv_indev_t * indev); 145 146 /** 147 * Do nothing until the next release 148 * @param indev pointer to an input device 149 */ 150 void lv_indev_wait_release(lv_indev_t * indev); 151 152 153 /** 154 * Gets a pointer to the currently active object in indev proc functions. 155 * NULL if no object is currently being handled or if groups aren't used. 156 * @return pointer to currently active object 157 */ 158 lv_obj_t * lv_indev_get_obj_act(void); 159 160 /** 161 * Search the most top, clickable object by a point 162 * @param obj pointer to a start object, typically the screen 163 * @param point pointer to a point for searching the most top child 164 * @return pointer to the found object or NULL if there was no suitable object 165 */ 166 lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point); 167 168 /** 169 * Get a pointer to the indev read task to 170 * modify its parameters with `lv_task_...` functions. 171 * @param indev pointer to an inout device 172 * @return pointer to the indev read refresher task. (NULL on error) 173 */ 174 lv_task_t * lv_indev_get_read_task(lv_disp_t * indev); 175 176 /********************** 177 * MACROS 178 **********************/ 179 180 #ifdef __cplusplus 181 } /* extern "C" */ 182 #endif 183 184 #endif /*LV_INDEV_H*/ 185