Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BsVrn-0005H9-7B for qemu-devel@nongnu.org; Wed, 04 Aug 2004 20:12:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BsVrm-0005Gx-Oc for qemu-devel@nongnu.org; Wed, 04 Aug 2004 20:12:19 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BsVrm-0005Gu-Lr for qemu-devel@nongnu.org; Wed, 04 Aug 2004 20:12:18 -0400 Received: from [213.238.211.114] (helo=klotjohan.mine.nu) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BsVo9-0007Au-Hy for qemu-devel@nongnu.org; Wed, 04 Aug 2004 20:08:33 -0400 Received: from [192.168.0.6] (omar [192.168.0.6]) by klotjohan.mine.nu (8.12.8/8.12.8) with ESMTP id i7508V0G007434 for ; Thu, 5 Aug 2004 02:08:31 +0200 Date: Thu, 05 Aug 2004 02:08:32 +0200 From: Erik Karlsson Subject: Re: [Qemu-devel] Keyboard patch for windows In-Reply-To: <41114F09.3030903@bellard.org> References: <20040804103148.10A7.ERIK.KARLSSON@bonetmail.com> <41114F09.3030903@bellard.org> Message-Id: <20040805020112.71D3.ERIK.KARLSSON@bonetmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 No, is does not work because the scancode in SDL is 8 bits. So when SDL sets the scancode to HIWORD(lParam) only bits 16-23 goes into the scancode. And there is still two more problems with using SDL that i have not mentioned yet. These problems are not caused directly by SDL. They are cauesd by some weird semantics of windows keyboard messges. 1) The shift up problem When both left and right shift keys are down and you release one of the shift keys no WM_KEYUP message is sent. For example: press left shift -> WM_KEYDOWN left shift press right shift -> WM_KEYDOWN right shift release left shift -> no message release right shift -> WM_KEYUP reight shift The result is that shift keys get stuck down in the guest OS when you are pressing both shift keys simultaneously. 2) The Alt-Gr problem When you press Alt-Gr windows atomatially generates a left control message befor sending the right alt message. These automatically ctrl presses must not be forwarded to the guest os. The only way I have found to avoid these two problems is using low level keyboard hooks (maybe Direct Input will work too). Using windows messages natively or pathing SDL's windows message handling will not work. The bottom line is that SDL is not an option if you want working keyboard support on windows. Erik > From the windows API it seems that the bit 24 of lParam in the message > WM_KEYDOWN contains what you want. From the SDL source code, it seems to > be passed in the scancode field... > > Fabrice. > > Erik Karlsson wrote: > > The problem is that some of the keycodes are prefixed with an e0 prefix. > > > > Examples: > > Numpad right arrow/6: 4d Right arrow: e0,4d > > Numpad left arrow/4: 4b Left arrow: e0,4b > > Left alt: 38 Right alt: e0,38 > > Left control: 1d Right control: e0,1d > > > > The problem withs SDL is that SDL strips off the e0 prefix. The result > > is that it is impossible to distinguish between e.g. the arrow keys and > > the arrow on the numeric keypad and between left and right alt and > > contol keys. > > > > Another advantage with low level keyboard hooks is that you can capture > > system key combinations such as Alt-Tab and Ctrl-Esc. sdl_grab_start() > > does not do that on windows. > > > > I agree that it is unclean to have native windows code in an SDL driver. > > It would of course be better to have a separate keyboard driver for > > windows. The problem is that the qemu architecture does not allow > > separate drivers for keyboard, mouse and display. This makes a windows > > driver just for the keybord impossible. A windows driver would then need > > to implement keyboard, mouse and display natively on windows. > > > > Erik