Simulte touch event from android kernel

3

I develop a new touch screen driver in the android kernel. And my goal it to simulate a touch screen event. Therefore, in the probe of my new driver, I allocate the required 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 the code I try to simulate a touch screen 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);

Know I can see almost all the events in my shell with the correct values(only the BTN_TOUCH event that I can't see at the shell). And in addition I see a circle at the corner of the phone screen. But this circle doesn't do anything. It is just disappear after some seconds.

I will appricate your help. I feel like I am missing some thing here...

android
c
linux-kernel
android-kernel
asked on Stack Overflow May 4, 2017 by Kram

1 Answer

0

You need to have the corresponding layout files in "/system/usr/idc" and "/system/usr/keylayout" which match your input device name (the one in /sys/class/inputX/name". You can take some existing one from there as an example and just copy or have a look at Google Pixel tree https://android.googlesource.com/device/google/marlin/+/o-preview

answered on Stack Overflow Jun 20, 2017 by alexst

User contributions licensed under CC BY-SA 3.0