I am trying to send multi touch from a phone to android x86 on Virtualbox using uinput. I am using muti touch screen in android emulator to receive the multi touch data. Once I recei the data, I want to use uinput t inject it into androidx86.
I have following code to create uinput device but device keeps on getting removed. Looks like there are no drivers to handle multi touch event. Can someone help me what I can change to get this working.
int main(int argc, char **argv)
{
int uinp_fd = -1;
struct uinput_user_dev uinp;
struct input_event event;
if (!(uinp_fd = open("/dev/uinput", O_WRONLY|O_NDELAY))) {
fprintf(stderr, "Unable to open /dev/uinput !\n");
exit(-1);
}
memset(&uinp, 0, sizeof(uinp));
strncpy(
uinp.name, "ABC", UINPUT_MAX_NAME_SIZE);
uinp.id.vendor=0x1234;
uinp.id.product=1;
uinp.id.version=1;
uinp.absmin[ABS_MT_POSITION_X]=0;
uinp.absmax[ABS_MT_POSITION_X]=800;
uinp.absmin[ABS_MT_POSITION_Y]=0;
uinp.absmax[ABS_MT_POSITION_Y]=600;
// Added for MT Touch
uinp.absmax[ABS_MT_SLOT] = 9;
uinp.absmax[ABS_MT_TRACKING_ID] = 10;
uinp.absmax[ABS_MT_TOUCH_MAJOR] = 0x7fffffff; // TODO: Make it less random;
uinp.absmax[ABS_MT_PRESSURE] = 0x100; // TODO: Make it less random;
// Added for MT Touch
ioctl(uinp_fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT);
ioctl(uinp_fd, UI_SET_EVBIT, EV_ABS);
ioctl(uinp_fd, UI_SET_EVBIT, BTN_TOUCH);
// Added for MT Touch
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_SLOT);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_POSITION_X);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MAJOR);
ioctl(uinp_fd, UI_SET_ABSBIT, ABS_MT_PRESSURE);
write(uinp_fd, &uinp, sizeof(uinp));
if (ioctl(uinp_fd, UI_DEV_CREATE)) {
ALOGW("Unable to create ABS uinput device...");
fprintf(stderr, "Unable to create ABS uinput device...\n");
exit(-1);
}
return 0;
}
I/EventHub( 1119): New device: id=7, fd=167, path='/dev/input/event7', name='ABC', classes=0x14, configuration='/system/usr/idc/ABC.idc', keyLayout='', keyCharacterMap='', builtinKeyboard=false, usingSuspendBlockIoctl=true, usingClockIoctl=true
I/InputReader( 1119): Device reconfigured: id=7, name='ABC', size 800x600, orientation 0, mode 1, display id 0
I/InputReader( 1119): Device added: id=7, name='ABC', sources=0x00001002
I/EventHub( 1119): Removing device '/dev/input/event7' due to inotify event
I/EventHub( 1119): Removed device: path=/dev/input/event7 name=ABC id=7 fd=167 classes=0x14
I/InputReader( 1119): Device removed: id=7, name='ABC', sources=0x00001002
D/InputReader( 1119): Could not retrieve current multitouch slot index. status=-1
E/EventHub( 1119): could not get driver version for /dev/input/js0, Invalid argument