1// Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
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 "qevdevutil_p.h"
5
6QT_BEGIN_NAMESPACE
7
8using namespace Qt::StringLiterals;
9
10namespace QEvdevUtil {
11
12ParsedSpecification parseSpecification(const QString &specification)
13{
14 ParsedSpecification result;
15
16 result.args = QStringView{specification}.split(sep: u':');
17
18 for (const auto &arg : std::as_const(t&: result.args)) {
19 if (arg.startsWith(s: "/dev/"_L1)) {
20 // if device is specified try to use it
21 result.devices.append(t: arg.toString());
22#ifdef Q_OS_VXWORKS
23 } else if (arg.startsWith("/input/"_L1)) {
24 result.devices.append(arg.toString());
25#endif
26 } else {
27 // build new specification without /dev/ elements
28 result.spec += arg + u':';
29 }
30 }
31
32 if (!result.spec.isEmpty())
33 result.spec.chop(n: 1); // remove trailing ':'
34
35 return result;
36}
37
38} // namespace QEvdevUtil
39
40QT_END_NAMESPACE
41

source code of qtbase/src/platformsupport/input/shared/qevdevutil.cpp