tslib: use ts_setup() to find the device
This automatically searches for some default devices. This not only reduces the amount of code, it also makes sure that Qt will by default find the same input devices that tslib (e.g. ts_calibrate) will find. Fixes: QTBUG-74680 Change-Id: Ied3fff7e8ed9d6637d2b8cf32119660133d251a3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
cab6587e5e
commit
093a1a6232
@ -476,7 +476,7 @@
|
||||
"tslib": {
|
||||
"label": "tslib",
|
||||
"test": {
|
||||
"main": "ts_open(\"foo\", 0);"
|
||||
"main": "ts_setup(nullptr, 0);"
|
||||
},
|
||||
"headers": "tslib.h",
|
||||
"sources": [
|
||||
|
@ -62,31 +62,15 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key,
|
||||
qCDebug(qLcTsLib) << "Initializing tslib plugin" << key << specification;
|
||||
setObjectName(QLatin1String("TSLib Mouse Handler"));
|
||||
|
||||
QByteArray device = qgetenv("TSLIB_TSDEVICE");
|
||||
|
||||
if (specification.startsWith(QLatin1String("/dev/")))
|
||||
device = specification.toLocal8Bit();
|
||||
|
||||
if (device.isEmpty())
|
||||
device = QByteArrayLiteral("/dev/input/event1");
|
||||
|
||||
m_dev = ts_open(device.constData(), 1);
|
||||
m_dev = ts_setup(nullptr, 1);
|
||||
if (!m_dev) {
|
||||
qErrnoWarning(errno, "ts_open() failed");
|
||||
qErrnoWarning(errno, "ts_setup() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ts_config(m_dev))
|
||||
qErrnoWarning(errno, "ts_config() failed");
|
||||
|
||||
int fd = ts_fd(m_dev);
|
||||
if (fd >= 0) {
|
||||
qCDebug(qLcTsLib) << "tslib device is" << device;
|
||||
m_notify = new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
||||
qCDebug(qLcTsLib) << "tslib device is" << ts_get_eventpath(m_dev);
|
||||
m_notify = new QSocketNotifier(ts_fd(m_dev), QSocketNotifier::Read, this);
|
||||
connect(m_notify, &QSocketNotifier::activated, this, &QTsLibMouseHandler::readMouseData);
|
||||
} else {
|
||||
qErrnoWarning(errno, "tslib: Cannot open input device %s", device.constData());
|
||||
}
|
||||
}
|
||||
|
||||
QTsLibMouseHandler::~QTsLibMouseHandler()
|
||||
|
Loading…
Reference in New Issue
Block a user