Rotate touch input

Which system do you use? Android, Ubuntu, OOWOW or others?

Android 11

Which version of system do you use? Please provide the version of the system here:

Self-built image using official guide

Please describe your issue below:

The main goal is to rotate screen in our custom android image. In system/core/init/property_service.cpp I changed some properties and screen became rotated, but touch input not

    } else if (strstr(buf,"khadas_mipi_id=2") != NULL) {
        InitPropertySet("sys.lcd.reverse", "2");
        InitPropertySet("persist.vendor.hwc.lcdpath", "0");
		InitPropertySet("ro.minui.default_rotation", "ROTATION_DOWN");
		InitPropertySet("ro.vendor.sf.rotation", "180");
		InitPropertySet("ro.surface_flinger.primary_display_orientation", "ORIENTATION_180");
		InitPropertySet("ro.surface_flinger.max_graphics_width", "3840");//1920*2
		InitPropertySet("ro.surface_flinger.max_graphics_height", "2400");//1200*2
        LOG(INFO) << "switch TS101 LCD!";

How can I change touch input orientation? Or you can suggest more optimal way for my problem.

Hello @mkovalevski

@william.lin will help you then.

@mkovalevski Are you using USB touch? If so, please refer to the link below.

@numbqq @goenjoy Thank you for your feedback. I have solved the problem by changing GTP_X_REVERSE_ENABLE and GTP_Y_REVERSE_ENABLE from 1 (1 is default) to 0 in gt9xx.h file, which is i2c touch driver for ts101 panel.

gt9xx.c file:

static void gtp_touch_down(struct goodix_ts_data* ts,s32 id,s32 x,s32 y,s32 w)
{
// THIS PART SWAPS X AND Y
#if GTP_CHANGE_X2Y
		GTP_SWAP(x, y);
#endif
// TURN OFF REVERSE AND ROTATION WILL BE EXECUTED
#if GTP_X_REVERSE_ENABLE 
		x = ts->abs_x_max - x;
#endif

#if GTP_Y_REVERSE_ENABLE 
		y = ts->abs_y_max - y;
#endif

#if GTP_ICS_SLOT_REPORT


    input_mt_slot(ts->input_dev, id);
    input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, id);
	if(id==9){
		input_mt_report_slot_state(ts->input_dev,MT_TOOL_PEN,true);
	}else{
		input_mt_report_slot_state(ts->input_dev,MT_TOOL_FINGER,true);
	}
	input_report_abs(ts->input_dev, ABS_MT_PRESSURE, w);
	
	if (2 == rotation) {
		input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x);
		input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, ts->abs_y_max-y);
    }else if (3 == rotation) {
		input_report_abs(ts->input_dev, ABS_MT_POSITION_X, ts->abs_x_max-x);
		input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, ts->abs_y_max-y);
	}else{
		input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x);
		input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y);
	}
    input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w);
    input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);
}

Also i have changed property_service.cpp where ro.surface_flinger.primary_display_orientation was only changed

else if (strstr(buf,"khadas_mipi_id=2") != NULL) {
        InitPropertySet("sys.lcd.reverse", "2");
        InitPropertySet("persist.vendor.hwc.lcdpath", "0");
		InitPropertySet("ro.minui.default_rotation", "ROTATION_NONE");
		InitPropertySet("ro.vendor.sf.rotation", "0");
		InitPropertySet("ro.surface_flinger.primary_display_orientation", "ORIENTATION_180");
		InitPropertySet("ro.surface_flinger.max_graphics_width", "3840");//1920*2
		InitPropertySet("ro.surface_flinger.max_graphics_height", "2400");//1200*2
        LOG(INFO) << "switch TS101 LCD!";
    }else {

Hope it will help somebody in future!

2 Likes