From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KGj5I-0003sy-JI for qemu-devel@nongnu.org; Wed, 09 Jul 2008 19:28:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KGj5A-0003ii-Ge for qemu-devel@nongnu.org; Wed, 09 Jul 2008 19:28:22 -0400 Received: from [199.232.76.173] (port=55622 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGj56-0003iU-7k for qemu-devel@nongnu.org; Wed, 09 Jul 2008 19:28:16 -0400 Received: from dbservice.com ([213.239.204.14]:39131 helo=matterhorn.dbservice.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KGj55-0003V2-Q0 for qemu-devel@nongnu.org; Wed, 09 Jul 2008 19:28:16 -0400 Received: from [192.168.0.27] (gw.ptr-62-65-141-13.customer.ch.netstream.com [62.65.141.13]) by matterhorn.dbservice.com (Postfix) with ESMTP id 6C02F20BB3C6 for ; Thu, 10 Jul 2008 01:28:04 +0200 (CEST) Message-ID: <48754975.1050303@dbservice.com> Date: Thu, 10 Jul 2008 01:27:49 +0200 From: Tomas Carnecky MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Bug in SDL key event processing Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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