qevdevtouchmanager.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the plugins module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qevdevtouchmanager_p.h"-
41#include "qevdevtouchhandler_p.h"-
42-
43#include <QStringList>-
44#include <QGuiApplication>-
45#include <QLoggingCategory>-
46#include <QtPlatformSupport/private/qdevicediscovery_p.h>-
47#include <private/qguiapplication_p.h>-
48#include <private/qinputdevicemanager_p_p.h>-
49-
50QT_BEGIN_NAMESPACE-
51-
52Q_DECLARE_LOGGING_CATEGORY(qLcEvdevTouch)-
53-
54QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specification, QObject *parent)-
55 : QObject(parent)-
56{-
57 Q_UNUSED(key);-
58-
59 if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
qEnvironmentVa..._EVDEV_DEBUG")Description
TRUEnever evaluated
FALSEnever evaluated
0
60 const_cast<QLoggingCategory &>(qLcEvdevTouch()).setEnabled(QtDebugMsg, true);
never executed: const_cast<QLoggingCategory &>(qLcEvdevTouch()).setEnabled(QtDebugMsg, true);
0
61-
62 QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS"));-
63-
64 if (spec.isEmpty())
spec.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
65 spec = specification;
never executed: spec = specification;
0
66-
67 QStringList args = spec.split(QLatin1Char(':'));-
68 QStringList devices;-
69-
70 foreach (const QString &arg, args) {-
71 if (arg.startsWith(QLatin1String("/dev/"))) {
arg.startsWith...ring("/dev/"))Description
TRUEnever evaluated
FALSEnever evaluated
0
72 devices.append(arg);-
73 args.removeAll(arg);-
74 }
never executed: end of block
0
75 }
never executed: end of block
0
76-
77 // build new specification without /dev/ elements-
78 m_spec = args.join(QLatin1Char(':'));-
79-
80 foreach (const QString &device, devices)-
81 addDevice(device);
never executed: addDevice(device);
0
82-
83 // when no devices specified, use device discovery to scan and monitor-
84 if (devices.isEmpty()) {
devices.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
85 qCDebug(qLcEvdevTouch) << "evdevtouch: Using device discovery";
never executed: QMessageLogger(__FILE__, 85, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Using device discovery";
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this);-
87 if (m_deviceDiscovery) {
m_deviceDiscoveryDescription
TRUEnever evaluated
FALSEnever evaluated
0
88 QStringList devices = m_deviceDiscovery->scanConnectedDevices();-
89 foreach (const QString &device, devices)-
90 addDevice(device);
never executed: addDevice(device);
0
91 connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));-
92 connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));-
93 }
never executed: end of block
0
94 }
never executed: end of block
0
95}
never executed: end of block
0
96-
97QEvdevTouchManager::~QEvdevTouchManager()-
98{-
99 qDeleteAll(m_activeDevices);-
100}
never executed: end of block
0
101-
102void QEvdevTouchManager::addDevice(const QString &deviceNode)-
103{-
104 qCDebug(qLcEvdevTouch) << "evdevtouch: Adding device at" << deviceNode;
never executed: QMessageLogger(__FILE__, 104, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Adding device at" << deviceNode;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
105 QEvdevTouchScreenHandlerThread *handler;-
106 handler = new QEvdevTouchScreenHandlerThread(deviceNode, m_spec);-
107 if (handler) {
handlerDescription
TRUEnever evaluated
FALSEnever evaluated
0
108 m_activeDevices.insert(deviceNode, handler);-
109 connect(handler, &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount);-
110 } else {
never executed: end of block
0
111 qWarning("evdevtouch: Failed to open touch device %s", qPrintable(deviceNode));-
112 }
never executed: end of block
0
113}-
114-
115void QEvdevTouchManager::removeDevice(const QString &deviceNode)-
116{-
117 if (m_activeDevices.contains(deviceNode)) {
m_activeDevice...ns(deviceNode)Description
TRUEnever evaluated
FALSEnever evaluated
0
118 qCDebug(qLcEvdevTouch) << "evdevtouch: Removing device at" << deviceNode;
never executed: QMessageLogger(__FILE__, 118, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Removing device at" << deviceNode;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
119 QEvdevTouchScreenHandlerThread *handler = m_activeDevices.value(deviceNode);-
120 m_activeDevices.remove(deviceNode);-
121 delete handler;-
122-
123 updateInputDeviceCount();-
124 }
never executed: end of block
0
125}
never executed: end of block
0
126-
127void QEvdevTouchManager::updateInputDeviceCount()-
128{-
129 int registeredTouchDevices = 0;-
130 Q_FOREACH (QEvdevTouchScreenHandlerThread *handler, m_activeDevices) {-
131 if (handler->isTouchDeviceRegistered())
handler->isTou...ceRegistered()Description
TRUEnever evaluated
FALSEnever evaluated
0
132 ++registeredTouchDevices;
never executed: ++registeredTouchDevices;
0
133 }
never executed: end of block
0
134-
135 qCDebug(qLcEvdevTouch) << "evdevtouch: Updating QInputDeviceManager device count:" << registeredTouchDevices << " touch devices,"
never executed: QMessageLogger(__FILE__, 135, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Updating QInputDeviceManager device count:" << registeredTouchDevices << " touch devices," << m_activeDevices.count() - registeredTouchDevices << "pending handler(s)" ;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
136 << m_activeDevices.count() - registeredTouchDevices << "pending handler(s)" ;
never executed: QMessageLogger(__FILE__, 135, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Updating QInputDeviceManager device count:" << registeredTouchDevices << " touch devices," << m_activeDevices.count() - registeredTouchDevices << "pending handler(s)" ;
0
137-
138 QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(-
139 QInputDeviceManager::DeviceTypeTouch, registeredTouchDevices);-
140}
never executed: end of block
0
141-
142QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9