Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
5.12.1, 5.12.9
-
Embedded Linux with linuxfb and evdev keyboard
-
-
355d1b8406e7b597a9f32678fdce515f48e90549 (qt/qtbase/6.2) 9c05fdac81d5fe0d3007ba55cfddf4eb99183153 (qt/qtbase/dev) 3cf09cccc224995eae74f93b7b35476d2649bdf2 (qt/tqtc-qtbase/5.15)
Description
I am running an application on an embedded Linux based on the framebuffer and using the evdev keyboard plugin to handle an external USB keyboard.
I found that the keyboard LEDs do not change when we press on numlock, capslock or scrolllock.
One can have the illusion that the LEDs work more or less but it may be related to a /dev/tty running on the device that still manages LEDs. However tty LED management should be disabled when running an application that handle LEDs by itself. Qt evdev keyboard handler actually does LED management itself, which is the expected design.
To reproduce the issue, you can remove tty from the Linux image (this is the case with our device) or switch tty to manual LED management by calling ioctl(tty, KDSETLED, 0) early when the system starts.
The problem comes from QEvdevKeyboardHandler::switchLed(). That function has no effect: the write() call returns -1 and errno is set to 9 (Bad file descriptor).
It happens that the file descriptor is read-only. To fix the problem, the QFdContainer in QEvdevKeyboardHandler::create() should be created with O_RDWR instead of O_RDONLY.
I also think QEvdevKeyboardHandler::switchLed() could be improved by adding an error message when qt_safe_write() fails. I had to add a trace myself and rebuild the Qt runtime to diagnose the problem.