下午好,
我正在尝试在有根的 Android 手机中使用 uinput 创建一个虚拟触摸屏。
即使我能够创建设备,
New device: id=88, fd=170, path='/dev/input/event6', name='uinput-eve',
classes=0x4, configuration='', keyLayout='', keyCharacterMap='',
builtinKeyboard=false, usingSuspendBlockIoctl=true, usingClockIoctl=false
Touch device 'uinput-eve' did not report support for X or Y axis!
The device will be inoperable.
Device added: id=88, name='uinput-eve', sources=0x00002002
由于设备无法操作,我无法正确创建它。正在跳跃任何人都可以揭示一些光。
这是我总是导致该消息的许多尝试之一。
struct uinput_user_dev uidev;
struct input_event ev;
int dx, dy;
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, "uinput-eve");
uidev.id.bustype = BUS_VIRTUAL;
uidev.id.vendor = 0x1;
uidev.id.product = 0x1;
uidev.id.version = 1;
if (write(fd, &uidev, sizeof(uidev)) < 0) {
die("error: write");
}
/* touch screen event */
ioctl(fd, UI_SET_EVBIT, EV_ABS);
ioctl(fd, UI_SET_ABSBIT, ABS_X);
ioctl(fd, UI_SET_ABSBIT, ABS_Y);
ioctl(fd, UI_SET_EVBIT, EV_KEY);
ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH);
if (ioctl(fd, UI_DEV_CREATE,0) < 0) {
die("error: ioctl");
}
Edit1:挖得更深一点,问题是显然没有设置 mRawPointerAxes,有人知道如何设置它们吗?下面的代码来自 services/input/InputReader.cpp。
// Ensure we have valid X and Y axes.
if (!mRawPointerAxes.x.valid || !mRawPointerAxes.y.valid) {
LOGW(INDENT "Touch device '%s' did not report support for X or Y axis! "
"The device will be inoperable.", getDeviceName().string());
mDeviceMode = DEVICE_MODE_DISABLED;
return;
}
提前感谢您的宝贵时间。