2016-06-08 07:25:08 +02:00
|
|
|
/**
|
2019-04-08 14:40:41 +02:00
|
|
|
* @file lv_indev.h
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
|
|
|
|
2017-10-10 16:17:23 +02:00
|
|
|
#ifndef LV_INDEV_H
|
|
|
|
#define LV_INDEV_H
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_obj.h"
|
2017-10-09 15:21:26 +02:00
|
|
|
#include "../lv_hal/lv_hal_indev.h"
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_group.h"
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
2016-12-18 22:07:03 +01:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
2017-11-19 19:28:45 +01:00
|
|
|
* Initialize the display input device subsystem
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-10-10 16:17:23 +02:00
|
|
|
void lv_indev_init(void);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
2019-04-02 12:15:35 +02:00
|
|
|
/**
|
|
|
|
* Called periodically to read the input devices
|
2019-04-27 11:32:13 +02:00
|
|
|
* @param task pointer to the task itself
|
2019-04-02 12:15:35 +02:00
|
|
|
*/
|
2019-04-27 11:32:13 +02:00
|
|
|
void lv_indev_read_task(lv_task_t * task);
|
2019-04-02 12:15:35 +02:00
|
|
|
|
2017-06-21 10:26:23 +02:00
|
|
|
/**
|
2017-10-09 15:21:26 +02:00
|
|
|
* Get the currently processed input device. Can be used in action functions too.
|
2019-04-04 07:15:40 +02:00
|
|
|
* @return pointer to the currently processed input device or NULL if no input device processing
|
|
|
|
* right now
|
2017-06-21 10:26:23 +02:00
|
|
|
*/
|
2017-10-09 15:21:26 +02:00
|
|
|
lv_indev_t * lv_indev_get_act(void);
|
2017-06-21 10:26:23 +02:00
|
|
|
|
2018-07-13 00:37:28 +02:00
|
|
|
/**
|
|
|
|
* Get the type of an input device
|
|
|
|
* @param indev pointer to an input device
|
|
|
|
* @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`)
|
|
|
|
*/
|
2019-03-29 16:10:18 +01:00
|
|
|
lv_indev_type_t lv_indev_get_type(const lv_indev_t * indev);
|
2018-07-13 00:37:28 +02:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
2017-11-19 19:28:45 +01:00
|
|
|
* Reset one or all input devices
|
2017-12-17 01:54:09 +01:00
|
|
|
* @param indev pointer to an input device to reset or NULL to reset all of them
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-10-09 15:21:26 +02:00
|
|
|
void lv_indev_reset(lv_indev_t * indev);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
2017-11-19 19:28:45 +01:00
|
|
|
* Reset the long press state of an input device
|
|
|
|
* @param indev_proc pointer to an input device
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2019-03-13 22:08:20 +01:00
|
|
|
void lv_indev_reset_long_press(lv_indev_t * indev);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
2017-10-10 16:17:23 +02:00
|
|
|
/**
|
2019-03-13 22:08:20 +01:00
|
|
|
* Enable or disable an input devices
|
|
|
|
* @param indev pointer to an input device
|
|
|
|
* @param en true: enable; false: disable
|
2017-11-19 19:28:45 +01:00
|
|
|
*/
|
2019-03-13 22:08:20 +01:00
|
|
|
void lv_indev_enable(lv_indev_t * indev, bool en);
|
2017-11-19 19:28:45 +01:00
|
|
|
|
|
|
|
/**
|
2018-02-24 13:17:39 +01:00
|
|
|
* Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON)
|
|
|
|
* @param indev pointer to an input device
|
2017-10-10 16:17:23 +02:00
|
|
|
* @param cur_obj pointer to an object to be used as cursor
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj);
|
2017-10-10 16:17:23 +02:00
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_GROUP
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
2018-02-24 13:17:39 +01:00
|
|
|
* Set a destination group for a keypad input device (for LV_INDEV_TYPE_KEYPAD)
|
|
|
|
* @param indev pointer to an input device
|
2017-11-19 19:28:45 +01:00
|
|
|
* @param group point to a group
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group);
|
2017-11-21 14:52:23 +01:00
|
|
|
#endif
|
2018-02-24 13:17:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* @param indev pointer to an input device
|
|
|
|
* @param group point to a group
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t * points);
|
2018-02-24 13:17:39 +01:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
2018-02-24 13:17:39 +01:00
|
|
|
* Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON)
|
2017-11-19 19:28:45 +01:00
|
|
|
* @param indev pointer to an input device
|
|
|
|
* @param point pointer to a point to store the result
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point);
|
2018-02-24 13:17:39 +01:00
|
|
|
|
2018-08-09 07:30:10 +02:00
|
|
|
/**
|
2019-03-17 07:59:38 +01:00
|
|
|
* Get the last pressed key of an input device (for LV_INDEV_TYPE_KEYPAD)
|
2018-08-09 07:30:10 +02:00
|
|
|
* @param indev pointer to an input device
|
|
|
|
* @return the last pressed key (0 on error)
|
|
|
|
*/
|
|
|
|
uint32_t lv_indev_get_key(const lv_indev_t * indev);
|
|
|
|
|
2017-11-19 19:28:45 +01:00
|
|
|
/**
|
2019-04-04 07:15:40 +02:00
|
|
|
* Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and
|
|
|
|
* LV_INDEV_TYPE_BUTTON)
|
2017-11-19 19:28:45 +01:00
|
|
|
* @param indev pointer to an input device
|
2017-01-13 23:27:49 +01:00
|
|
|
* @return true: drag is in progress
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
bool lv_indev_is_dragging(const lv_indev_t * indev);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
2019-04-04 07:15:40 +02:00
|
|
|
* Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and
|
|
|
|
* LV_INDEV_TYPE_BUTTON)
|
2017-11-19 19:28:45 +01:00
|
|
|
* @param indev pointer to an input device
|
2017-01-13 23:27:49 +01:00
|
|
|
* @param point pointer to a point to store the vector
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point);
|
2017-12-11 10:59:33 +01:00
|
|
|
|
2019-09-19 14:58:07 +02:00
|
|
|
/**
|
|
|
|
* Manually finish dragging.
|
|
|
|
* `LV_SIGNAL_DRAG_END` and `LV_EVENT_DRAG_END` will be sent.
|
|
|
|
* @param indev pointer to an input device
|
|
|
|
* @return `LV_RES_INV` if the object being dragged was deleted. Else `LV_RES_OK`.
|
|
|
|
*/
|
|
|
|
lv_res_t lv_indev_finish_drag(lv_indev_t * indev);
|
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Do nothing until the next release
|
2017-11-19 19:28:45 +01:00
|
|
|
* @param indev pointer to an input device
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-11-19 19:28:45 +01:00
|
|
|
void lv_indev_wait_release(lv_indev_t * indev);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2019-04-02 12:15:35 +02:00
|
|
|
/**
|
|
|
|
* Get a pointer to the indev read task to
|
|
|
|
* modify its parameters with `lv_task_...` functions.
|
|
|
|
* @param indev pointer to an inout device
|
|
|
|
* @return pointer to the indev read refresher task. (NULL on error)
|
|
|
|
*/
|
|
|
|
lv_task_t * lv_indev_get_read_task(lv_disp_t * indev);
|
|
|
|
|
2019-05-19 10:56:34 -07:00
|
|
|
/**
|
2019-05-20 09:42:31 -07:00
|
|
|
* Gets a pointer to the currently active object in indev proc functions.
|
2019-05-19 10:56:34 -07:00
|
|
|
* NULL if no object is currently being handled or if groups aren't used.
|
2019-05-20 09:52:18 -07:00
|
|
|
* @return pointer to currently active object
|
2019-05-19 10:56:34 -07:00
|
|
|
*/
|
2019-06-06 06:05:40 +02:00
|
|
|
lv_obj_t * lv_indev_get_obj_act(void);
|
2019-05-19 10:56:34 -07:00
|
|
|
|
2019-12-09 04:21:56 +07:00
|
|
|
/**
|
|
|
|
* Search the most top, clickable object by a point
|
|
|
|
* @param obj pointer to a start object, typically the screen
|
|
|
|
* @param point pointer to a point for searhing the most top child
|
|
|
|
* @return pointer to the found object or NULL if there was no suitable object
|
|
|
|
*/
|
|
|
|
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t *point);
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
2016-12-17 12:02:30 +01:00
|
|
|
#endif
|
2017-07-09 15:32:49 +02:00
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_INDEV_H*/
|