Evdev mouse not working

I have a slight problem with the mouse after updating to v6 of littlevgl. I used the /dev/input/mice before and in v6 the support for that is gone. How do I use the mouse via /dev/input/event1 in my case.

I do not want to use SDL!

The defines USE_EVDEV and EVDEV_NAME “/dev/input/event1” are used.

Not really sure, but something seems to be wrong here. The mouse is showing up but its not moving at all.
When using evtest the output is the following:


Here is the main that I am experimenting with:

#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include "lv_drivers/indev/evdev.h"
#include "MasterSurface.h"


#define DISP_BUF_SIZE (80*LV_HOR_RES_MAX)
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/


int main(void) {
	/*LittlevGL init*/
	lv_init();

	/*Linux frame buffer device init*/
	fbdev_init();

	/*A small buffer for LittlevGL to draw the screen's content*/
	static lv_color_t buf[DISP_BUF_SIZE];

	/*Initialize a descriptor for the buffer*/
	static lv_disp_buf_t disp_buf;
	lv_disp_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);

	/*Initialize and register a display driver*/
	lv_disp_drv_t disp_drv;
	lv_disp_drv_init(&disp_drv);
	disp_drv.buffer = &disp_buf;
	disp_drv.flush_cb = fbdev_flush;
	lv_disp_drv_register(&disp_drv);

	// enable event input
	evdev_init();

	// get mouse as an input
	lv_indev_drv_t indev_drv;
	lv_indev_drv_init(&indev_drv);
	indev_drv.type = LV_INDEV_TYPE_POINTER;
	indev_drv.read_cb = evdev_read;
	
	lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);

	lv_obj_t * cursor_obj = lv_img_create(lv_scr_act(), NULL); //Create an image for the cursor
	lv_img_set_src(cursor_obj, &mouse_cursor_icon); //For simlicity add a built in symbol not an image
	lv_indev_set_cursor(mouse_indev, cursor_obj); // connect the object to the driver

	//inits surface
	lv_master_surface_init();
	
	/*Handle LitlevGL tasks (tickless mode)*/
	while (1) {
		lv_task_handler();
		usleep(5000);
	}

	return 0;
}

Are you using Ubuntu? The output of your evtest appears to be different than what I would expect.

Mine does this (with my mouse):

Event: time 1567033530.102580, -------------- SYN_REPORT ------------
Event: time 1567033530.110621, type 2 (EV_REL), code 0 (REL_X), value 3
Event: time 1567033530.110621, type 2 (EV_REL), code 1 (REL_Y), value -1
Event: time 1567033530.110621, -------------- SYN_REPORT ------------
Event: time 1567033530.118624, type 2 (EV_REL), code 0 (REL_X), value 3
Event: time 1567033530.118624, type 2 (EV_REL), code 1 (REL_Y), value -2
Event: time 1567033530.118624, -------------- SYN_REPORT ------------
Event: time 1567033530.126624, type 2 (EV_REL), code 0 (REL_X), value 3
Event: time 1567033530.126624, type 2 (EV_REL), code 1 (REL_Y), value -1

Note that it is showing EV_REL and REL_X, and it is actually showing the event type (whereas yours is skipping that information).

Dear all,

I’m really sorry for digging out that old thread after one year, but I’m experiencing exactly the same issue. I’m currently testing the Linux framebuffer version of LVGL on a Raspberry Pi with XPT2046, mapped as an evdev device. I get the same behaviour as @Light0815, so evtest works, but does not return “EV_REL” (relative position), but “EV_ABS” (absolute position) events… Nevertheless, according to a simple “printf” test, it looks like the “evdev_read” function is actually never called…
Does anyone have an idea how to solve that?

Are you initializing and registering the driver correctly? Could you show the code where you call lv_indev_drv_register?

Also, make sure the correct device is selected in lv_drv_conf.h.