I'm about to give up / Touchscreen

Hi there,

My simple goal - “Button and action”. :smile:

This is my code:

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


void btn_event_cb(lv_obj_t * btn, lv_event_t event)
    if(event == LV_EVENT_CLICKED) {

int main(void)



    static lv_color_t buf[DISP_BUF_SIZE];

    static lv_disp_buf_t disp_buf;
    lv_disp_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);

    lv_disp_drv_t disp_drv;
    disp_drv.buffer = &disp_buf;
    disp_drv.flush_cb = fbdev_flush;

    lv_indev_drv_t indev_drv;
    indev_drv.type = LV_INDEV_TYPE_POINTER;
    indev_drv.read_cb = evdev_read;
    lv_indev_drv_register(&indev_drv);    /*Add a display the LittlevGL sing the frame buffer driver*/

    lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);     
    lv_obj_set_pos(btn, 10, 10);                            
    lv_obj_set_size(btn, 300, 200);                          
    lv_obj_set_event_cb(btn, btn_event_cb);               
    lv_obj_t * label = lv_label_create(btn, NULL);       
    lv_label_set_text(label, "Button");                 

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

    return 0;

I’m using a Raspberry with an attached touchscreen. Evtest shows everything is fine with /dev/input/event1.


#define LV_HOR_RES_MAX (800)
#define LV_VER_RES_MAX (480)
#define LV_COLOR_DEPTH 32


#define USE_EVDEV 1
#LIBINPUT_NAME “/dev/input/event1”
#define USE_FBDEV 1
#define FBDEV_PATH “/dev/fb0”

Screen is working fine as expected but I don’t get any feedback from my button. I’m sure it must be a silly mistake…

Any ideas?

Thank you very much in advance.

I haven’t gotten my touchscreen working yet as I am still waiting for some driver work to be done, but I have simulated with a mouse. Have you run evtest to ensure you see the touch events?

I referenced this post when I was bringing up the mouse.

Hi Tarvik,

thank you for your quick reply. Evtest runs without any problems. I’ll try it with mouse as input. Good idea!

(Sorry for my bad formatted code in first post - I don’t know how to correct it)

I’m still learning the formatting myself… I reference the link found in here a lot.

edit Ugh, sorry, I missed out in your original post where you already stated that you’d run evtest successfully. My brain still hasn’t started this morning… :slight_smile:

Thanks a lot! (And you missed nothing :wink: - I deleted this information while fighting with the formatting)

What is the evdev_read code?

Is there a reason why you are using the option for LIBINPUT when you are using the evdev driver?