poky/downloads/qtbase-opensource-src-5.4.1/src/plugins/generic/tslib/qtslib.cpp 中
QTsLibMouseHandler()函数中 调用tslib的函数ts_open(),打开 /dev/inpu/event%d的设备节点,
m_dev = ts_open(device.constData(), 1);
if (!m_dev) {
qErrnoWarning(errno, “ts_open() failed”);
return;
}
if (ts_config(m_dev))
perror(“Error configuring\n”);
m_rawMode = !key.compare(QLatin1String(“TslibRaw”), Qt::CaseInsensitive);
int fd = ts_fd(m_dev);
if (fd >= 0) {
m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this); //监听fd 文件句柄。(监听 /dev/input/event%d设备节点是否有数据)
connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
}
代码最终调用QWindowSystemInterface :: handleMouseEvent(….)将事件转发到应用程序.
void QTsLibMouseHandler::readMouseData()
{
QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton);
}
QT得到触摸坐标的框架图: