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 }
23#ifdef Q_OS_VXWORKS
24 else if (arg.startsWith("/input/"_L1)) {
25 result.devices.append(arg.toString());
26 }
27#endif
28 else {
29 // build new specification without /dev/ elements
30 result.spec += arg + u':';
31 }
32 }
33
34 if (!result.spec.isEmpty())
35 result.spec.chop(n: 1); // remove trailing ':'
36
37 return result;
38}
39
40} // namespace QEvdevUtil
41
42QT_END_NAMESPACE
43

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

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