18QEvdevTouchManager::QEvdevTouchManager(
const QString &key,
const QString &specification, QObject *parent)
23 if (qEnvironmentVariableIsSet(
"QT_QPA_EVDEV_DEBUG"))
24 const_cast<QLoggingCategory &>(qLcEvdevTouch()).setEnabled(QtDebugMsg,
true);
26 QString spec = qEnvironmentVariable(
"QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS");
31 auto parsed = QEvdevUtil::parseSpecification(spec);
32 m_spec = std::move(parsed.spec);
34 for (
const QString &device : std::as_const(parsed.devices))
38 if (parsed.devices.isEmpty()) {
39 qCDebug(qLcEvdevTouch,
"evdevtouch: Using device discovery");
40 if (
auto deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen,
this)) {
41 const QStringList devices = deviceDiscovery->scanConnectedDevices();
42 for (
const QString &device : devices)
45 connect(deviceDiscovery, &QDeviceDiscovery::deviceDetected,
46 this, &QEvdevTouchManager::addDevice);
47 connect(deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
48 this, &QEvdevTouchManager::removeDevice);
59 qCDebug(qLcEvdevTouch,
"evdevtouch: Adding device at %ls", qUtf16Printable(deviceNode));
60 auto handler = std::make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec);
62 connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered,
this, &QEvdevTouchManager::updateInputDeviceCount);
63 m_activeDevices.add(deviceNode, std::move(handler));
65 qWarning(
"evdevtouch: Failed to open touch device %ls", qUtf16Printable(deviceNode));
79 int registeredTouchDevices = 0;
80 for (
const auto &device : m_activeDevices) {
81 if (device.handler->isPointingDeviceRegistered())
82 ++registeredTouchDevices;
85 qCDebug(qLcEvdevTouch,
"evdevtouch: Updating QInputDeviceManager device count: %d touch devices, %d pending handler(s)",
86 registeredTouchDevices, m_activeDevices.count() - registeredTouchDevices);
88 QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
89 QInputDeviceManager::DeviceTypeTouch, registeredTouchDevices);