@@ -42,12 +42,66 @@ static void lvgl_read_cb(lv_indev_t* indev, lv_indev_data_t* data)
4242 if (!touchpad_pressed)
4343 {
4444 data->state = LV_INDEV_STATE_REL;
45+ return ;
4546 }
46- else
47+
48+ lv_display_t * disp = lv_indev_get_display (indev);
49+ lv_display_rotation_t rotation = LV_DISPLAY_ROTATION_0;
50+ lv_coord_t raw_w = BSP_LCD_H_RES;
51+ lv_coord_t raw_h = BSP_LCD_V_RES;
52+ static bool logged_right_edge_ok = false ;
53+
54+ if (disp != nullptr )
55+ {
56+ rotation = lv_display_get_rotation (disp);
57+
58+ lv_coord_t phys_w = lv_display_get_physical_horizontal_resolution (disp);
59+ lv_coord_t phys_h = lv_display_get_physical_vertical_resolution (disp);
60+ if (phys_w > 0 )
61+ {
62+ raw_w = phys_w;
63+ }
64+ if (phys_h > 0 )
65+ {
66+ raw_h = phys_h;
67+ }
68+ }
69+
70+ lv_coord_t transformed_x = touch_x[0 ];
71+ lv_coord_t transformed_y = touch_y[0 ];
72+
73+ switch (rotation)
74+ {
75+ case LV_DISPLAY_ROTATION_90:
76+ transformed_x = touch_y[0 ];
77+ transformed_y = raw_w - 1 - touch_x[0 ];
78+ break ;
79+ case LV_DISPLAY_ROTATION_180:
80+ transformed_x = raw_w - 1 - touch_x[0 ];
81+ transformed_y = raw_h - 1 - touch_y[0 ];
82+ break ;
83+ case LV_DISPLAY_ROTATION_270:
84+ transformed_x = raw_h - 1 - touch_y[0 ];
85+ transformed_y = touch_x[0 ];
86+ break ;
87+ case LV_DISPLAY_ROTATION_0:
88+ default :
89+ break ;
90+ }
91+
92+ data->state = LV_INDEV_STATE_PR;
93+ data->point .x = transformed_x;
94+ data->point .y = transformed_y;
95+
96+ lv_coord_t right_edge_threshold = LV_MAX (raw_h - 5 , 0 );
97+ if (!logged_right_edge_ok && rotation == LV_DISPLAY_ROTATION_90
98+ && transformed_x >= right_edge_threshold)
4799 {
48- data->state = LV_INDEV_STATE_PR;
49- data->point .x = touch_x[0 ];
50- data->point .y = touch_y[0 ];
100+ mclog::tagInfo (_tag,
101+ " Touch rotation check: right edge press mapped to ({}, {})" ,
102+ static_cast <int >(transformed_x),
103+ static_cast <int >(transformed_y));
104+ logged_right_edge_ok = true ;
51105 }
52106}
53107
0 commit comments