qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Bug in SDL key event processing
@ 2008-07-09 23:27 Tomas Carnecky
  2008-07-09 23:37 ` Samuel Thibault
  0 siblings, 1 reply; 30+ messages in thread
From: Tomas Carnecky @ 2008-07-09 23:27 UTC (permalink / raw)
  To: qemu-devel

I just spend half day figuring out why my arrow keys and some other keys 
wouldn't work inside of the guest OS. Turns out you have a capital error 
in your SDL keyboard event parsing code.

Once the event hits sdl_process_key(), the function converts the event 
to a keycode. That depends on whether a keyboard layout has been loaded 
(-k en-us) or not. If not, it calls into sdl_keyevent_to_keycode() which 
  uses the SDL keyboard event scancode (presumably the X11 keycode) and 
converts it to keycodes that are then sent to the guest OS. The problem 
is that you assume a fixed layout of the X11 'scancodes', and use a 
table (x_keycode_to_pc_keycode) to convert those. Well, my xserver 
generates keycode=111 for the 'Up' key, which then your code translated 
to 'Print'. I tried changing the keymap files, but it didn't make any 
difference since qemu doesn't use those if no layout has been selected 
using the '-k' switch. If I load the en-use keymap, all keys work as 
expected.

Why is there OS (X11/Windows) specific code in the SDL frontend? And why 
does qemu need keymaps anyway? I would expect qemu to translate my 
keypresses to corresponding bios scancodes and do no further processing. 
  If you do that, you won't need the keymaps code, just a table to 
translate from SDL events to bios scancodes. For that you'd need just 
one table, holding ~322 elements. That's how many keysyms are defined in 
SDL.

tom

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: [Qemu-devel] Bug in SDL key event processing
@ 2008-07-10 14:22 Juergen Keil
  0 siblings, 0 replies; 30+ messages in thread
From: Juergen Keil @ 2008-07-10 14:22 UTC (permalink / raw)
  To: qemu-devel


> QEMU assumes that the xserver uses the xfree86 model. See files in 
> /usr/share/X11/xkb/keycodes/, especially 'xfree86' and 'evdev'. The 
> files translate from scancodes that the drivers generate into xserver 
> keycodes. The xfree86 file has '<UP> = 98', meaning that if the xkb 
> driver generates 98 it means the user pressed the UP key. When QEMU uses 
> `98 - 97` as the index into the x_keycode_to_pc_keycode table, which 
> yields the correct Up scancode. But the 'evdev' keycode file in the xkb 
> directory has '<UP> = 111', meaning that the evdev driver generates 
> keycode 111 for the UP key.
> 
> Again, you _can not_ assume that the X keycode (XKeyEvent.keycode or 
> SDL_KeyboardEvent.scancode) has any particular meaning. If you run on 
> pure X11, you have to translate it into a keysym (XKeycodeToKeysym()) 
> and use that instead. If you run on SDL, you have to use keysym.sym.
> 
> Am I the only one who uses the evdev driver and runs QEMU? I can't 
> believe that.

Yes, the same issue exists when displaying to a non-Xorg server,
e.g. the Xsun server on a Solaris/SPARC.

With an US English layout keyboard on the Solaris/SPARC machine,
I get keycode 27 in xev (which translates to keysym 0xff52, "Up").

Qemu's sdl keyboard layout is broken when displaying to Xsun, unless I 
use "-k en-us".

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2008-07-14 16:27 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-09 23:27 [Qemu-devel] Bug in SDL key event processing Tomas Carnecky
2008-07-09 23:37 ` Samuel Thibault
2008-07-09 23:46   ` Tomas Carnecky
2008-07-09 23:55     ` Samuel Thibault
2008-07-10  0:09       ` Tomas Carnecky
2008-07-10  0:20         ` Samuel Thibault
2008-07-10  3:19         ` Anthony Liguori
2008-07-10  7:56           ` Tomas Carnecky
2008-07-10 13:35             ` Anthony Liguori
2008-07-10 13:43               ` Tomas Carnecky
2008-07-10 13:56                 ` Anthony Liguori
2008-07-10 14:03                 ` Tomas Carnecky
2008-07-10 14:10                   ` Samuel Thibault
2008-07-10 14:20                     ` Tomas Carnecky
2008-07-10 14:49                       ` Samuel Thibault
2008-07-10 14:39                   ` Anthony Liguori
2008-07-10 15:35                     ` Tomas Carnecky
2008-07-10 15:51                       ` Samuel Thibault
2008-07-10 19:25                       ` Anthony Liguori
2008-07-10 19:51                         ` Tomas Carnecky
2008-07-10 21:55                         ` Samuel Thibault
2008-07-10 22:03                           ` Anthony Liguori
2008-07-10 22:14                             ` Samuel Thibault
2008-07-14 16:02                           ` Ian Jackson
2008-07-14 16:27                             ` Samuel Thibault
2008-07-14 16:01                         ` Ian Jackson
2008-07-09 23:52   ` Anthony Liguori
2008-07-10 12:03     ` Jamie Lokier
2008-07-10 12:24       ` Samuel Thibault
  -- strict thread matches above, loose matches on Subject: below --
2008-07-10 14:22 Juergen Keil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).