1// Copyright (C) 2018 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#ifndef QDEVICEDISCOVERY_H
5#define QDEVICEDISCOVERY_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QObject>
19#include <QSocketNotifier>
20#include <QStringList>
21#include <private/qglobal_p.h>
22
23#define QT_EVDEV_DEVICE_PATH "/dev/input/"
24#define QT_EVDEV_DEVICE_PREFIX "event"
25#define QT_EVDEV_DEVICE QT_EVDEV_DEVICE_PATH QT_EVDEV_DEVICE_PREFIX
26
27#define QT_DRM_DEVICE_PATH "/dev/dri/"
28#define QT_DRM_DEVICE_PREFIX "card"
29#define QT_DRM_DEVICE QT_DRM_DEVICE_PATH QT_DRM_DEVICE_PREFIX
30
31QT_BEGIN_NAMESPACE
32
33class QDeviceDiscovery : public QObject
34{
35 Q_OBJECT
36
37public:
38 enum QDeviceType {
39 Device_Unknown = 0x00,
40 Device_Mouse = 0x01,
41 Device_Touchpad = 0x02,
42 Device_Touchscreen = 0x04,
43 Device_Keyboard = 0x08,
44 Device_DRM = 0x10,
45 Device_DRM_PrimaryGPU = 0x20,
46 Device_Tablet = 0x40,
47 Device_Joystick = 0x80,
48 Device_InputMask = Device_Mouse | Device_Touchpad | Device_Touchscreen | Device_Keyboard | Device_Tablet | Device_Joystick,
49 Device_VideoMask = Device_DRM
50 };
51 Q_ENUM(QDeviceType)
52 Q_DECLARE_FLAGS(QDeviceTypes, QDeviceType)
53
54 static QDeviceDiscovery *create(QDeviceTypes type, QObject *parent = nullptr);
55
56 virtual QStringList scanConnectedDevices() = 0;
57
58signals:
59 void deviceDetected(const QString &deviceNode);
60 void deviceRemoved(const QString &deviceNode);
61
62protected:
63 QDeviceDiscovery(QDeviceTypes types, QObject *parent) : QObject(parent), m_types(types) { }
64 Q_DISABLE_COPY_MOVE(QDeviceDiscovery)
65
66 QDeviceTypes m_types;
67};
68
69Q_DECLARE_OPERATORS_FOR_FLAGS(QDeviceDiscovery::QDeviceTypes)
70
71QT_END_NAMESPACE
72
73#endif // QDEVICEDISCOVERY_H
74

source code of qtbase/src/platformsupport/devicediscovery/qdevicediscovery_p.h