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
, QueueKeyStateTable
, (LPWORD
)ch
, 0);
35 for (c2
=0; c2
<cnt
; c2
++)
36 INT_Int16AddChar(ch
[c2
], scan
);
39 /* need to handle things like shift-F-keys etc */
40 FIXME("DOS special key translation not implemented\n");
43 DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */
46 static void KbdRelay( LPDOSTASK lpDosTask
, CONTEXT86
*context
, void *data
)
48 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
50 if (sys
&& sys
->queuelen
) {
51 /* cleanup operation, called from DOSVM_PIC_ioport_out:
52 * we'll remove current scancode from keyboard buffer here,
53 * rather than in ReadScan, because some DOS apps depend on
54 * the scancode being available for reading multiple times... */
56 memmove(sys
->queue
,sys
->queue
+1,sys
->queuelen
);
60 void WINAPI
INT_Int09SendScan( BYTE scan
)
62 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
64 sys
= calloc(1,sizeof(KBDSYSTEM
));
65 DOSVM_SetSystemData(0x09,sys
);
67 /* add scancode to queue */
68 sys
->queue
[sys
->queuelen
++] = scan
;
69 /* tell app to read it by triggering IRQ 1 (int 09) */
70 DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD
,KbdRelay
,NULL
);
73 BYTE WINAPI
INT_Int09ReadScan( void )
75 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);