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