diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-12-03 14:49:57 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-12-08 13:45:34 +0100 |
commit | 9c05fdac81d5fe0d3007ba55cfddf4eb99183153 (patch) | |
tree | 5b16fc470fd7a9c3978af5343c692dcb3a3ab9df /src/platformsupport | |
parent | d8b943849fc458029b78029a290beda4d535e8b7 (diff) |
evdevkeyboard: Try opening as read-write first
switchLed writes to the device, and so O_RDONLY cannot be correct.
Change-Id: If79814804bcd3c6fb01617be9f1a73e54b9563bd
Pick-to: 6.2 5.15
Fixes: QTBUG-80653
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/platformsupport')
-rw-r--r-- | src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp | 6 | ||||
-rw-r--r-- | src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index ec9d588aff..e1026c5621 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -139,7 +139,11 @@ std::unique_ptr<QEvdevKeyboardHandler> QEvdevKeyboardHandler::create(const QStri 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) { diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index f92a2bf704..24ed1b64a8 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -143,6 +143,7 @@ public: int release() noexcept { int result = m_fd; m_fd = -1; return result; } void reset() noexcept; + void reset(int fd) { reset(); m_fd = fd; } }; class QEvdevKeyboardHandler : public QObject |