2 * DOS interrupt 09h handler (IRQ1 - KEYBOARD)
12 #include "debugtools.h"
15 DEFAULT_DEBUG_CHANNEL(int)
18 BYTE queuelen
,queue
[15];
21 /**********************************************************************
24 * Handler for int 09h.
26 void WINAPI
INT_Int09Handler( CONTEXT86
*context
)
28 BYTE scan
= INT_Int09ReadScan();
29 UINT vkey
= MapVirtualKeyA(scan
&0x7f, 1);
33 TRACE("scan=%02x\n",scan
);
35 /* as in TranslateMessage, windows/input.c */
36 cnt
= ToAscii(vkey
, scan
, QueueKeyStateTable
, (LPWORD
)ch
, 0);
38 for (c2
=0; c2
<cnt
; c2
++)
39 INT_Int16AddChar(ch
[c2
], scan
);
42 /* FIXME: need to handle things like shift-F-keys,
43 * 0xE0 extended keys, etc */
44 INT_Int16AddChar(0, scan
);
47 DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */
50 static void KbdRelay( LPDOSTASK lpDosTask
, CONTEXT86
*context
, void *data
)
52 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
54 if (sys
&& sys
->queuelen
) {
55 /* cleanup operation, called from DOSVM_PIC_ioport_out:
56 * we'll remove current scancode from keyboard buffer here,
57 * rather than in ReadScan, because some DOS apps depend on
58 * the scancode being available for reading multiple times... */
60 memmove(sys
->queue
,sys
->queue
+1,sys
->queuelen
);
64 void WINAPI
INT_Int09SendScan( BYTE scan
)
66 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
68 sys
= calloc(1,sizeof(KBDSYSTEM
));
69 DOSVM_SetSystemData(0x09,sys
);
71 /* add scancode to queue */
72 sys
->queue
[sys
->queuelen
++] = scan
;
73 /* tell app to read it by triggering IRQ 1 (int 09) */
74 DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD
,KbdRelay
,NULL
);
77 BYTE WINAPI
INT_Int09ReadScan( void )
79 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);