0

I need to a keymap for my embedded QWSServer application.

Using environmental variables like this

QWS_KEYBOARD="TTY:keymap=/german_keyboard.qmap"
export QWS_KEYBOARD

works, but isn't optimal for me.

I tried to set it from code using

QWSServer* wsServer = QWSServer::instance();
QWSKeyboardHandler * kh = QKbdDriverFactory::create("TTY", "keymap=/german_keymap.qmap");
wsServer->setKeyboardHandler(kh);

as mentioned here.

However, it is not working. Any ideas how to fix it?

Community
  • 1
  • 1
Zulakis
  • 7,859
  • 10
  • 42
  • 67

2 Answers2

2

It actually looks like you couldn't do it. According to this manual page you can only set the driver and device for a keyboard handler, but no additional options like keymap. In this arcticle about the keymap thing only the environment variable way ist mentioned, too.

Because of this, the answer here seems to be wrong.

Beware: According to this answer, Qt5 doesn't have QWS and all QWS-related APIs have been removed.

Community
  • 1
  • 1
Zulakis
  • 7,859
  • 10
  • 42
  • 67
  • Unfortunately your first and second links are dead. Do you have new ones? – Alex Oct 08 '14 at 08:28
  • Thanks for updating the links. So, did you get keymap changing to work? The tutorials are severly lacking in regards of working example code. Anyone who can make it work without getting tutored by real-life Qt-employees, just by reading the class documentation, must be a real genius imho. – Alex Nov 03 '14 at 08:19
  • Nope, I only managed to use one keymap all the time, I couldn't get the changing to work. – Zulakis Nov 03 '14 at 12:32
  • Ok. Then what did you do to set that one keymap? – Alex Nov 03 '14 at 16:48
  • `export QWS_KEYBOARD="TTY:keymap=/usr/share/qt/german_keymap.qmap"` before starting the gui. – Zulakis Nov 03 '14 at 19:59
  • That's all? Cool, I'll try that. Thanks! – Alex Nov 04 '14 at 13:50
  • 1
    Unfortunately it didn't work as easy as that. I ran a programm that invoked "system("export QWS_KEYBOARD=\"TTY:keymap=/usr/de.qmap\"");" and way later my GUI starts up, but the keyboard layout doesn't change. The system command returned 0. Is there a trick to this? – Alex Nov 05 '14 at 14:10
0

You can try:

QWSServer::instance()->closeKeyboard();
QWSKeyboardHandler * kh = QKbdDriverFactory::create("TTY", "keymap=/german_keymap.qmap");

It works for me, but only the first time, if I want to change the layout a second time, the closeKeyboard() will crash, as it's trying to delete the driver defined by QWS_KEYBOARD, and it has already been deleted the first time.

Sylvain V
  • 194
  • 1
  • 7