Simulte touch event from Android kernel
I have developed a new touchscreen driver in android kernel. And my goal is to simulate a touchscreen event. Therefore, in the probe of my new driver, I highlight the necessary keys:
input_set_abs_params(in_dev, ABS_MT_TRACKING_ID, 10000, 0, 0); input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, 1000, 0, 0); input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0,1000, 0, 0); input_set_abs_params(in_dev, ABS_MT_TOUCH_MAJOR,0,1000,0, 0); input_set_abs_params(in_dev, ABS_MT_TOUCH_MINOR,0,1000,0, 0);
And in code I am trying to simulate a touchscreen event:
input_event(in_dev, EV_ABS, ABS_MT_TRACKING_ID, ++counter); input_event(in_dev, EV_KEY, BTN_TOUCH, 1); input_event(in_dev, EV_KEY, BTN_TOOL_FINGER, 1); input_event(in_dev, EV_ABS, ABS_MT_POSITION_X, 0x00000336); input_event(in_dev, EV_ABS, ABS_MT_POSITION_Y, 0x0000059a); input_event(in_dev, EV_ABS, ABS_MT_TOUCH_MAJOR, 7); input_event(in_dev, EV_ABS, ABS_MT_TOUCH_MINOR, 6); input_event(in_dev, EV_ABS, ABS_MT_TRACKING_ID, 0xffffffff); input_event(in_dev, EV_KEY, BTN_TOUCH, 0); input_event(in_dev, EV_KEY, BTN_TOOL_FINGER, 0);
Be aware that I can see almost all events in my shell with correct values (only BTN_TOUCH event, which I cannot see in the shell). And besides, I see a circle in the corner of the phone screen. But this circle does nothing. After a few seconds, it just disappears.
I will share your help. I feel like something is missing here ...
source to share
You should have corresponding layout files in files "/ system / usr / idc" and "/ system / usr / keylayout" that match your input device name (one in / sys / class / inputX / name). can take some of the existing ones as an example and just copy or look at the Google Pixel tree https://android.googlesource.com/device/google/marlin/+/o-preview
source to share