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);
31 TRACE("scan=%02x\n",scan
);
33 /* as in TranslateMessage, windows/input.c */
34 cnt
= ToAscii(vkey
, scan
, QueueKeyStateTable
, (LPWORD
)ch
, 0);
36 for (c2
=0; c2
<cnt
; c2
++)
37 INT_Int16AddChar(ch
[c2
], scan
);
40 /* FIXME: need to handle things like shift-F-keys,
41 * 0xE0 extended keys, etc */
42 INT_Int16AddChar(0, scan
);
45 DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */
48 static void KbdRelay( LPDOSTASK lpDosTask
, CONTEXT86
*context
, void *data
)
50 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
52 if (sys
&& sys
->queuelen
) {
53 /* cleanup operation, called from DOSVM_PIC_ioport_out:
54 * we'll remove current scancode from keyboard buffer here,
55 * rather than in ReadScan, because some DOS apps depend on
56 * the scancode being available for reading multiple times... */
58 memmove(sys
->queue
,sys
->queue
+1,sys
->queuelen
);
62 void WINAPI
INT_Int09SendScan( BYTE scan
)
64 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);
66 sys
= calloc(1,sizeof(KBDSYSTEM
));
67 DOSVM_SetSystemData(0x09,sys
);
69 /* add scancode to queue */
70 sys
->queue
[sys
->queuelen
++] = scan
;
71 /* tell app to read it by triggering IRQ 1 (int 09) */
72 DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD
,KbdRelay
,NULL
);
75 BYTE WINAPI
INT_Int09ReadScan( void )
77 KBDSYSTEM
*sys
= (KBDSYSTEM
*)DOSVM_GetSystemData(0x09);