/**
 * @file lv_port_indev_templ.c
 *
 */

 /*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/
#if 1

#ifdef __cplusplus
extern "C" {
#endif

/*********************
 *      INCLUDES
 *********************/
#include "lv_port_indev.h"
#include "stdbool.h"
///#include "key.h"
#if USE_BSD_EVDEV
#include <dev/evdev/input.h>
#else
#include <linux/input.h>
#endif
#include "lv_conf.h"
#include "lvgl/lvgl.h"
#include <stdio.h>

lv_group_t 			*g_pLv_group_key = NULL;
static lv_indev_t	*pIndev_keypad;

/*******************************************************************************
* @author	:Winston
* @function	:key port
* @input	:
* @output	:
*******************************************************************************/
void lv_port_indev_group_set(lv_group_t *pGroup)
{
	if(pIndev_keypad != NULL && pGroup!= NULL){
		lv_indev_set_group(pIndev_keypad, pGroup);
	}
  	 
}
/*******************************************************************************
* @author	:Winston
* @function	:key port
* @input	:
* @output	:
*******************************************************************************/
void lv_port_indev_init(void)
{
    lv_indev_drv_t 	indev_drv;
    	
	/*Register a keypad input device*/
	lv_indev_drv_init(&indev_drv);
	indev_drv.type = LV_INDEV_TYPE_KEYPAD; 
	indev_drv.read_cb = evdev_read; 
	pIndev_keypad = lv_indev_drv_register(&indev_drv);

	/* Later you should create group(s) with `lv_group_t * group = lv_group_create()`,
	* add objects to the group with `lv_group_add_obj(group, obj)`
	* and assign this input device to group to navigate in it:
	* `lv_indev_set_group(indev_keypad, group);` */
  	g_pLv_group_key = lv_group_create();
  	printf("pIndev_keypad=%d, g_pLv_group_key=%d\n", (int)pIndev_keypad, (int)g_pLv_group_key);
	lv_port_indev_group_set(g_pLv_group_key);
}

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
