Touch doesn't trigger events

Description

I’m trying to implement LVGL 9.2.2 on a Waveshare ESP32-S3-Touch-LCD-2 with Arduino IDE. I got the GUI working and already tried multiple widgets. The lv_indev_set_read_cb is working as well. I added a Serial print on the callback an get a reaonable position, when I touch the display.
But none of the LVGL widgets are responding to touch.

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

Waveshare ESP32-S3-Touch-LCD-2 with Arduino IDE

What do you want to achieve?

Have the widgets respond to touch events

What have you tried so far?

I followed the examples for Input Devices and tried to implement Tabview example 2.
When that didn’t work directly, I removed additional widgets and styles until I was only using the tabview widget, in case there was some interference.
I tried to add an LV_EVENT_VALUE_CHANGED event to the tabview, but that wasn’t fired either.

Then I tried a button by using one of the getting started examples. No click event was fired.

I also checked the coordinates, the touchscreen is reporting, and they are matching the coordinates LVGL uses.

The only thing that got me anything was attaching a LV_EVENT_CLICKED to the active screen.

Code to reproduce

void init() {
  /* ... */
  indev = lv_indev_create();
  lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER); 
  lv_indev_set_read_cb(indev, touchpad_read);
  /* ... */
}

void createTabview() {
  tabview = lv_tabview_create(lv_screen_active());
  lv_tabview_set_tab_bar_position(tabview, LV_DIR_LEFT);
  lv_obj_set_size(tabview, 315, 215);
  lv_tabview_set_tab_bar_size(tabview, 40);
  lv_obj_set_style_margin_left(tabview, 5, 0);
  lv_obj_set_style_bg_color(tabview, lv_color_hex(palette[0]), 0);

  // create tabs
  lv_obj_t * tabIMU = lv_tabview_add_tab(tabview, "IMU");
  lv_obj_t * tabGPS = lv_tabview_add_tab(tabview, "GPS");
  lv_obj_t * tabRAD = lv_tabview_add_tab(tabview, "RAD");

  lv_obj_add_event_cb(tabview, TR590_DisplayGeo::onTabviewChanged, LV_EVENT_VALUE_CHANGED, NULL);

  lv_obj_t * tab_buttons = lv_tabview_get_tab_bar(tabview);

  lv_obj_t* button;
  lv_obj_t* buttonLabel;
  uint8_t i;

  // change button styles
  for (i = 0; i < 3; i++) {
	  button = lv_obj_get_child(tab_buttons, i);
	  lv_obj_set_style_bg_opa(button, LV_OPA_COVER, LV_PART_MAIN);
	  lv_obj_set_style_bg_color(button, lv_color_hex(palette[19]), LV_PART_MAIN);
	  lv_obj_set_style_text_color(button, lv_color_hex(palette[0]), LV_PART_MAIN);
	  lv_obj_set_style_bg_opa(button, LV_OPA_COVER, LV_PART_MAIN | LV_STATE_CHECKED);
	  lv_obj_set_style_bg_color(button, lv_color_hex(palette[4]), LV_PART_MAIN | LV_STATE_CHECKED);
	  lv_obj_set_style_text_color(button, lv_color_hex(palette[0]), LV_PART_MAIN | LV_STATE_CHECKED);
	  lv_obj_set_style_border_width(button, 0, LV_PART_MAIN);
	  buttonLabel = lv_obj_get_child(button, 0);
	  lv_obj_set_align(buttonLabel, LV_ALIGN_TOP_RIGHT);
  }

  drawIMU(tabIMU);
  drawGPS(tabGPS);
  drawRAD(tabRAD);

  lv_obj_remove_flag(lv_tabview_get_content(tabview), LV_OBJ_FLAG_SCROLLABLE);
}

void drawIMU(lv_obj_t * tab) { // drawGPS and drawRAD are basically the same
	lv_obj_t * label = lv_label_create(tab);
	lv_label_set_text(label, "IMU");
}

void touchpad_read( lv_indev_t * indev, lv_indev_data_t * data ) {
  int x, y;
  bool touched = handleTouch(x, y); // provided by the touchscreen driver

  if(!touched) {
      data->state = LV_INDEV_STATE_RELEASED;
  } else {
      data->state = LV_INDEV_STATE_PRESSED;

      data->point.x = x;
      data->point.y = 240 - y;

      Serial.print("Touch: (");
      Serial.print(data->point.x);
      Serial.print(", ");
      Serial.print(data->point.y);
      Serial.println(")");
  }
}

I’m not sure what I’m doing wrong here or if I missed something. Any help would be appreciated.

I figured it out myself.

After a little bit more research and finding the issue https://github.com/lvgl/lvgl/issues/7841, I tried removing the rotation on my display. I got a button to work with it. Then I retried the tabview and it worked as well. Nice.

I reapplied the rotation and tried again and the tabview again didn’t work.
I then modifyed the coordinates reported by the touchscreen. Turns out I have to swap x and y as well as inverting the values.

data->point.x = 240 - y;
data->point.y = 320 - x;

But now it’s working as intended