0010-weston-calibrate-touch-coordinate.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. Weston calibrate coordinate for touch event.
  2. Signed-off-by: Leo Lu <leo.lu@starfivetech.com>
  3. --- a/libweston/libinput-device.c 2023-08-29 09:50:15.351292430 +0800
  4. +++ b/libweston/libinput-device.c 2023-08-29 16:50:45.075771603 +0800
  5. @@ -445,25 +445,32 @@ handle_touch_with_coords(struct libinput
  6. double x;
  7. double y;
  8. struct weston_point2d_device_normalized norm;
  9. - uint32_t width, height;
  10. struct timespec time;
  11. int32_t slot;
  12. + struct weston_output *primary = NULL;
  13. if (!device->output)
  14. return;
  15. -
  16. +
  17. + primary = wl_container_of(device->output->compositor->output_list.next,
  18. + primary,link);
  19. + if (!primary)
  20. + return;
  21. +
  22. timespec_from_usec(&time,
  23. libinput_event_touch_get_time_usec(touch_event));
  24. slot = libinput_event_touch_get_seat_slot(touch_event);
  25. - width = device->output->current_mode->width;
  26. - height = device->output->current_mode->height;
  27. - x = libinput_event_touch_get_x_transformed(touch_event, width);
  28. - y = libinput_event_touch_get_y_transformed(touch_event, height);
  29. + x = libinput_event_touch_get_x(touch_event);
  30. + y = libinput_event_touch_get_y(touch_event);
  31. - weston_output_transform_coordinate(device->output,
  32. - x, y, &x, &y);
  33. + if (!strncmp(primary->name, "HDMI", strlen("HDMI")))
  34. + x += primary->width;
  35. +
  36. + weston_output_transform_coordinate(primary,
  37. + x, y, &x, &y);
  38. +
  39. if (weston_touch_device_can_calibrate(device->touch_device)) {
  40. norm.x = libinput_event_touch_get_x_transformed(touch_event, 1);
  41. norm.y = libinput_event_touch_get_y_transformed(touch_event, 1);
  42. @@ -472,6 +479,8 @@ handle_touch_with_coords(struct libinput
  43. } else {
  44. notify_touch(device->touch_device, &time, slot, x, y, touch_type);
  45. }
  46. +
  47. +
  48. }
  49. static void