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>
This commit is contained in:
parent
d8b943849f
commit
9c05fdac81
@ -139,7 +139,11 @@ std::unique_ptr<QEvdevKeyboardHandler> QEvdevKeyboardHandler::create(const QStri
|
|||||||
|
|
||||||
qCDebug(qLcEvdevKey, "Opening keyboard at %ls", qUtf16Printable(device));
|
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) {
|
if (fd.get() >= 0) {
|
||||||
::ioctl(fd.get(), EVIOCGRAB, grab);
|
::ioctl(fd.get(), EVIOCGRAB, grab);
|
||||||
if (repeatDelay > 0 && repeatRate > 0) {
|
if (repeatDelay > 0 && repeatRate > 0) {
|
||||||
|
@ -143,6 +143,7 @@ public:
|
|||||||
|
|
||||||
int release() noexcept { int result = m_fd; m_fd = -1; return result; }
|
int release() noexcept { int result = m_fd; m_fd = -1; return result; }
|
||||||
void reset() noexcept;
|
void reset() noexcept;
|
||||||
|
void reset(int fd) { reset(); m_fd = fd; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class QEvdevKeyboardHandler : public QObject
|
class QEvdevKeyboardHandler : public QObject
|
||||||
|
Loading…
Reference in New Issue
Block a user