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
qdevicediscovery_vxworks.cpp
Go to the documentation of this file.
1
// Copyright (C) 2024 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
"qdevicediscovery_vxworks_p.h"
5
6
#
include
<
QStringList
>
7
#
include
<
QCoreApplication
>
8
#
include
<
QObject
>
9
#
include
<
QHash
>
10
#
include
<
QDir
>
11
#
include
<
QLoggingCategory
>
12
#
include
<
QtCore
/
private
/
qcore_unix_p
.
h
>
13
14
#
include
<
evdevLib
.
h
>
15
#
include
<
fcntl
.
h
>
16
17
#
define
LONG_BITS
(
sizeof
(
long
)
*
8
)
18
#
define
LONG_FIELD_SIZE
(
bits
)
(
(
bits
/
LONG_BITS
)
+
1
)
19
20
QT_BEGIN_NAMESPACE
21
22
using
namespace
Qt::StringLiterals;
23
24
Q_STATIC_LOGGING_CATEGORY
(lcDD,
"qt.qpa.input"
)
25
26
QDeviceDiscovery *QDeviceDiscovery::create(QDeviceTypes types, QObject *parent)
27
{
28
return
new
QDeviceDiscoveryVxWorks(types, parent);
29
}
30
31
QDeviceDiscoveryVxWorks::QDeviceDiscoveryVxWorks(QDeviceTypes types, QObject *parent)
32
: QDeviceDiscovery(types, parent)
33
{
34
qCDebug(lcDD) <<
"vxworks device discovery for type"
<< types;
35
}
36
37
QStringList QDeviceDiscoveryVxWorks::scanConnectedDevices()
38
{
39
QStringList devices;
40
41
// check for input devices
42
if
(m_types & Device_InputMask) {
43
for
(
const
auto
&entry : QDirListing(QString::fromLatin1(
"/input/"
))) {
44
QString absoluteFilePath = entry.absoluteFilePath();
45
if
(checkDeviceType(absoluteFilePath))
46
devices << absoluteFilePath;
47
}
48
}
49
50
if
(m_types & Device_VideoMask) {
51
devices << QString::fromLatin1(
"/dev/dri/card0"
);
52
}
53
54
return
devices;
55
}
56
57
bool
QDeviceDiscoveryVxWorks::checkDeviceType(
const
QString &device)
58
{
59
int
fd = QT_OPEN(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
60
if
(Q_UNLIKELY(fd == -1)) {
61
// This is changed to debug type message due the nature of scanning
62
// and adding new device for VxWorks by getting dev count from
63
// dev /input/event0 which might be already in use
64
qCDebug(lcDD) <<
"Device discovery cannot open device"
<< device;
65
return
false
;
66
}
67
68
qCDebug(lcDD) <<
"doing static device discovery for "
<< device;
69
70
if
((m_types & Device_DRM) && device.contains(
QT_DRM_DEVICE_PREFIX
""_L1
)) {
71
QT_CLOSE(fd);
72
return
true
;
73
}
74
75
UINT32 devCap = 0;
76
if
(ERROR != ioctl(fd, EV_DEV_IO_GET_CAP, (
char
*)&devCap)) {
77
if
((m_types & Device_Keyboard) && (devCap & EV_DEV_KEY)) {
78
if
(!(devCap & EV_DEV_REL) && !(devCap & EV_DEV_ABS)) {
79
qCDebug(lcDD) <<
"DeviceDiscovery found keyboard at"
<< device;
80
QT_CLOSE(fd);
81
return
true
;
82
}
83
}
84
85
if
(m_types & Device_Mouse) {
86
if
((devCap & EV_DEV_REL) && (devCap & EV_DEV_KEY) && !(devCap & EV_DEV_ABS)) {
87
qCDebug(lcDD) <<
"DeviceDiscovery found mouse at"
<< device;
88
QT_CLOSE(fd);
89
return
true
;
90
}
91
}
92
93
if
((m_types & (Device_Touchpad | Device_Touchscreen))) {
94
if
((m_types & Device_Touchscreen) && (devCap & EV_DEV_ABS && (devCap & EV_DEV_KEY))) {
95
qCDebug(lcDD) <<
"DeviceDiscovery found touchscreen at"
<< device;
96
QT_CLOSE(fd);
97
return
true
;
98
}
99
}
100
}
101
QT_CLOSE(fd);
102
103
return
false
;
104
}
105
106
QT_END_NAMESPACE
QT_DRM_DEVICE_PREFIX
#define QT_DRM_DEVICE_PREFIX
Definition
qdevicediscovery_p.h:28
LONG_BITS
#define LONG_BITS
Definition
qdevicediscovery_static.cpp:40
Q_STATIC_LOGGING_CATEGORY
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
qtbase
src
platformsupport
devicediscovery
qdevicediscovery_vxworks.cpp
Generated on
for Qt by
1.18.0