Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qevdevtabletmanager.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
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
17
18Q_DECLARE_LOGGING_CATEGORY(qLcEvdevTablet)
19
20QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &specification, QObject *parent)
21 : QObject(parent)
22{
24
25 if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
26 const_cast<QLoggingCategory &>(qLcEvdevTablet()).setEnabled(QtDebugMsg, true);
27
28 QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TABLET_PARAMETERS"));
29
30 if (spec.isEmpty())
31 spec = specification;
32
33 auto parsed = QEvdevUtil::parseSpecification(spec);
34 m_spec = std::move(parsed.spec);
35
36 for (const QString &device : std::as_const(parsed.devices))
37 addDevice(device);
38
39 // when no devices specified, use device discovery to scan and monitor
40 if (parsed.devices.isEmpty()) {
41 qCDebug(qLcEvdevTablet, "evdevtablet: Using device discovery");
42 if (auto deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this)) {
43 const QStringList devices = deviceDiscovery->scanConnectedDevices();
44 for (const QString &device : devices)
45 addDevice(device);
46
51 }
52 }
53}
54
58
60{
61 qCDebug(qLcEvdevTablet, "Adding device at %ls", qUtf16Printable(deviceNode));
62 auto handler = std::make_unique<QEvdevTabletHandlerThread>(deviceNode, m_spec);
63 if (handler) {
64 m_activeDevices.add(deviceNode, std::move(handler));
65 updateDeviceCount();
66 } else {
67 qWarning("evdevtablet: Failed to open tablet device %ls", qUtf16Printable(deviceNode));
68 }
69}
70
72{
73 if (m_activeDevices.remove(deviceNode)) {
74 qCDebug(qLcEvdevTablet, "Removing device at %ls", qUtf16Printable(deviceNode));
75 updateDeviceCount();
76 }
77}
78
79void QEvdevTabletManager::updateDeviceCount()
80{
83}
84
IOBluetoothDevice * device
void deviceDetected(const QString &deviceNode)
static QDeviceDiscovery * create(QDeviceTypes type, QObject *parent=nullptr)
void deviceRemoved(const QString &deviceNode)
void addDevice(const QString &deviceNode)
void removeDevice(const QString &deviceNode)
static QInputDeviceManager * inputDeviceManager()
static QInputDeviceManagerPrivate * get(QInputDeviceManager *mgr)
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5949
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
void add(const QString &deviceNode, std::unique_ptr< Handler > handler)
bool remove(const QString &deviceNode)
ParsedSpecification parseSpecification(const QString &specification)
Combined button and popup list for selecting options.
EGLDeviceEXT * devices
@ QtDebugMsg
Definition qlogging.h:30
#define qWarning
Definition qlogging.h:166
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLuint64 key
#define qUtf16Printable(string)
Definition qstring.h:1543
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
#define Q_UNUSED(x)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)