2 * DOS interrupt 09h handler (IRQ1 - KEYBOARD)
10 #include "debugtools.h"
13 DEFAULT_DEBUG_CHANNEL(int)
16 BYTE queuelen
,queue
[15];
19 /**********************************************************************
22 * Handler for int 09h.
24 void WINAPI
INT_Int09Handler( CONTEXT86
*context
)
26 BYTE scan
= INT_Int09ReadScan();
27 UINT vkey
= MapVirtualKeyA(scan
&0x7f, 1);
32 /* as in TranslateMessage, windows/input.c */
33 cnt
= ToAscii(vkey
, scan
&0x7f, QueueKeyStateTable
, (LPWORD
)ch
, 0);
35 FIXME("enter character %c into console input, not implemented\n",ch
[0]);
38 DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */
41 static void KbdRelay( LPDOSTASK lpDosTask
, CONTEXT86
*context
, void *data
)
43 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
45 if (sys
&& sys
->queuelen
) {
46 /* cleanup operation, called from DOSVM_PIC_ioport_out:
47 * we'll remove current scancode from keyboard buffer here,
48 * rather than in ReadScan, because some DOS apps depend on
49 * the scancode being available for reading multiple times... */
51 memmove(sys
->queue
,sys
->queue
+1,sys
->queuelen
);
55 void WINAPI
INT_Int09SendScan( BYTE scan
)
57 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
59 sys
= calloc(1,sizeof(KBDSYSTEM
));
60 DOSVM_SetSystemData(0x09,sys
);
62 /* add scancode to queue */
63 sys
->queue
[sys
->queuelen
++] = scan
;
64 /* tell app to read it by triggering IRQ 1 (int 09) */
65 DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD
,KbdRelay
,NULL
);
68 BYTE WINAPI
INT_Int09ReadScan( void )
70 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);