Вопрос

Good morning,

I am able to create a virtual touchscreen using uinput in a rooted Android phone. Using the following jni code:

static int startDevice(const char *touchdevice) {

 struct uinput_user_dev uidev;
 int fd;

 fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
 if (fd < 0) {
    die("error: open");
 }
 memset(&uidev, 0, sizeof(uidev));

 snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "%s",touchdevice);


 uidev.id.bustype = 0;
 uidev.id.vendor = 0x0;
 uidev.id.product = 0x0;
 uidev.id.version = 0;
 uidev.absmax[ABS_MT_POSITION_X] = 1280;
 uidev.absmax[ABS_MT_POSITION_Y] = 800;

 if (write(fd, &uidev, sizeof(uidev)) < 0) {
    die("error: write");
 }
 ioctl(fd, UI_SET_EVBIT, EV_ABS);


 ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_X);
 ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
 ioctl(fd, UI_SET_ABSBIT, ABS_MT_PRESSURE);
 ioctl(fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MAJOR);
 ioctl(fd, UI_SET_ABSBIT, ABS_MT_SLOT);
 ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);

 ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH);


 if (ioctl(fd, UI_DEV_CREATE, 0) < 0) {
    die("error: ioctl");
 }

 idVirtualTouch = fd;

 return 55;
}

When calling the method i give the touchdevice the same name has the default android touchscreen. So when it creates the touch device it will load the configuration file (.idc) of the default touchscreen.

The problem is that it creates a virtual device that answers to multi touch protocol A instead of B (https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt).

I am currently using a Galaxy tab2 with android 4.1.2 and if i forward the default device (protocol b) events to the virtual drive it expects the protocol A events and so it doesn't work properly.

There is no .idc for the default touchscreen and so i created one with only:

touch.deviceType = touchScreen
touch.internal = 1

So my question is what do i have to do for my touch driver to work with protocol B? Is the problem my .idc or is the initialisation of the device?

Thank you for your time

Это было полезно?

Решение

Found the problem, forgot to define the slot and tracking id

uidev.absmax[ABS_MT_TRACKING_ID] = 65535;
uidev.absmax[ABS_MT_SLOT] = 9;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top