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) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the plugins module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qevdevtouchmanager_p.h"-
35#include "qevdevtouchhandler_p.h"-
36-
37#include <QStringList>-
38#include <QGuiApplication>-
39#include <QLoggingCategory>-
40#include <QtPlatformSupport/private/qdevicediscovery_p.h>-
41#include <private/qguiapplication_p.h>-
42#include <private/qinputdevicemanager_p_p.h>-
43-
44QT_BEGIN_NAMESPACE-
45-
46Q_DECLARE_LOGGING_CATEGORY(qLcEvdevTouch)-
47-
48QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specification, QObject *parent)-
49 : QObject(parent)-
50{-
51 Q_UNUSED(key);-
52-
53 if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
qEnvironmentVa..._EVDEV_DEBUG")Description
TRUEnever evaluated
FALSEnever evaluated
0
54 const_cast<QLoggingCategory &>(qLcEvdevTouch()).setEnabled(QtDebugMsg, true);
never executed: const_cast<QLoggingCategory &>(qLcEvdevTouch()).setEnabled(QtDebugMsg, true);
0
55-
56 QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS"));-
57-
58 if (spec.isEmpty())
spec.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
59 spec = specification;
never executed: spec = specification;
0
60-
61 QStringList args = spec.split(QLatin1Char(':'));-
62 QStringList devices;-
63-
64 foreach (const QString &arg, args) {-
65 if (arg.startsWith(QLatin1String("/dev/"))) {
arg.startsWith...ring("/dev/"))Description
TRUEnever evaluated
FALSEnever evaluated
0
66 devices.append(arg);-
67 args.removeAll(arg);-
68 }
never executed: end of block
0
69 }
never executed: end of block
0
70-
71 // build new specification without /dev/ elements-
72 m_spec = args.join(QLatin1Char(':'));-
73-
74 foreach (const QString &device, devices)-
75 addDevice(device);
never executed: addDevice(device);
0
76-
77 // when no devices specified, use device discovery to scan and monitor-
78 if (devices.isEmpty()) {
devices.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
79 qCDebug(qLcEvdevTouch) << "evdevtouch: Using device discovery";
never executed: QMessageLogger(__FILE__, 79, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Using device discovery";
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
80 m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this);-
81 if (m_deviceDiscovery) {
m_deviceDiscoveryDescription
TRUEnever evaluated
FALSEnever evaluated
0
82 QStringList devices = m_deviceDiscovery->scanConnectedDevices();-
83 foreach (const QString &device, devices)-
84 addDevice(device);
never executed: addDevice(device);
0
85 connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));-
86 connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));-
87 }
never executed: end of block
0
88 }
never executed: end of block
0
89}
never executed: end of block
0
90-
91QEvdevTouchManager::~QEvdevTouchManager()-
92{-
93 qDeleteAll(m_activeDevices);-
94}
never executed: end of block
0
95-
96void QEvdevTouchManager::addDevice(const QString &deviceNode)-
97{-
98 qCDebug(qLcEvdevTouch) << "evdevtouch: Adding device at" << deviceNode;
never executed: QMessageLogger(__FILE__, 98, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Adding device at" << deviceNode;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
99 QEvdevTouchScreenHandlerThread *handler;-
100 handler = new QEvdevTouchScreenHandlerThread(deviceNode, m_spec);-
101 if (handler) {
handlerDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 m_activeDevices.insert(deviceNode, handler);-
103 connect(handler, &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount);-
104 } else {
never executed: end of block
0
105 qWarning("evdevtouch: Failed to open touch device %s", qPrintable(deviceNode));-
106 }
never executed: end of block
0
107}-
108-
109void QEvdevTouchManager::removeDevice(const QString &deviceNode)-
110{-
111 if (m_activeDevices.contains(deviceNode)) {
m_activeDevice...ns(deviceNode)Description
TRUEnever evaluated
FALSEnever evaluated
0
112 qCDebug(qLcEvdevTouch) << "evdevtouch: Removing device at" << deviceNode;
never executed: QMessageLogger(__FILE__, 112, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Removing device at" << deviceNode;
qt_category_enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
113 QEvdevTouchScreenHandlerThread *handler = m_activeDevices.value(deviceNode);-
114 m_activeDevices.remove(deviceNode);-
115 delete handler;-
116-
117 updateInputDeviceCount();-
118 }
never executed: end of block
0
119}
never executed: end of block
0
120-
121void QEvdevTouchManager::updateInputDeviceCount()-
122{-
123 int registeredTouchDevices = 0;-
124 Q_FOREACH (QEvdevTouchScreenHandlerThread *handler, m_activeDevices) {-
125 if (handler->isTouchDeviceRegistered())
handler->isTou...ceRegistered()Description
TRUEnever evaluated
FALSEnever evaluated
0
126 ++registeredTouchDevices;
never executed: ++registeredTouchDevices;
0
127 }
never executed: end of block
0
128-
129 qCDebug(qLcEvdevTouch) << "evdevtouch: Updating QInputDeviceManager device count:" << registeredTouchDevices << " touch devices,"
never executed: QMessageLogger(__FILE__, 129, __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
130 << m_activeDevices.count() - registeredTouchDevices << "pending handler(s)" ;
never executed: QMessageLogger(__FILE__, 129, __PRETTY_FUNCTION__, qLcEvdevTouch().categoryName()).debug() << "evdevtouch: Updating QInputDeviceManager device count:" << registeredTouchDevices << " touch devices," << m_activeDevices.count() - registeredTouchDevices << "pending handler(s)" ;
0
131-
132 QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(-
133 QInputDeviceManager::DeviceTypeTouch, registeredTouchDevices);-
134}
never executed: end of block
0
135-
136QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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