设备usb触摸线断开之后,即使重连,在已经运行的qt程序中,触摸失效,并且系统已经生成了触摸设备节点。
解决方法:使用tslib;修改qt源码中的src/gui/embedded/qmousetslib_qws.cpp
在QWSTslibMouseHandlerPrivate::readMouseData()的开始处加入以下代码,
void QWSTslibMouseHandlerPrivate::readMouseData()
{
if(!qt_screen)
return;
/* Support usb touchscreen hotplug */
int version;
if (ioctl(ts_fd(dev), EVIOCGVERSION, &version) < 0) {
disconnect(mouseNotifier, 0, 0, 0);
delete mouseNotifier;
while (1) {
if(open()) {
mouseNotifier = new QSocketNotifier(ts_fd(dev), QSocketNotifier::Read, this);
connect(mouseNotifier, SIGNAL(activated(int)), this, SLOT(readMouseData()));
resume();
return;
}
system("echo waiting for tp ...");
system("sleep 1");
}
}
/* end */
...
}
但是重新编译qt会失败,错误一:缺少ioctl()的头文件, #include <sys/ioctl.h>
错误二:EVIOCGVERSION未定义 ,#define EVIOCGVERSION _IOR('E', 0x01, int) /* 获取驱动的版本信息*/ ;
之后编译,替换掉的libQtGui.so.4.8.6