2017-10-18 14:09:10 +02:00
/**
2019-02-10 11:06:47 +01:00
* @ file lv_hal_indev . h
2017-10-18 14:09:10 +02:00
*
* @ description Input Device HAL interface layer header file
2018-06-19 09:49:58 +02:00
*
2017-10-18 14:09:10 +02:00
*/
2019-02-10 11:06:47 +01:00
# ifndef LV_HAL_INDEV_H
# define LV_HAL_INDEV_H
2017-10-18 14:09:10 +02:00
# ifdef __cplusplus
extern " C " {
# endif
/*********************
* INCLUDES
* * * * * * * * * * * * * * * * * * * * */
2019-02-20 23:58:13 +01:00
# ifdef LV_CONF_INCLUDE_SIMPLE
# include "lv_conf.h"
# else
# include "../../lv_conf.h"
# endif
2017-10-18 14:09:10 +02:00
# include <stdbool.h>
# include <stdint.h>
2017-11-23 20:42:14 +01:00
# include "../lv_misc/lv_area.h"
2017-10-18 14:09:10 +02:00
/*********************
* DEFINES
* * * * * * * * * * * * * * * * * * * * */
/**********************
* TYPEDEFS
* * * * * * * * * * * * * * * * * * * * * */
2019-02-24 21:20:51 +01:00
struct _lv_obj_t ;
2019-02-12 12:21:34 +01:00
struct _disp_t ;
2019-02-20 23:58:13 +01:00
struct _lv_indev_t ;
2019-02-24 21:20:51 +01:00
struct _lv_indev_drv_t ;
2019-02-12 12:21:34 +01:00
2017-10-18 14:09:10 +02:00
/*Possible input device types*/
2018-09-18 13:59:40 +02:00
enum {
2017-11-27 09:38:10 +01:00
LV_INDEV_TYPE_NONE , /*Show uninitialized state*/
2017-11-29 13:08:03 +01:00
LV_INDEV_TYPE_POINTER , /*Touch pad, mouse, external button*/
2017-10-20 22:11:18 +02:00
LV_INDEV_TYPE_KEYPAD , /*Keypad or keyboard*/
2018-02-24 13:17:39 +01:00
LV_INDEV_TYPE_BUTTON , /*External (hardware button) which is assinged to a specific point of the screen*/
2018-09-24 22:59:48 +02:00
LV_INDEV_TYPE_ENCODER , /*Encoder with only Left, Right turn and a Button*/
2018-09-18 13:59:40 +02:00
} ;
typedef uint8_t lv_hal_indev_type_t ;
2017-10-18 14:09:10 +02:00
2017-11-19 19:28:45 +01:00
/*States for input devices*/
2018-09-18 13:59:40 +02:00
enum {
2018-02-24 13:17:39 +01:00
LV_INDEV_STATE_REL = 0 ,
2017-11-29 13:08:03 +01:00
LV_INDEV_STATE_PR
2018-09-18 13:59:40 +02:00
} ;
typedef uint8_t lv_indev_state_t ;
2017-10-18 14:09:10 +02:00
2017-11-19 19:28:45 +01:00
/*Data type when an input device is read */
2017-10-18 14:09:10 +02:00
typedef struct {
2019-02-28 13:05:47 +01:00
lv_point_t point ; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/
uint32_t key ; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/
uint32_t btn_id ; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/
int16_t enc_diff ; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/
2019-02-20 23:58:13 +01:00
2018-09-18 13:59:40 +02:00
lv_indev_state_t state ; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/
2019-02-20 23:58:13 +01:00
2018-06-19 09:49:58 +02:00
} lv_indev_data_t ;
2017-10-18 14:09:10 +02:00
2017-11-19 19:28:45 +01:00
/*Initialized by the user and registered by 'lv_indev_add()'*/
2019-02-24 21:20:51 +01:00
typedef struct _lv_indev_drv_t {
lv_hal_indev_type_t type ; /*Input device type*/
bool ( * read_cb ) ( struct _lv_indev_drv_t * indev_drv , lv_indev_data_t * data ) ; /*Function pointer to read_cb data. Return 'true' if there is still data to be read_cb (buffered)*/
2019-02-25 07:06:05 +01:00
2019-03-07 00:05:16 +01:00
# if LV_USE_USER_DATA_MULTI
2019-02-25 06:50:20 +01:00
lv_indev_drv_user_data_t read_user_data ; /*Pointer to user defined data, passed in 'lv_indev_data_t' on read*/
2019-02-25 07:06:05 +01:00
# endif
2019-03-07 00:05:16 +01:00
# if LV_USE_USER_DATA_SINGLE
2019-02-25 07:06:05 +01:00
lv_indev_drv_user_data_t user_data ;
# endif
2019-02-24 21:20:51 +01:00
struct _disp_t * disp ; /*Pointer to the assigned display*/
2018-06-19 09:49:58 +02:00
} lv_indev_drv_t ;
2017-10-18 14:09:10 +02:00
2018-02-24 13:17:39 +01:00
/*Run time data of input devices*/
typedef struct _lv_indev_proc_t {
2017-12-11 12:53:58 +01:00
lv_indev_state_t state ;
2017-11-19 19:28:45 +01:00
union {
2018-02-24 13:17:39 +01:00
struct { /*Pointer and button data*/
2017-11-23 21:28:36 +01:00
lv_point_t act_point ;
lv_point_t last_point ;
lv_point_t vect ;
2018-06-19 09:49:58 +02:00
lv_point_t drag_sum ; /*Count the dragged pixels to check LV_INDEV_DRAG_LIMIT*/
2019-02-27 06:04:30 +01:00
lv_point_t drag_throw_vect ;
2019-03-03 11:20:49 +01:00
struct _lv_obj_t * act_obj ; /*The object being pressed*/
struct _lv_obj_t * last_obj ; /*The last obejct which was pressed (used by dragthrow and other post-release event)*/
struct _lv_obj_t * last_pressed ; /*The lastly pressed object*/
2017-11-19 19:28:45 +01:00
/*Flags*/
2019-02-26 16:07:40 +01:00
uint8_t drag_limit_out : 1 ;
2017-11-19 19:28:45 +01:00
uint8_t drag_in_prog : 1 ;
2019-03-08 14:11:13 +01:00
uint8_t wait_until_release : 1 ;
2019-02-26 19:46:37 +01:00
} pointer ;
2017-11-29 13:08:03 +01:00
struct { /*Keypad data*/
lv_indev_state_t last_state ;
2018-02-24 14:39:15 +01:00
uint32_t last_key ;
2019-02-26 19:46:37 +01:00
} keypad ;
} types ;
2017-11-19 19:28:45 +01:00
2017-11-16 10:20:30 +01:00
uint32_t pr_timestamp ; /*Pressed time stamp*/
uint32_t longpr_rep_timestamp ; /*Long press repeat time stamp*/
2017-10-18 14:09:10 +02:00
/*Flags*/
2017-11-16 10:20:30 +01:00
uint8_t long_pr_sent : 1 ;
2017-10-20 22:11:18 +02:00
uint8_t reset_query : 1 ;
uint8_t disabled : 1 ;
2018-06-19 09:49:58 +02:00
} lv_indev_proc_t ;
2017-10-18 14:09:10 +02:00
2019-02-10 11:06:47 +01:00
typedef void ( * lv_indev_feedback_t ) ( struct _lv_indev_t * , uint8_t ) ;
2017-10-18 14:09:10 +02:00
2017-11-19 19:28:45 +01:00
struct _lv_obj_t ;
struct _lv_group_t ;
2018-02-24 13:17:39 +01:00
/*The main input device descriptor with driver, runtime data ('proc') and some additional information*/
2017-10-18 14:09:10 +02:00
typedef struct _lv_indev_t {
2017-10-20 22:11:18 +02:00
lv_indev_drv_t driver ;
2017-11-29 13:08:03 +01:00
lv_indev_proc_t proc ;
2018-12-16 20:16:48 -05:00
lv_indev_feedback_t feedback ;
2017-12-11 12:53:58 +01:00
uint32_t last_activity_time ;
2019-03-07 00:05:16 +01:00
struct _lv_obj_t * cursor ; /*Cursor for LV_INPUT_TYPE_POINTER*/
struct _lv_group_t * group ; /*Keypad destination group*/
const lv_point_t * btn_points ; /*Array points assigned to the button ()screen will be pressed here by the buttons*/
2017-10-18 14:09:10 +02:00
} lv_indev_t ;
/**********************
* GLOBAL PROTOTYPES
* * * * * * * * * * * * * * * * * * * * * */
2017-11-27 09:38:10 +01:00
/**
* Initialize an input device driver with default values .
* It is used to surly have known values in the fields ant not memory junk .
* After it you can set the fields .
* @ param driver pointer to driver variable to initialize
*/
void lv_indev_drv_init ( lv_indev_drv_t * driver ) ;
2017-10-18 14:09:10 +02:00
/**
2017-10-20 22:41:10 +02:00
* Register an initialized input device driver .
* @ param driver pointer to an initialized ' lv_indev_drv_t ' variable ( can be local variable )
* @ return pointer to the new input device or NULL on error
2017-10-18 14:09:10 +02:00
*/
2017-11-29 16:28:20 +01:00
lv_indev_t * lv_indev_drv_register ( lv_indev_drv_t * driver ) ;
2017-10-18 14:09:10 +02:00
/**
* Get the next input device .
* @ param indev pointer to the current input device . NULL to initialize .
2019-02-10 11:06:47 +01:00
* @ return the next input devise or NULL if no more . Give the first input device when the parameter is NULL
2017-10-18 14:09:10 +02:00
*/
lv_indev_t * lv_indev_next ( lv_indev_t * indev ) ;
2017-10-20 22:41:10 +02:00
/**
* Read data from an input device .
* @ param indev pointer to an input device
* @ param data input device will write its data here
* @ return false : no more data ; true : there more data to read ( buffered )
*/
bool lv_indev_read ( lv_indev_t * indev , lv_indev_data_t * data ) ;
2017-10-18 14:09:10 +02:00
/**********************
* MACROS
* * * * * * * * * * * * * * * * * * * * * */
# ifdef __cplusplus
} /* extern "C" */
# endif
# endif