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 } else {
23 // build new specification without /dev/ elements
24 result.spec += arg + u':';
25 }
26 }
27
28 if (!result.spec.isEmpty())
29 result.spec.chop(n: 1); // remove trailing ':'
30
31 return result;
32}
33
34} // namespace QEvdevUtil
35
36QT_END_NAMESPACE
37

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