[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Keyboard patch for windows

From: Erik Karlsson
Subject: Re: [Qemu-devel] Keyboard patch for windows
Date: Thu, 05 Aug 2004 02:08:32 +0200

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

The bottom line is that SDL is not an option if you want working
keyboard support on windows.


>  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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]