use /dev/uinput to simulate touch event in Android don't work
<p>I try to use /dev/uinput to simulate touch event in Android, some code like this:</p>

<p>first open "/dev/uinput" file, and create an udev:</p>

<pre><code>static int open_uinput_device(){
uinp_fd = open(uinput_deivce_path, O_WRONLY | O_NDELAY);
if (uinp_fd &lt;= 0) {
    debug("could not open %s, %s", uinput_deivce_path, strerror(errno));
    return -1;
}

memset(&amp;ui_dev, 0, sizeof(ui_dev));
strncpy(ui_dev.name, "RemoteTV Event", UINPUT_MAX_NAME_SIZE);
ui_dev.id.bustype = BUS_USB;
ui_dev.id.vendor = 0x1341;
ui_dev.id.product = 0x0001;
ui_dev.id.version = 4;

ui_dev.absmin[ABS_MT_SLOT] = 0;
ui_dev.absmax[ABS_MT_SLOT] = 9;
ui_dev.absmin[ABS_MT_TOUCH_MAJOR] = 0;
ui_dev.absmax[ABS_MT_TOUCH_MAJOR] = 255;
ui_dev.absmin[ABS_MT_POSITION_X] = 0;
ui_dev.absmax[ABS_MT_POSITION_X] = screen_width - 1;
ui_dev.absmin[ABS_MT_POSITION_Y] = 0;
ui_dev.absmax[ABS_MT_POSITION_Y] = screen_Height - 1;
ui_dev.absmin[ABS_MT_TRACKING_ID] = 0;
ui_dev.absmax[ABS_MT_TRACKING_ID] = 65535;
ui_dev.absmin[ABS_MT_PRESSURE] = 0;
ui_dev.absmax[ABS_MT_PRESSURE] = 30;
ui_dev.absmin[ABS_MT_TOOL_TYPE] = 0;
ui_dev.absmax[ABS_MT_TOOL_TYPE] = 1;

//enable direct
ioctl(uinp_fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT);
//enable mouse event
ioctl(uinp_fd, UI_SET_EVBIT, EV_REL);
ioctl(uinp_fd, UI_SET_RELBIT, REL_X);
ioctl(uinp_fd, UI_SET_RELBIT, REL_Y);
//enable touch event
ioctl(uinp_fd, UI_SET_EVBIT, EV_ABS);
for (i = 0; i &lt;= ABS_CNT; i++) {
    ioctl(uinp_fd, UI_SET_ABSBIT, i);
}

ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
for (i = 0; i &lt; 256; i++) {
    ioctl(uinp_fd, UI_SET_KEYBIT, i);
}
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_MOUSE);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_TOUCH);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_MOUSE);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_LEFT);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_MIDDLE);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_RIGHT);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_FORWARD);
ioctl(uinp_fd, UI_SET_KEYBIT, BTN_BACK);

write(uinp_fd, &amp;ui_dev, sizeof(ui_dev));
if (ioctl(uinp_fd, UI_DEV_CREATE)) {
    debug("Unable to create UINPUT device.");
    return -1;
}
return 0;
</code></pre>

<p>}</p>

<p>and then write some events in uinput_fd, code segment like this:</p>

<pre><code> int len;
// Move pointer to (100,100) location
memset(&amp;event, 0, sizeof(event));
gettimeofday(&amp;event.time, NULL);
event.type = type;
event.code = code;
event.value = value;
len = write(uinp_fd, &amp;event, sizeof(event));
debug("SendEventToUinput done:%d %d %d",type, code, value);
</code></pre>

<p>I can see events have writen on /dev/input/event7 in terminal by enter command "getevent -l", like this:</p>

<blockquote>
<pre><code>/dev/input/event7: EV_KEY       BTN_TOUCH            DOWN                
/dev/input/event7: EV_ABS       ABS_MT_TRACKING_ID   00000027            
/dev/input/event7: EV_ABS       ABS_MT_TOUCH_MAJOR   0000005d            
/dev/input/event7: EV_ABS       ABS_MT_POSITION_X    00000251            
/dev/input/event7: EV_ABS       ABS_MT_POSITION_Y    0000048f            
/dev/input/event7: EV_SYN       SYN_REPORT           00000000            
/dev/input/event7: EV_ABS       ABS_MT_TOUCH_MAJOR   00000045            
/dev/input/event7: EV_SYN       SYN_REPORT           00000000            
/dev/input/event7: EV_ABS       ABS_MT_TRACKING_ID   ffffffff            
/dev/input/event7: EV_SYN       SYN_REPORT           00000000            
/dev/input/event7: EV_KEY       BTN_TOUCH            UP                  
/dev/input/event7: EV_SYN       SYN_REPORT           00000000 
</code></pre>
</blockquote>

<p>but nothing show on screen, if I send same events on "dev/input/event4" it can work?  why "dev/uinput" is invalide?</p>

<p>Someone help me please.</p>