summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp')
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp64
1 files changed, 17 insertions, 47 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
index ec9d588aff..48fba79958 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qevdevkeyboardhandler_p.h"
#include "qoutputmapping_p.h"
@@ -69,6 +33,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_LOGGING_CATEGORY(qLcEvdevKey, "qt.qpa.input")
Q_LOGGING_CATEGORY(qLcEvdevKeyMap, "qt.qpa.input.keymap")
@@ -90,7 +56,7 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer
{
qCDebug(qLcEvdevKey) << "Create keyboard handler with for device" << device;
- setObjectName(QLatin1String("LinuxInput Keyboard Handler"));
+ setObjectName("LinuxInput Keyboard Handler"_L1);
memset(m_locks, 0, sizeof(m_locks));
@@ -121,25 +87,29 @@ std::unique_ptr<QEvdevKeyboardHandler> QEvdevKeyboardHandler::create(const QStri
bool enableCompose = false;
int grab = 0;
- const auto args = QStringView{specification}.split(QLatin1Char(':'));
+ const auto args = QStringView{specification}.split(u':');
for (const auto &arg : args) {
- if (arg.startsWith(QLatin1String("keymap=")))
+ if (arg.startsWith("keymap="_L1))
keymapFile = arg.mid(7).toString();
- else if (arg == QLatin1String("disable-zap"))
+ else if (arg == "disable-zap"_L1)
disableZap = true;
- else if (arg == QLatin1String("enable-compose"))
+ else if (arg == "enable-compose"_L1)
enableCompose = true;
- else if (arg.startsWith(QLatin1String("repeat-delay=")))
+ else if (arg.startsWith("repeat-delay="_L1))
repeatDelay = arg.mid(13).toInt();
- else if (arg.startsWith(QLatin1String("repeat-rate=")))
+ else if (arg.startsWith("repeat-rate="_L1))
repeatRate = arg.mid(12).toInt();
- else if (arg.startsWith(QLatin1String("grab=")))
+ else if (arg.startsWith("grab="_L1))
grab = arg.mid(5).toInt();
}
qCDebug(qLcEvdevKey, "Opening keyboard at %ls", qUtf16Printable(device));
- QFdContainer fd(qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0));
+ QFdContainer fd(qt_safe_open(device.toLocal8Bit().constData(), O_RDWR | O_NDELAY, 0));
+ if (fd.get() < 0) {
+ qCDebug(qLcEvdevKey, "Keyboard device could not be opened as read-write, trying read-only");
+ fd.reset(qt_safe_open(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0));
+ }
if (fd.get() >= 0) {
::ioctl(fd.get(), EVIOCGRAB, grab);
if (repeatDelay > 0 && repeatRate > 0) {