How to configure keyboard layout when running QT on EGLFS without X?
-
Hi,
I've cross-compiled QT 5.12.5 to run on the RPi using EGLFS without a windowing system like X, and everything seems to be working, but I can't figure out how to change the locale/layout of the keyboard inside QT.
On the console the keyboard is working fine, outputting the expected keys and diacritics for the brazilian ABNT2 keyboard that was configured on the /etc/default/keyboard file.
I tried both using libinput, which is on by default, and disabling it. Neither respect the setting on the keyboard file and I couldn't figure where QT is looking for keyboard related settings.
Since I don't have X running commands like setxkbmap and others dealing with 'xkb' won't run, usually complaining about the lack of display.
Those are some relevant lines from the default log I get by setting QT_LOGGING_RULES=qt.qpa.*=true
qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_brcm" qt.qpa.input: libinput: event4 - UVC Camera (046d:0825): is tagged by udev as: Keyboard qt.qpa.input: libinput: event4 - UVC Camera (046d:0825): device is a keyboard qt.qpa.input: libinput: event0 - Logitech USB Receiver: is tagged by udev as: Keyboard qt.qpa.input: libinput: event0 - Logitech USB Receiver: device is a keyboard qt.qpa.input: libinput: event1 - Logitech USB Receiver Mouse: is tagged by udev as: Mouse qt.qpa.input: libinput: event1 - Logitech USB Receiver Mouse: device is a pointer qt.qpa.input: libinput: event2 - Logitech USB Receiver Consumer Control: is tagged by udev as: Keyboard qt.qpa.input: libinput: event2 - Logitech USB Receiver Consumer Control: device is a keyboard qt.qpa.input: libinput: event3 - Logitech USB Receiver System Control: is tagged by udev as: Keyboard qt.qpa.input: libinput: event3 - Logitech USB Receiver System Control: device is a keyboard qt.qpa.input: Using xkbcommon for key mapping
And this is what I get when I set QT_QPA_EGLFS_NO_LIBINPUT=1
qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_brcm" qt.qpa.input: evdevkeyboard: Using device discovery qt.qpa.input: udev device discovery for type QFlags<QDeviceDiscovery::QDeviceType>(Device_Keyboard) qt.qpa.input: Found matching devices ("/dev/input/event4", "/dev/input/event0", "/dev/input/event2", "/dev/input/event3") qt.qpa.input: Adding keyboard at "/dev/input/event4" qt.qpa.input: Try to create keyboard handler for "/dev/input/event4" "" qt.qpa.input: Opening keyboard at "/dev/input/event4" qt.qpa.input: Create keyboard handler with for device "/dev/input/event4" qt.qpa.input: Unload current keymap and restore built-in qt.qpa.input: numlock=0 , capslock=0, scrolllock=0 qt.qpa.input: Adding keyboard at "/dev/input/event0" qt.qpa.input: Try to create keyboard handler for "/dev/input/event0" "" qt.qpa.input: Opening keyboard at "/dev/input/event0" qt.qpa.input: Create keyboard handler with for device "/dev/input/event0" qt.qpa.input: Unload current keymap and restore built-in qt.qpa.input: numlock=0 , capslock=0, scrolllock=0 qt.qpa.input: Adding keyboard at "/dev/input/event2" qt.qpa.input: Try to create keyboard handler for "/dev/input/event2" "" qt.qpa.input: Opening keyboard at "/dev/input/event2" qt.qpa.input: Create keyboard handler with for device "/dev/input/event2" qt.qpa.input: Unload current keymap and restore built-in qt.qpa.input: numlock=0 , capslock=0, scrolllock=0 qt.qpa.input: Adding keyboard at "/dev/input/event3" qt.qpa.input: Try to create keyboard handler for "/dev/input/event3" "" qt.qpa.input: Opening keyboard at "/dev/input/event3" qt.qpa.input: Create keyboard handler with for device "/dev/input/event3" qt.qpa.input: Unload current keymap and restore built-in qt.qpa.input: numlock=0 , capslock=0, scrolllock=0 qt.qpa.input: evdevmouse: Using device discovery qt.qpa.input: udev device discovery for type QFlags<QDeviceDiscovery::QDeviceType>(Device_Mouse|Device_Touchpad) qt.qpa.input: Found matching devices ("/dev/input/event1") qt.qpa.input: Adding mouse at "/dev/input/event1" qt.qpa.input: create mouse handler for "/dev/input/event1" "" qt.qpa.input: evdevtouch: Using device discovery qt.qpa.input: udev device discovery for type QFlags<QDeviceDiscovery::QDeviceType>(Device_Touchpad|Device_Touchscreen) qt.qpa.input: Found matching devices ()
-
I've found some more environment variables that should help config the XKBCommon behaviour:
export XKB_LOG_LEVEL=50 export XKB_LOG_VERBOSITY=10 export XKB_DEFAULT_MODEL=logicd export XKB_DEFAULT_LAYOUT=br export XKB_DEFAULT_VARIANT=abnt2 export XKB_DEFAULT_OPTIONS=lv3:ralt_switch export QT_LOGGING_RULES=qt.qpa.*=true
I got more information about what is being loaded and the keyboard layout seems to match what I press but the diacritics dead-keys don't work at all to compose or to just output them.
Here are the logs I get running with those options above:
qt.qpa.input: libinput: event0 - Logitech USB Receiver: is tagged by udev as: Keyboard qt.qpa.input: libinput: event0 - Logitech USB Receiver: device is a keyboard qt.qpa.input: libinput: event1 - Logitech USB Receiver Mouse: is tagged by udev as: Mouse qt.qpa.input: libinput: event1 - Logitech USB Receiver Mouse: device is a pointer qt.qpa.input: libinput: event2 - Logitech USB Receiver Consumer Control: is tagged by udev as: Keyboard qt.qpa.input: libinput: event2 - Logitech USB Receiver Consumer Control: device is a keyboard qt.qpa.input: libinput: event3 - Logitech USB Receiver System Control: is tagged by udev as: Keyboard qt.qpa.input: libinput: event3 - Logitech USB Receiver System Control: device is a keyboard qt.qpa.input: Using xkbcommon for key mapping xkbcommon: DEBUG: Compiling from RMLVO: rules 'evdev', model 'logicd', layout 'br', variant 'abnt2', options 'lv3:ralt_switch' xkbcommon: DEBUG: Compiling from KcCGST: keycodes 'evdev+aliases(qwerty)', types 'complete', compat 'complete', symbols 'pc+br(abnt2)+inet(evdev)+level3(ralt_switch)' xkbcommon: DEBUG: Compiling xkb_keycodes "(unnamed)" xkbcommon: DEBUG: Compiling xkb_types "(unnamed)" xkbcommon: DEBUG: Compiling xkb_compatibility "(unnamed)" xkbcommon: DEBUG: The "group" statement in compat is unsupported; Ignored xkbcommon: DEBUG: The "group" statement in compat is unsupported; Ignored xkbcommon: DEBUG: The "group" statement in compat is unsupported; Ignored xkbcommon: DEBUG: The "allowExplicit" field in indicator statements is unsupported; Ignored xkbcommon: DEBUG: The "allowExplicit" field in indicator statements is unsupported; Ignored xkbcommon: DEBUG: The "allowExplicit" field in indicator statements is unsupported; Ignored xkbcommon: DEBUG: The "allowExplicit" field in indicator statements is unsupported; Ignored xkbcommon: DEBUG: The "indicatorDrivesKeyboard" field in indicator statements is unsupported; Ignored xkbcommon: DEBUG: The "allowExplicit" field in indicator statements is unsupported; Ignored xkbcommon: DEBUG: Indicator name "Shift Lock" was not declared in the keycodes section; Adding new indicator xkbcommon: DEBUG: Indicator name "Group 2" was not declared in the keycodes section; Adding new indicator xkbcommon: DEBUG: Indicator name "Mouse Keys" was not declared in the keycodes section; Adding new indicator xkbcommon: DEBUG: Compiling xkb_symbols "(unnamed)" xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <TLDE>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <TLDE>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AE02>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AE03>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AE04>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AE04>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AE05>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <AE06>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AE06>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AE06>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AE12>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AD01>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AD01>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AD02>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AD02>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AD03>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AD03>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AD04>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <AD11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <AD11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AD11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AD11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <AD12>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <AD12>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AD12>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <BKSL>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <BKSL>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <BKSL>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <BKSL>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <AC10>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <AC10>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <AC11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <AC11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AC11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AC11>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <AB03>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <AB07>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <AB10>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <AB10>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <BKSL>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <BKSL>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <LSGT>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <LSGT>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 3/group 1 on key <LSGT>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 4/group 1 on key <LSGT>; Using from, ignoring to xkbcommon: WARNING: Multiple symbols for level 2/group 1 on key <KPDL>; Using from, ignoring to xkbcommon: WARNING: Multiple definitions for group 1 type of key <RALT>; Using ONE_LEVEL, ignoring TWO_LEVEL xkbcommon: WARNING: Multiple symbols for level 1/group 1 on key <RALT>; Using from, ignoring to xkbcommon: WARNING: Type "ONE_LEVEL" has 1 levels, but <RALT> has 2 levels; Ignoring extra symbols xkbcommon: WARNING: Key <OUTP> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <KITG> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <KIDN> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <KIUP> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <RO> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <I192> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <I193> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <I194> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <I195> not found in keycodes; Symbols ignored xkbcommon: WARNING: Key <I196> not found in keycodes; Symbols ignored xkbcommon: INFO: No symbols defined for <JPCM> xkbcommon: INFO: No symbols defined for <I120> xkbcommon: INFO: No symbols defined for <AE13> xkbcommon: INFO: No symbols defined for <I149> xkbcommon: INFO: No symbols defined for <I154> xkbcommon: INFO: No symbols defined for <I168> xkbcommon: INFO: No symbols defined for <I178> xkbcommon: INFO: No symbols defined for <I183> xkbcommon: INFO: No symbols defined for <I184> xkbcommon: INFO: No symbols defined for <FK19> xkbcommon: INFO: No symbols defined for <FK24> xkbcommon: INFO: No symbols defined for <I217> xkbcommon: INFO: No symbols defined for <I219> xkbcommon: INFO: No symbols defined for <I221> xkbcommon: INFO: No symbols defined for <I222> xkbcommon: INFO: No symbols defined for <I230> xkbcommon: INFO: No symbols defined for <I247> xkbcommon: INFO: No symbols defined for <I248> xkbcommon: INFO: No symbols defined for <I249> xkbcommon: INFO: No symbols defined for <I250> xkbcommon: INFO: No symbols defined for <I251> xkbcommon: INFO: No symbols defined for <I252> xkbcommon: INFO: No symbols defined for <I253> xkbcommon: WARNING: Key "Alt_R" not found in symbol map; Modifier map entry for Mod1 not updated xkbcommon: WARNING: Key "Meta_R" not found in symbol map; Modifier map entry for Mod1 not updated
-
I've might have stumbled upon some bugs:
https://bugreports.qt.io/browse/QTBUG-42181
https://bugreports.qt.io/browse/QTBUG-48657
https://bugreports.qt.io/browse/QTBUG-53663
https://bugreports.qt.io/browse/QTBUG-54792
https://bugreports.qt.io/browse/QTBUG-59378
https://bugreports.qt.io/browse/QTBUG-56452
https://codereview.qt-project.org/c/qt/qtbase/+/207231
https://codereview.qt-project.org/c/qt/qtbase/+/98062Some were fixed on 5.13, but the other is only on dev branch... guess I'll be compiling stuff through the night.
-
I eventually found out that those changes mentioned in the links in the last post require you to set "QT_IM_MODULE=compose" but even then composing didn't work.
That being the case, I've reported a bug: https://bugreports.qt.io/browse/QTBUG-79097
I'm keeping this as unanswered until there is a workaround or a fix, but if you do not need dead keys or composition, just setting the XKB_DEFAULT vars and ensuring you are using libinput/xkbcommon should be enough to get your keyboard layout "working".