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 "../hal/lv_hal_indev.h" 18 #include "lv_group.h" 19 20 /********************* 21 * DEFINES 22 *********************/ 23 24 /********************** 25 * TYPEDEFS 26 **********************/ 27 28 /********************** 29 * GLOBAL PROTOTYPES 30 **********************/ 31 32 /** 33 * Called periodically to read the input devices 34 * @param timer pointer to a timer to read 35 */ 36 void lv_indev_read_timer_cb(lv_timer_t * timer); 37 38 39 void lv_indev_enable(lv_indev_t * indev, bool en); 40 41 /** 42 * Get the currently processed input device. Can be used in action functions too. 43 * @return pointer to the currently processed input device or NULL if no input device processing 44 * right now 45 */ 46 lv_indev_t * lv_indev_get_act(void); 47 48 /** 49 * Get the type of an input device 50 * @param indev pointer to an input device 51 * @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`) 52 */ 53 lv_indev_type_t lv_indev_get_type(const lv_indev_t * indev); 54 55 /** 56 * Reset one or all input devices 57 * @param indev pointer to an input device to reset or NULL to reset all of them 58 * @param obj pointer to an object which triggers the reset. 59 */ 60 void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj); 61 62 /** 63 * Reset the long press state of an input device 64 * @param indev pointer to an input device 65 */ 66 void lv_indev_reset_long_press(lv_indev_t * indev); 67 68 /** 69 * Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON) 70 * @param indev pointer to an input device 71 * @param cur_obj pointer to an object to be used as cursor 72 */ 73 void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj); 74 75 /** 76 * Set a destination group for a keypad input device (for LV_INDEV_TYPE_KEYPAD) 77 * @param indev pointer to an input device 78 * @param group point to a group 79 */ 80 void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group); 81 82 /** 83 * Set the an array of points for LV_INDEV_TYPE_BUTTON. 84 * These points will be assigned to the buttons to press a specific point on the screen 85 * @param indev pointer to an input device 86 * @param group point to a group 87 */ 88 void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t points[]); 89 90 /** 91 * Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) 92 * @param indev pointer to an input device 93 * @param point pointer to a point to store the result 94 */ 95 void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point); 96 97 /** 98 * Get the current gesture direct 99 * @param indev pointer to an input device 100 * @return current gesture direct 101 */ 102 lv_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev); 103 104 /** 105 * Get the last pressed key of an input device (for LV_INDEV_TYPE_KEYPAD) 106 * @param indev pointer to an input device 107 * @return the last pressed key (0 on error) 108 */ 109 uint32_t lv_indev_get_key(const lv_indev_t * indev); 110 111 /** 112 * Check the current scroll direction of an input device (for LV_INDEV_TYPE_POINTER and 113 * LV_INDEV_TYPE_BUTTON) 114 * @param indev pointer to an input device 115 * @return LV_DIR_NONE: no scrolling now 116 * LV_DIR_HOR/VER 117 */ 118 lv_dir_t lv_indev_get_scroll_dir(const lv_indev_t * indev); 119 120 /** 121 * Get the currently scrolled object (for LV_INDEV_TYPE_POINTER and 122 * LV_INDEV_TYPE_BUTTON) 123 * @param indev pointer to an input device 124 * @return pointer to the currently scrolled object or NULL if no scrolling by this indev 125 */ 126 lv_obj_t * lv_indev_get_scroll_obj(const lv_indev_t * indev); 127 128 /** 129 * Get the movement vector of an input device (for LV_INDEV_TYPE_POINTER and 130 * LV_INDEV_TYPE_BUTTON) 131 * @param indev pointer to an input device 132 * @param point pointer to a point to store the types.pointer.vector 133 */ 134 void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point); 135 136 /** 137 * Do nothing until the next release 138 * @param indev pointer to an input device 139 */ 140 void lv_indev_wait_release(lv_indev_t * indev); 141 142 /** 143 * Gets a pointer to the currently active object in the currently processed input device. 144 * @return pointer to currently active object or NULL if no active object 145 */ 146 lv_obj_t * lv_indev_get_obj_act(void); 147 148 /** 149 * Get a pointer to the indev read timer to 150 * modify its parameters with `lv_timer_...` functions. 151 * @param indev pointer to an input device 152 * @return pointer to the indev read refresher timer. (NULL on error) 153 */ 154 lv_timer_t * lv_indev_get_read_timer(lv_disp_t * indev); 155 156 /** 157 * Search the most top, clickable object by a point 158 * @param obj pointer to a start object, typically the screen 159 * @param point pointer to a point for searching the most top child 160 * @return pointer to the found object or NULL if there was no suitable object 161 */ 162 lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point); 163 164 /********************** 165 * MACROS 166 **********************/ 167 168 #ifdef __cplusplus 169 } /*extern "C"*/ 170 #endif 171 172 #endif /*LV_INDEV_H*/ 173