On Mon, 2 Mar 2020, Daniel P. Berrangé wrote: > There's two translations happening > > * The scancode emitted by the kernel and/or hardware device, > and then translated/mangled by X11 and reported as the > hardware keycode > > * The keysym which is the mapping from the hardware keycode > done by XKB and/or Xmodmap
Yes, sure. > We're dealing with the first point in QEMU, taking the hardware > keycode and trying to undo the X11 mangling that was performed. That’s where VNC often fails, generally, anyway… (asd often get translated back as adf). > > But if I can do anything to help debugging this, sure. > > Can you launch 'xev' inside your VNC session and press the 'Page Up' > button and let me know what it reports the keycode and keysym. Sure. > Specifically I'm interested in this line of text: > > state 0x0, keycode 112 (keysym 0xff55, Prior), same_screen YES, > > On evdev it reports 112 as hardware code which is 0x70 hex, while with > 'kbd' it reports 99 which is 0x63 hex. These are the only two scenarios > QEMU knows how to cope with. Then we’re somewhat out of luck: KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624181177, (244,533), root:(250,560), state 0x0, keycode 71 (keysym 0xff55, Prior), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False I’ve also done a,s,d: KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624183753, (244,533), root:(250,560), state 0x0, keycode 38 (keysym 0x61, a), same_screen YES, XLookupString gives 1 bytes: (61) "a" XmbLookupString gives 1 bytes: (61) "a" XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624184249, (244,533), root:(250,560), state 0x0, keycode 56 (keysym 0x73, s), same_screen YES, XLookupString gives 1 bytes: (73) "s" XmbLookupString gives 1 bytes: (73) "s" XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624184641, (244,533), root:(250,560), state 0x0, keycode 41 (keysym 0x64, d), same_screen YES, XLookupString gives 1 bytes: (64) "d" XmbLookupString gives 1 bytes: (64) "d" XFilterEvent returns: False I’ve tried looking at the sources for x11vnc-0.9.16 and tightvnc-1.3.9 but could not, within a quarter hour at least (got to go…), find out where those codes are mapped anyway other than a reference to XKeysymToKeycode (from libX11 probably). > For that matter, if you have time to help, it would be interesting to > see what it reports for a random selection of other keys too. For > example: > > @ KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624747092, (82,98), root:(88,125), state 0x0, keycode 10 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624747284, (82,98), root:(88,125), state 0x1, keycode 19 (keysym 0x40, at), same_screen YES, XLookupString gives 1 bytes: (40) "@" XmbLookupString gives 1 bytes: (40) "@" XFilterEvent returns: False > # KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624748276, (82,98), root:(88,125), state 0x0, keycode 10 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624748772, (82,98), root:(88,125), state 0x1, keycode 20 (keysym 0x23, numbersign), same_screen YES, XLookupString gives 1 bytes: (23) "#" XmbLookupString gives 1 bytes: (23) "#" XFilterEvent returns: False > $ KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624749620, (82,98), root:(88,125), state 0x0, keycode 10 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624750028, (82,98), root:(88,125), state 0x1, keycode 21 (keysym 0x24, dollar), same_screen YES, XLookupString gives 1 bytes: (24) "$" XmbLookupString gives 1 bytes: (24) "$" XFilterEvent returns: False > ` This one is tricky because on my host keyboard layout ` is on the Escape key while the key left to 1 has Esc (except when shifted, so ~ is Shift plus the key left from 1). This is the physical Escape key, giving `: KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624751028, (82,98), root:(88,125), state 0x0, keycode 33 (keysym 0x60, grave), same_screen YES, XLookupString gives 1 bytes: (60) "`" XmbLookupString gives 1 bytes: (60) "`" XFilterEvent returns: False This is the physical key left to the 1: KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624753908, (82,98), root:(88,125), state 0x0, keycode 67 (keysym 0xff1b, Escape), same_screen YES, XLookupString gives 1 bytes: (1b) "" XmbLookupString gives 1 bytes: (1b) "" XFilterEvent returns: False When I run “setxkbmap us” on the host, I get the following for the physical key left to the 1 (`): KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2625065838, (136,535), root:(142,562), state 0x0, keycode 33 (keysym 0x60, grave), same_screen YES, XLookupString gives 1 bytes: (60) "`" XmbLookupString gives 1 bytes: (60) "`" XFilterEvent returns: False This makes me assume that the VNC viewer+server combination translates back keysyms into keycodes, losing the original scancodes, only based on the keysyms they create in the host keyboard layout. Ouch! > - KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624780388, (101,155), root:(107,182), state 0x0, keycode 27 (keysym 0x2d, minus), same_screen YES, XLookupString gives 1 bytes: (2d) "-" XmbLookupString gives 1 bytes: (2d) "-" XFilterEvent returns: False > + KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624780652, (101,155), root:(107,182), state 0x0, keycode 10 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624781060, (101,155), root:(107,182), state 0x1, keycode 28 (keysym 0x2b, plus), same_screen YES, XLookupString gives 1 bytes: (2b) "+" XmbLookupString gives 1 bytes: (2b) "+" XFilterEvent returns: False > 1 > 2 > 3 KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624781516, (101,155), root:(107,182), state 0x0, keycode 18 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 bytes: (31) "1" XmbLookupString gives 1 bytes: (31) "1" XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624781764, (101,155), root:(107,182), state 0x0, keycode 19 (keysym 0x32, 2), same_screen YES, XLookupString gives 1 bytes: (32) "2" XmbLookupString gives 1 bytes: (32) "2" XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624781988, (101,155), root:(107,182), state 0x0, keycode 20 (keysym 0x33, 3), same_screen YES, XLookupString gives 1 bytes: (33) "3" XmbLookupString gives 1 bytes: (33) "3" XFilterEvent returns: False > a > s > d see above > q > w > e KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624782620, (101,155), root:(107,182), state 0x0, keycode 54 (keysym 0x71, q), same_screen YES, XLookupString gives 1 bytes: (71) "q" XmbLookupString gives 1 bytes: (71) "q" XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624782812, (101,155), root:(107,182), state 0x0, keycode 60 (keysym 0x77, w), same_screen YES, XLookupString gives 1 bytes: (77) "w" XmbLookupString gives 1 bytes: (77) "w" XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624782996, (101,155), root:(107,182), state 0x0, keycode 42 (keysym 0x65, e), same_screen YES, XLookupString gives 1 bytes: (65) "e" XmbLookupString gives 1 bytes: (65) "e" XFilterEvent returns: False > , > . > / KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624783972, (101,155), root:(107,182), state 0x0, keycode 34 (keysym 0x2c, comma), same_screen YES, XLookupString gives 1 bytes: (2c) "," XmbLookupString gives 1 bytes: (2c) "," XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624784172, (101,155), root:(107,182), state 0x0, keycode 35 (keysym 0x2e, period), same_screen YES, XLookupString gives 1 bytes: (2e) "." XmbLookupString gives 1 bytes: (2e) "." XFilterEvent returns: False KeyPress event, serial 35, synthetic NO, window 0x1000001, root 0x25, subw 0x0, time 2624784412, (101,155), root:(107,182), state 0x0, keycode 36 (keysym 0x2f, slash), same_screen YES, XLookupString gives 1 bytes: (2f) "/" XmbLookupString gives 1 bytes: (2f) "/" XFilterEvent returns: False Thanks, //mirabilos -- tarent solutions GmbH Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/ Tel: +49 228 54881-393 • Fax: +49 228 54881-235 HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941 Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg ********** Mit der tarent Academy bieten wir auch Trainings und Schulungen in den Bereichen Softwareentwicklung, Agiles Arbeiten und Zukunftstechnologien an. Besuchen Sie uns auf www.tarent.de/academy. Wir freuen uns auf Ihren Kontakt. **********