Qt Embedded for Linux. Keyboard layout switching

自闭症网瘾萝莉.ら 提交于 2019-11-29 11:28:30

Version 4.6 has gained keymap support. Solution:

  1. generate kmap file:

    ckbcomp -layout xx > xx.kmap

  2. convert kmap to qmap

    kmap2qmap xx.kmap xx.qmap

  3. load keymap either by

    1. specifying QWS_KEYBOARD environment variable:

      QWS_KEYBOARD="TTY:keymap=xx.qmap"

    2. or loading a keymap dynamically:

      QWSKeyboardHandler * currentKeyboardHandler =
          QKbdDriverFactory::create("TTY", "keymap=foo.qmap");
      

      Make sure that you delete created handler when you create a new one:

      delete currentKeyboardHandler;
      currentKeyboardHandler =
          QKbdDriverFactory::create("TTY", "keymap=bar.qmap");
      

Seems like Qt for Embedded linux is superseeded by Project Lighthouse. Not sure though, if it is production ready, neither I know how does it handle keyboard layout switching.

Update

Qt5 doesn't have QWS and all QWS-related APIs are removed. So you'll need some thirdparty solution. Or write a plugin for QPA.

I need a way to type non-US characters

You can change qmap, but even in Qt 4.8.0 there is no way to switch between US and russian (for example). You need to patch kmap2qmap (add AltGr_Lock support), qkbd_qws.cpp (change testmods according to state of AltGr_Lock). It's looks like no one is used QtEmbedded with keyboard. Or all keeps final patches in secret place.

Can't comment, so this is the answer to

You need to patch kmap2qmap (add AltGr_Lock support), qkbd_qws.cpp (change testmods according to state of AltGr_Lock).

This simple patch to qkbd_qws.cpp enables switch beteewn languages by the CapsLock button.

523,526c523,524
<             //if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter))
<             //    testmods ^= QWSKeyboard::ModShift;
<             if (d->m_locks[0] /*CapsLock*/)
<                 testmods ^= QWSKeyboard::ModAltGr;
---
>             if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter))
>                 testmods ^= QWSKeyboard::ModShift;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!