lv_indev.h
API reference for lv_indev.h
Functions
lv_indev_set_type
Set the type of an input device
void lv_indev_set_type(lv_indev_t *indev, lv_indev_type_t indev_type)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
indev_type | lv_indev_type_t | the type of the input device from lv_indev_type_t (LV_INDEV_TYPE_...) |
lv_indev_set_read_cb
Set a callback function to read input device data to the indev
void lv_indev_set_read_cb(lv_indev_t *indev, lv_indev_read_cb_t read_cb)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
read_cb | lv_indev_read_cb_t | pointer to callback function to read input device data |
lv_indev_set_user_data
Set user data to the indev
void lv_indev_set_user_data(lv_indev_t *indev, void *user_data)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
user_data | void * | pointer to user data May be NULL. |
lv_indev_set_driver_data
Set driver data to the indev
void lv_indev_set_driver_data(lv_indev_t *indev, void *driver_data)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
driver_data | void * | pointer to driver data May be NULL. |
lv_indev_set_display
Assign a display to the indev
void lv_indev_set_display(lv_indev_t *indev, struct _lv_display_t *disp)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
disp | struct _lv_display_t * | pointer to an display May be NULL. |
lv_indev_set_long_press_time
Set long press time to indev
void lv_indev_set_long_press_time(lv_indev_t *indev, uint16_t long_press_time)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to input device |
long_press_time | uint16_t | time long press time in ms |
lv_indev_set_long_press_repeat_time
Set long press repeat time to indev
void lv_indev_set_long_press_repeat_time(lv_indev_t *indev, uint16_t long_press_repeat_time)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to input device |
long_press_repeat_time | uint16_t | long press repeat time in ms |
lv_indev_set_double_click_time
Set double click time to indev
void lv_indev_set_double_click_time(lv_indev_t *indev, uint16_t double_click_time)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to input device |
double_click_time | uint16_t | double/triple click time in ms |
lv_indev_set_scroll_limit
Set scroll limit to the input device
void lv_indev_set_scroll_limit(lv_indev_t *indev, uint8_t scroll_limit)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
scroll_limit | uint8_t | the number of pixels to slide before actually drag the object |
lv_indev_set_scroll_throw
Set scroll throw slow-down to the indev. Greater value means faster slow-down
void lv_indev_set_scroll_throw(lv_indev_t *indev, uint8_t scroll_throw)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
scroll_throw | uint8_t | the slow-down in [%] |
lv_indev_set_gesture_min_velocity
Set the minimum velocity threshold for gesture detection. The difference between consecutive points must exceed this value (in pixels) for the movement to be considered fast enough to trigger a gesture.
void lv_indev_set_gesture_min_velocity(lv_indev_t *indev, uint8_t min_velocity)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
min_velocity | uint8_t | minimum velocity threshold in pixels (default: 3) |
lv_indev_set_gesture_min_distance
Set the minimum distance threshold for gesture detection. The total distance from the first point to the current point must exceed this value (in pixels) for the movement to be considered large enough to trigger a gesture.
void lv_indev_set_gesture_min_distance(lv_indev_t *indev, uint8_t min_distance)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
min_distance | uint8_t | minimum distance threshold in pixels (default: 50) |
lv_indev_set_cursor
Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON)
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
cur_obj | lv_obj_t * | pointer to an object to be used as cursor |
lv_indev_set_group
Set a destination group for a keypad or encoder input device
void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
group | lv_group_t * | pointer to a group May be NULL.. Use NULL to detatch group from the indev |
lv_indev_set_button_points
Set the an array of points for LV_INDEV_TYPE_BUTTON. These points will be assigned to the buttons to press a specific point on the screen
void lv_indev_set_button_points(lv_indev_t *indev, const lv_point_t points[])| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
points | const lv_point_t | array of points |
lv_indev_set_mode
Set the input device's event model: event-driven mode or timer mode.
void lv_indev_set_mode(lv_indev_t *indev, lv_indev_mode_t mode)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
mode | lv_indev_mode_t | the mode of input device |
lv_indev_set_key_remap_cb
Set key remapping callback (LV_INDEV_TYPE_KEYPAD)
void lv_indev_set_key_remap_cb(lv_indev_t *indev, lv_indev_key_remap_cb_t remap_cb)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an indev |
remap_cb | lv_indev_key_remap_cb_t | remapping function callback. Use NULL to disable callback. |
lv_indev_set_ccw
Set Counter-Clock-Wise (CCW) rotation processing for an indev
void lv_indev_set_ccw(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | indev to set CCW rotation processing on |
lv_indev_set_external_data
Attaches external user data and destructor callback to an indev.
Associates custom user data with an LVGL indev and specifies a destructor function that will be automatically invoked when the indev is deleted to properly clean up the associated resources.
void lv_indev_set_external_data(lv_indev_t *indev, void *data, void(*free_cb)(void *data))| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | Pointer to an indev |
data | void * | User-defined data pointer to associate with the indev May be NULL. |
free_cb | void(*)(void *data) | Callback function for cleaning up ext_data when indev is deleted. Receives ext_data as parameter. May be NULL. When NULL no cleanup is performed. |
lv_indev_get_next
Get the next input device.
lv_indev_t * lv_indev_get_next(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to the current input device. May be NULL. When NULL the first input device is returned. |
Returns: lv_indev_t * — the next input device or NULL if there are no more.
lv_indev_get_type
Get the type of an input device
lv_indev_type_t lv_indev_get_type(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: lv_indev_type_t — the type of the input device from lv_hal_indev_type_t (LV_INDEV_TYPE_...)
lv_indev_get_read_cb
Get the callback function to read input device data to the indev
lv_indev_read_cb_t lv_indev_get_read_cb(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
Returns: lv_indev_read_cb_t — Pointer to callback function to read input device data or NULL if indev is NULL
lv_indev_get_state
Get the indev state
lv_indev_state_t lv_indev_get_state(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: lv_indev_state_t — Indev state or LV_INDEV_STATE_RELEASED if indev is NULL
lv_indev_get_group
Get the indev assigned group
lv_group_t * lv_indev_get_group(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: lv_group_t * — Pointer to indev assigned group or NULL if indev is NULL
lv_indev_get_display
Get a pointer to the assigned display of the indev
lv_display_t * lv_indev_get_display(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: lv_display_t * — pointer to the assigned display or NULL if indev is NULL
lv_indev_get_user_data
Get a pointer to the user data of the indev
void * lv_indev_get_user_data(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: void * — pointer to the user data or NULL if indev is NULL
lv_indev_get_driver_data
Get a pointer to the driver data of the indev
void * lv_indev_get_driver_data(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: void * — pointer to the driver data or NULL if indev is NULL
lv_indev_get_press_moved
Get whether indev is moved while pressed
bool lv_indev_get_press_moved(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: bool — true: indev is moved while pressed; false: indev is not moved while pressed
lv_indev_get_point
Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
void lv_indev_get_point(const lv_indev_t *indev, lv_point_t *point)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device. |
point | lv_point_t * | pointer to a point to store the result |
lv_indev_get_gesture_dir
Get the current gesture direct
lv_dir_t lv_indev_get_gesture_dir(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: lv_dir_t — current gesture direct
lv_indev_get_key
Get the last pressed key of an input device (for LV_INDEV_TYPE_KEYPAD)
uint32_t lv_indev_get_key(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: uint32_t — the last pressed key (0 on error)
lv_indev_get_short_click_streak
Get the counter for consecutive clicks within a short distance and time. The counter is updated before LV_EVENT_SHORT_CLICKED is fired.
uint8_t lv_indev_get_short_click_streak(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: uint8_t — short click streak counter
lv_indev_get_scroll_dir
Check the current scroll direction of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
lv_dir_t lv_indev_get_scroll_dir(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: lv_dir_t — LV_DIR_NONE: no scrolling now LV_DIR_HOR/VER
lv_indev_get_scroll_obj
Get the currently scrolled object (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
lv_obj_t * lv_indev_get_scroll_obj(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
Returns: lv_obj_t * — pointer to the currently scrolled object or NULL if no scrolling by this indev
lv_indev_get_vect
Get the movement vector of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
void lv_indev_get_vect(const lv_indev_t *indev, lv_point_t *point)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | pointer to an input device |
point | lv_point_t * | pointer to a point to store the types.pointer.vector |
lv_indev_get_cursor
Get the cursor object of an input device (for LV_INDEV_TYPE_POINTER only)
lv_obj_t * lv_indev_get_cursor(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
Returns: lv_obj_t * — pointer to the cursor object
lv_indev_get_active_obj
Gets a pointer to the currently active object in the currently processed input device.
lv_obj_t * lv_indev_get_active_obj(void)Returns: lv_obj_t * — pointer to currently active object or NULL if no active object
lv_indev_get_read_timer
Get a pointer to the indev read timer to modify its parameters with lv_timer_... functions.
lv_timer_t * lv_indev_get_read_timer(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
Returns: lv_timer_t * — pointer to the indev read refresher timer. (NULL on error)
lv_indev_get_mode
Get the input device's running mode.
lv_indev_mode_t lv_indev_get_mode(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
Returns: lv_indev_mode_t — the running mode for the specified input device.
lv_indev_get_event_count
Get the number of event attached to an indev
uint32_t lv_indev_get_event_count(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an indev |
Returns: uint32_t — number of events
lv_indev_get_event_dsc
Get an event descriptor for an event
lv_event_dsc_t * lv_indev_get_event_dsc(lv_indev_t *indev, uint32_t index)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an indev |
index | uint32_t | the index of the event |
Returns: lv_event_dsc_t * — the event descriptor
lv_indev_get_ccw
Get Counter-Clock-Wise (CCW) rotation processing for an indev
bool lv_indev_get_ccw(const lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | const lv_indev_t * | indev to get CCW rotation from |
Returns: bool — True if CCW processing is set for an indev, false if indev is NULL or CCW processing is not set.
lv_indev_create
Create an indev
lv_indev_t * lv_indev_create(void)Returns: lv_indev_t * — Pointer to the created indev or NULL when allocation failed
lv_indev_delete
Remove the provided input device. Make sure not to use the provided input device afterwards anymore.
void lv_indev_delete(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to delete May be NULL. |
lv_indev_read
Read data from an input device.
void lv_indev_read(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
lv_indev_read_timer_cb
Called periodically to read the input devices
void lv_indev_read_timer_cb(lv_timer_t *timer)| Name | Type | Description |
|---|---|---|
timer | lv_timer_t * | pointer to a timer to read |
lv_indev_enable
Enable or disable one or all input devices (default enabled)
void lv_indev_enable(lv_indev_t *indev, bool enable)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device. May be NULL. When NULL every input device is enabled/disabled. |
enable | bool | true to enable, false to disable |
lv_indev_active
Get the currently processed input device. Can be used in action functions too.
lv_indev_t * lv_indev_active(void)Returns: lv_indev_t * — pointer to the currently processed input device or NULL if no input device processing right now
lv_indev_reset
Reset one or all input devices
void lv_indev_reset(lv_indev_t *indev, lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device to reset. May be NULL. When NULL every input device is reset. |
obj | lv_obj_t * | pointer to an object which triggers the reset. May be NULL. When NULL the reset is not attributed to any object. |
lv_indev_stop_processing
Touch and key related events are sent to the input device first and to the widget after that. If this functions called in an indev event, the event won't be sent to the widget.
void lv_indev_stop_processing(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
lv_indev_reset_long_press
Reset the long press state of an input device
void lv_indev_reset_long_press(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
lv_indev_wait_release
Do nothing until the next release
void lv_indev_wait_release(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an input device |
lv_indev_search_obj
Search the most top, clickable object by a point
lv_obj_t * lv_indev_search_obj(lv_obj_t *obj, lv_point_t *point)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to a start object, typically the screen |
point | lv_point_t * | pointer to a point for searching the most top child |
Returns: lv_obj_t * — pointer to the found object or NULL if there was no suitable object
lv_indev_add_event_cb
Add an event handler to the indev
lv_event_dsc_t * lv_indev_add_event_cb(lv_indev_t *indev, lv_event_cb_t event_cb, lv_event_code_t filter, void *user_data)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an indev |
event_cb | lv_event_cb_t | an event callback |
filter | lv_event_code_t | event code to react or LV_EVENT_ALL |
user_data | void * | optional user_data May be NULL. |
Returns: lv_event_dsc_t * — the event descriptor or NULL if the event couldn't be created
lv_indev_remove_event
Remove an event
bool lv_indev_remove_event(lv_indev_t *indev, uint32_t index)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an indev |
index | uint32_t | the index of the event to remove |
Returns: bool — true: and event was removed; false: no event was removed
lv_indev_remove_event_cb_with_user_data
Remove an event_cb with user_data
uint32_t lv_indev_remove_event_cb_with_user_data(lv_indev_t *indev, lv_event_cb_t event_cb, void *user_data)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to a indev |
event_cb | lv_event_cb_t | the event_cb of the event to remove |
user_data | void * | user_data May be NULL. |
Returns: uint32_t — the count of the event removed
lv_indev_send_event
Send an event to an indev
lv_result_t lv_indev_send_event(lv_indev_t *indev, lv_event_code_t code, void *param)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | pointer to an indev |
code | lv_event_code_t | an event code. LV_EVENT_... |
param | void * | optional param May be NULL. |
Returns: lv_result_t — LV_RESULT_OK: indev wasn't deleted in the event.
lv_indev_clear_ccw
Clear Counter-Clock-Wise (CCW) rotation processing for an indev
void lv_indev_clear_ccw(lv_indev_t *indev)| Name | Type | Description |
|---|---|---|
indev | lv_indev_t * | indev to clear CCW rotation processing on |
Enums
lv_indev_type_t
Possible input device types
| Name | Description |
|---|---|
LV_INDEV_TYPE_NONE | Uninitialized state |
LV_INDEV_TYPE_POINTER | Touch pad, mouse, external button |
LV_INDEV_TYPE_KEYPAD | Keypad or keyboard |
LV_INDEV_TYPE_BUTTON | External (hardware button) which is assigned to a specific point of the screen |
LV_INDEV_TYPE_ENCODER | Encoder with only Left, Right turn and a Button |
Used by 6 functions
lv_test_indev_get_indev— paramtypelv_test_indev_get_gesture_indev— paramtypelv_evdev_create— paramindev_typelv_evdev_create_fd— paramindev_typelv_libinput_create— paramindev_typelv_indev_set_type— paramindev_type
lv_indev_state_t
States for input devices
| Name | Value |
|---|---|
LV_INDEV_STATE_RELEASED | 0 |
LV_INDEV_STATE_PRESSED |
lv_indev_mode_t
| Name | Value |
|---|---|
LV_INDEV_MODE_NONE | 0 |
LV_INDEV_MODE_TIMER | |
LV_INDEV_MODE_EVENT |
Used by 1 function
lv_indev_set_mode— parammode
lv_indev_gesture_type_t
| Name | Value |
|---|---|
LV_INDEV_GESTURE_NONE | 0 |
LV_INDEV_GESTURE_PINCH | |
LV_INDEV_GESTURE_SWIPE | |
LV_INDEV_GESTURE_ROTATE | |
LV_INDEV_GESTURE_TWO_FINGERS_SWIPE | |
LV_INDEV_GESTURE_SCROLL | |
LV_INDEV_GESTURE_CNT |
Used by 2 functions
lv_indev_set_gesture_data— paramtypelv_event_get_gesture_state— paramtype
Structs
lv_indev_data_t
Data structure passed to an input driver to fill
| Member | Type | Description |
|---|---|---|
gesture_type | lv_indev_gesture_type_t[LV_INDEV_GESTURE_CNT] | |
gesture_data | void *[LV_INDEV_GESTURE_CNT] | |
state | lv_indev_state_t | LV_INDEV_STATE_RELEASED or LV_INDEV_STATE_PRESSED |
point | lv_point_t | For LV_INDEV_TYPE_POINTER the currently pressed point |
key | uint32_t | For LV_INDEV_TYPE_KEYPAD the currently pressed key |
btn_id | uint32_t | For LV_INDEV_TYPE_BUTTON the currently pressed button |
enc_diff | int16_t | For LV_INDEV_TYPE_ENCODER number of steps since the previous read |
timestamp | uint32_t | Initialized to lv_tick_get(). Driver may provide more accurate timestamp for buffered events |
continue_reading | bool | If set to true, the read callback is invoked again, unless the device is in event-driven mode |
Used by 2 functions
lv_indev_set_gesture_data— paramdatalv_indev_gesture_recognizers_set_data— paramdata
Typedefs
lv_indev_read_cb_t
typedef void(* lv_indev_read_cb_t) (lv_indev_t *indev, lv_indev_data_t *data)Used by 3 functions
lv_indev_set_read_cb— paramread_cblv_wayland_update_indevs— paramread_cblv_wayland_indevs_ready— paramread_cb
lv_indev_key_remap_cb_t
typedef lv_key_t(* lv_indev_key_remap_cb_t) (lv_indev_t *indev, lv_key_t key)Indev key remapping callback
Used by 1 function
lv_indev_set_key_remap_cb— paramremap_cb
Dependencies
lv_obj_event.hlv_monkey.hlv_test_indev.hlv_test_indev_gesture.hlv_lovyan_gfx.hlv_evdev.hlv_libinput.hlv_nuttx_entry.hlv_nuttx_libuv.hlv_nuttx_touchscreen.hlv_qnx.hlv_sdl_window.hlv_uefi_indev.hlv_wayland_keyboard.hlv_wayland_pointer.hlv_wayland_pointer_axis.hlv_wayland_touch.hlv_windows_display.hlv_windows_input.hlv_x11.hlvgl.h
Indirect dependencies
Last updated on