Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qevdevtouchmanager.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qevdevtouchmanager_p.h"
5
#
include
"qevdevtouchhandler_p.h"
6
7
#
include
<
QtInputSupport
/
private
/
qevdevutil_p
.
h
>
8
9
#
include
<
QStringList
>
10
#
include
<
QGuiApplication
>
11
#
include
<
QLoggingCategory
>
12
#
include
<
QtDeviceDiscoverySupport
/
private
/
qdevicediscovery_p
.
h
>
13
#
include
<
private
/
qguiapplication_p
.
h
>
14
#
include
<
private
/
qinputdevicemanager_p_p
.
h
>
15
16
QT_BEGIN_NAMESPACE
17
18
QEvdevTouchManager::QEvdevTouchManager(
const
QString &key,
const
QString &specification, QObject *parent)
19
: QObject(parent)
20
{
21
Q_UNUSED(key);
22
23
if
(qEnvironmentVariableIsSet(
"QT_QPA_EVDEV_DEBUG"
))
24
const_cast
<QLoggingCategory &>(qLcEvdevTouch()).setEnabled(QtDebugMsg,
true
);
25
26
QString spec = qEnvironmentVariable(
"QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS"
);
27
28
if
(spec.isEmpty())
29
spec = specification;
30
31
auto
parsed = QEvdevUtil::parseSpecification(spec);
32
m_spec = std::move(parsed.spec);
33
34
for
(
const
QString &device : std::as_const(parsed.devices))
35
addDevice(device);
36
37
// when no devices specified, use device discovery to scan and monitor
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)
43
addDevice(device);
44
45
connect(deviceDiscovery, &QDeviceDiscovery::deviceDetected,
46
this
, &QEvdevTouchManager::addDevice);
47
connect(deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
48
this
, &QEvdevTouchManager::removeDevice);
49
}
50
}
51
}
52
53
QEvdevTouchManager
::~
QEvdevTouchManager
()
54
{
55
}
56
57
void
QEvdevTouchManager
::
addDevice
(
const
QString &deviceNode)
58
{
59
qCDebug(qLcEvdevTouch,
"evdevtouch: Adding device at %ls"
, qUtf16Printable(deviceNode));
60
auto
handler = std::make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec);
61
if
(handler) {
62
connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered,
this
, &
QEvdevTouchManager
::
updateInputDeviceCount
);
63
m_activeDevices.add(deviceNode, std::move(handler));
64
}
else
{
65
qWarning(
"evdevtouch: Failed to open touch device %ls"
, qUtf16Printable(deviceNode));
66
}
67
}
68
69
void
QEvdevTouchManager
::
removeDevice
(
const
QString &deviceNode)
70
{
71
if
(m_activeDevices.remove(deviceNode)) {
72
qCDebug(qLcEvdevTouch,
"evdevtouch: Removing device at %ls"
, qUtf16Printable(deviceNode));
73
updateInputDeviceCount
(
)
;
74
}
75
}
76
77
void
QEvdevTouchManager
::
updateInputDeviceCount
()
78
{
79
int
registeredTouchDevices = 0;
80
for
(
const
auto
&device : m_activeDevices) {
81
if
(device.handler->isPointingDeviceRegistered())
82
++registeredTouchDevices;
83
}
84
85
qCDebug(qLcEvdevTouch,
"evdevtouch: Updating QInputDeviceManager device count: %d touch devices, %d pending handler(s)"
,
86
registeredTouchDevices, m_activeDevices.count() - registeredTouchDevices);
87
88
QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
89
QInputDeviceManager::DeviceTypeTouch, registeredTouchDevices);
90
}
91
92
QT_END_NAMESPACE
QEvdevTouchManager
Definition
qevdevtouchmanager_p.h:30
QEvdevTouchManager::removeDevice
void removeDevice(const QString &deviceNode)
Definition
qevdevtouchmanager.cpp:69
QEvdevTouchManager::addDevice
void addDevice(const QString &deviceNode)
Definition
qevdevtouchmanager.cpp:57
QEvdevTouchManager::updateInputDeviceCount
void updateInputDeviceCount()
Definition
qevdevtouchmanager.cpp:77
QEvdevTouchManager::~QEvdevTouchManager
~QEvdevTouchManager()
Definition
qevdevtouchmanager.cpp:53
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
platformsupport
input
evdevtouch
qevdevtouchmanager.cpp
Generated on
for Qt by
1.18.0