[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] qemu kbd emulation
From: |
Rafał Cygnarowski |
Subject: |
[Qemu-devel] qemu kbd emulation |
Date: |
Wed, 28 Jun 2006 10:27:31 +0200 |
User-agent: |
KMail/1.9.1 |
Hi!
I wanted to correct qemu emulation of keyboard under DOS as
guest OS, so I started with simple pascal program to check
what happen on guest DOS (and DOS) when I press up/down/left/right
keys.
The program was:
-- BEGIN test.pas --
program time; {$M 2048,0,0}
uses crt, dos;
var OldKeyInt : procedure;
procedure NewKeyInt; interrupt;
begin
write(Port[$60]); write(' ')
inline($9c); OldKeyInt;
end;
begin
getintvec($9, addr(OldKeyInt));
setintvec($9, @NewKeyInt);
keep(0);
end.
-- END test.pas --
and it look that qemu does not generate some codes before
pressing and after releasing arrow keys. For example pressing
up key on qemu looks like:
224 72 224 200
while without emulation it looks:
224 42 224 72 224 200 224 170.
It's true only for single keystrokes, but good for the
beginning.
So I tried to patch qemu for this and created following patch:
-- BEGIN sdl.patch --
--- sdl.c.old 2006-05-03 20:32:58.000000000 +0000
+++ sdl.c 2006-06-28 07:26:14.000000000 +0000
@@ -254,14 +254,34 @@
kbd_put_keycode(keycode);
kbd_put_keycode(keycode | 0x80);
return;
+ case 0xc8: /* up */
+ case 0xd0: /* down */
+ case 0xcd: /* right */
+ case 0xcb: /* left */
+ if (ev->type != SDL_KEYUP) {
+ kbd_put_keycode(e0);
+ kbd_put_keycode(2a);
+ }
+ break;
}
-
+
/* now send the key code */
if (keycode & 0x80)
kbd_put_keycode(0xe0);
- if (ev->type == SDL_KEYUP)
- kbd_put_keycode(keycode | 0x80);
- else
+
+ if (ev->type == SDL_KEYUP) {
+ kbd_put_keycode(keycode | 0x80);
+
+ switch(keycode) {
+ case 0xc8: /* up */
+ case 0xd0: /* down */
+ case 0xcd: /* right */
+ case 0xcb: /* left */
+ kbd_put_keycode(0xe0);
+ kbd_put_keycode(0xaa);
+ break;
+ }
+ } else
kbd_put_keycode(keycode & 0x7f);
}
-- END sdl.patch --
Unfortunatelly results of this patch completely suprised me. After this patch
my test program produces results witch are impossible to produce in normal
situation. Example output for UP key was:
224 224 72 88224 224 170.
What's wrong with this patch? What I'm doing wrong?
Regards,
--
Rafał Cygnarowski
address@hidden