F1ash / qt-virt-manager

Qt Virtual machines manager
http://f1ash.github.io/qt-virt-manager
GNU General Public License v2.0
239 stars 70 forks source link

Improve support for keyboards, especially for keypad/numlock and different layouts like with umlauts #34

Open rapgro opened 6 years ago

rapgro commented 6 years ago

Working on a new implementation for converting QKey to SPICE. SPICE needs valid scan codes from code table of PC AT key codes set number 1.

[Samstag, 7. April 2018] [08:59:49 CEST] <RaphGro>  maybe I can explain the issue with scancodes
[Samstag, 7. April 2018] [08:59:52 CEST] Betreten   kalev-afk (~kalev@81-229-202-110-no287.tbcn.telia.com) hat diesen Kanal betreten.
[Samstag, 7. April 2018] [09:00:31 CEST] <flash__>  good
[Samstag, 7. April 2018] [09:00:50 CEST] <RaphGro>  but I tried to refactor the sources, not easy
[Samstag, 7. April 2018] [09:01:59 CEST] <RaphGro>  well, the scancode for numlock is wrong
[Samstag, 7. April 2018] [09:02:05 CEST] <flash__>  maybe say the idea ?
[Samstag, 7. April 2018] [09:02:15 CEST] <RaphGro>  still no idea about umlauts
[Samstag, 7. April 2018] [09:02:44 CEST] <RaphGro>  have to send scancodes as 4 bytes array = uint32
[Samstag, 7. April 2018] [09:02:50 CEST] <RaphGro>  just shift the bytes to the left
[Samstag, 7. April 2018] [09:02:56 CEST] <RaphGro>  I have ready code
[Samstag, 7. April 2018] [09:04:00 CEST] <RaphGro>  but it will break keypad (keypad/numlock is b0rken anyways) and will break alt+gr as well and key sequence
[Samstag, 7. April 2018] [09:04:29 CEST] <RaphGro>  writing keyboard driver is not easy :(
[Samstag, 7. April 2018] [09:06:37 CEST] <flash__>  you shure that it will works on any keyboard?  and why need shift bytes order? if exist some rule?
[Samstag, 7. April 2018] [09:06:51 CEST] <flash__>  or exist*
[Samstag, 7. April 2018] [09:08:36 CEST] <RaphGro>  maybe an improvement. but be aware what I wrote above.
[Samstag, 7. April 2018] [09:09:12 CEST] <RaphGro>      // http://doc.qt.io/qt-5/qt.html#Key-enum
[Samstag, 7. April 2018] [09:09:12 CEST] <RaphGro>      // https://github.com/qemu/keycodemapdb/blob/master/data/keymaps.csv
[Samstag, 7. April 2018] [09:09:12 CEST] <RaphGro>      // https://github.com/CendioOssman/keycodemapdb/blob/master/data/keymaps.csv
[Samstag, 7. April 2018] [09:09:25 CEST] <flash__>  on #virt  challel i have answer that virt-viewer uses the https://gitlab.com/keycodemap/keycodemapdb/blob/master/data/keymaps.csv for works with different systems and keyboards... buy how to -- not clear..
[Samstag, 7. April 2018] [09:09:54 CEST] <RaphGro>  PC AT scan codes 1
[Samstag, 7. April 2018] [09:10:04 CEST] <RaphGro>  the numlock implementation is wrong
[Samstag, 7. April 2018] [09:10:14 CEST] <RaphGro>  Qt seems to handle keypad specially
[Samstag, 7. April 2018] [09:11:43 CEST] <RaphGro>  ADD_SCAN4 should maybe use the old code as in git
[Samstag, 7. April 2018] [09:11:51 CEST] Betreten   kallesbar (~kallesbar@192.130.252.52) hat diesen Kanal betreten.
[Samstag, 7. April 2018] [09:12:06 CEST] <RaphGro>  ADD_SCAN4 is used for key sequence
[Samstag, 7. April 2018] [09:13:36 CEST] <RaphGro>  well, I did not try QKeyEvent getScanCode()
[Samstag, 7. April 2018] [09:13:55 CEST] <RaphGro>  documentation says it is not guaranteed to give a number
[Samstag, 7. April 2018] [09:14:29 CEST] <RaphGro>  how to test if it works on any keyboard?
[Samstag, 7. April 2018] [09:15:09 CEST] <flash__>  i'm use that table for set 1: http://philipstorr.id.au/pcbook/book3/scancode.htm
[Samstag, 7. April 2018] [09:15:36 CEST] <RaphGro>  https://stackoverflow.com/questions/17204142/capturing-modifier-keys-qt
[Samstag, 7. April 2018] [09:15:47 CEST] <RaphGro>  you can use mouse button with modifier keys …
[Samstag, 7. April 2018] [09:16:01 CEST] <RaphGro>  but interesting for gamer user
[Samstag, 7. April 2018] [09:16:19 CEST] <RaphGro>  … all in all, keyboard driver is not easy stuff :(
[Samstag, 7. April 2018] [09:17:50 CEST] <RaphGro>  https://stackoverflow.com/questions/24822505/how-to-tell-if-shift-is-pressed-on-numpad-input-with-numlock-on-or-at-least-get
[Samstag, 7. April 2018] [09:19:35 CEST] <RaphGro>  did you check the sources of spice-gtk or gtk viewer?
[Samstag, 7. April 2018] [09:21:11 CEST] <RaphGro>  https://github.com/UPC/ravada/issues/448#issuecomment-379319506
[Samstag, 7. April 2018] [09:21:12 CEST] <flash__>  not for using keyboard...
[Samstag, 7. April 2018] [09:21:25 CEST] <RaphGro>  you should check
rapgro commented 6 years ago

With german keyboard layout in the host system, the keys z and y are still switched. Umlauts (ü, ö ,ä, ß) do not work at all. Other keys without correct mapping: pipe, <, >, ;, : , -, _, *, +,~, ', # , ", §, &, /, (, ), =, ?, `, ´, {,[,],},\, Pos1, End, Ins, Del, PageUp, PageDown Maybe there are more key errors.

rapgro commented 5 years ago

Managed to get a keyboard with UK layout. I'll report if it can improve the translation of key codes.