Button events are not working in fbdev(display)


I am unable to use button events in fbdev.

i wrote some sample code with buttons and created events.

and when i executes it on board the button events are not working.

is there any solution?


Please fill the template to provide enough information to investigate your issue. You can copy it into a new post and add your information within.

> ## Important: posts that do not use this template will be ignored or closed.
> ## Before posting
> - Get familiar with [Markdown](https://forum.lvgl.io/t/get-familiar-with-markdown/403) to format and structure your post
> - Be sure to update [lvgl](https://github.com/littlevgl/lvgl) from the latest version from the `master` branch.
> - Be sure you have checked the relevant part of the [documentation](https://docs.littlevgl.com/en/html/index.html). **We will not respond in detail to posts where you haven't read the relevant documentation.**
> - If applicable use the [Simulator](https://docs.littlevgl.com/en/html/get-started/pc-simulator.html) to eliminate hardware related issues.
>  *Delete this section if you read and applied the mentioned points.*
## Description

###  What MCU/Processor/Board and compiler are you using?

###  What do you want to achieve?

### What have you tried so far?

## Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:
/*You code here*/


Button Events are not working in fbdev (Display).

What MCU/Processor/Board and compiler are you using?

What do you want to achieve?

  1. How to Work with button events in fbdev?

What have you tried so far?

Again, you still haven’t provided a clear description of what isn’t working. “Not working” is not enough information on its own for us to help you.

Please describe exactly what the problem is, the exact steps you’ve tried, and any debugging steps you’ve taken.


I created a button and added an even handler to it (navigate to other screen when it is clicked)
it worked for me on PC Simulator. But same code i used in fbdev for my board. it showing button on my board but when i click on it, nothing is happen.

What MCU/Processor/Board and compiler are you using?

i am using gcc linaro arm linux gnueabihf compiler.

What do you want to achieve?

  1. How to work with this event handler on board?

What have you tried so far?

i tried below code in my main.c file
lv_indev_drv_t indev_drv;
indev_drv.type = LV_INDEV_TYPE_BUTTON;
indev_drv.read_cb =button_read;
lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);

Sample Code i am running on my board:

lv_obj_t * label;
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_event_cb(btn1, event_handler);
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);

label = lv_label_create(btn1, NULL);
lv_label_set_text(label, "Button");

static void event_handler(lv_obj_t * obj, lv_event_t event)
if(event == LV_EVENT_CLICKED) {
// printf(“Clicked\n”);
else if(event == LV_EVENT_VALUE_CHANGED) {

Do you have a physical hardware button, or are you using a touchscreen? If it’s the latter you should be registering an LV_INDEV_TYPE_POINTER device instead. See the documentation.

You mentioned that you are using the fbdev driver, so I assume this is a Linux system. Does your input device use the standard Linux evdev interface? We have a driver for that already.

i am using touch screen(linux).
I just used evdev.h file in my main.c and used evdev_init();
But this evdev_init() is not getting into the main.c file.
lv_init(); and fbdev_init(); are working.

main.c file

#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#include "lv_examples/lv_apps/test/test.h"
#include <unistd.h>

#define DISP_BUF_SIZE (480*854)

int main(void)
	/*LittlevGL init*/

	/*Linux frame buffer device init*/

	/*Linux touchscreen device init*/

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

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

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

	/*Initialize and register an input device*/
	lv_indev_drv_t indev_drv;
	indev_drv.type = LV_INDEV_TYPE_POINTER;
	indev_drv.read_cb = evdev_read;
	lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);


	/*Handle LitlevGL tasks (tickless mode)*/
	while(1) {

	return 0;

Getting implicit declaration of function warning.


Did you enable the evdev driver in lv_drv_conf.h?

Yes I Enabled evdev driver in lv_drv_conf.h (0 to 1)

and included them in my main.c file.
still got error at indev_drv.read_cb=evdev_read(evdev_read could not be resolved)
but the code compiled without any errors.
when i run on board it showing unable open evdev interface::No such file or directory

The issue solved for me.

Thanks for your help.

Continuing the discussion from Button events are not working in fbdev(display):

would you please share how do you solved it?
I have met same issue, when I am run ./demo.

Thanks & Best Regards

Ironically, I am also stuck on the same issue and have followed the details of this thread very closely to troubleshoot - still not able to get the button with touchscreen using Linux frame buffer to work. I am clearly overlooking something.

Any suggestions or insights on how this was solved would be greatly appreciated!

  • Ti

Just wanted to clarify, shouldn’t both the lv_example_get_started_1 and lv_example_event_1 work out of the box assuming lv_dr_conf.h and lv_conf.h are configured correctly? Or am I supposed to write some glue code for these examples - sorry, but it’s not clear to me. I am a student and still learning!

Both examples above compile cleanly and display correctly but neither mouse nor touch will respond even though both are set to ‘1’ in lv_dr_conf.h.