2 * DOS interrupt 09h handler (IRQ1 - KEYBOARD)
13 #include "debugtools.h"
16 DEFAULT_DEBUG_CHANNEL(int);
22 BYTE queuelen
,queue
[QUEUELEN
],ascii
[QUEUELEN
];
26 /**********************************************************************
29 * Handler for int 09h.
31 void WINAPI
INT_Int09Handler( CONTEXT86
*context
)
33 BYTE ascii
, scan
= INT_Int09ReadScan(&ascii
);
37 TRACE("scan=%02x\n",scan
);
40 /* we already have an ASCII code, no translation necessary */
44 #if 0 /* FIXME: cannot call USER functions here */
45 UINT vkey
= MapVirtualKeyA(scan
&0x7f, 1);
46 /* as in TranslateMessage, windows/input.c */
47 cnt
= ToAscii(vkey
, scan
, QueueKeyStateTable
, (LPWORD
)ch
, 0);
53 for (c2
=0; c2
<cnt
; c2
++)
54 INT_Int16AddChar(ch
[c2
], scan
);
57 /* FIXME: need to handle things like shift-F-keys,
58 * 0xE0 extended keys, etc */
59 INT_Int16AddChar(0, scan
);
62 DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */
65 static void KbdRelay( CONTEXT86
*context
, void *data
)
67 if (kbdinfo
.queuelen
) {
68 /* cleanup operation, called from DOSVM_PIC_ioport_out:
69 * we'll remove current scancode from keyboard buffer here,
70 * rather than in ReadScan, because some DOS apps depend on
71 * the scancode being available for reading multiple times... */
72 if (--kbdinfo
.queuelen
) {
73 memmove(kbdinfo
.queue
,kbdinfo
.queue
+1,kbdinfo
.queuelen
);
74 memmove(kbdinfo
.ascii
,kbdinfo
.ascii
+1,kbdinfo
.queuelen
);
79 void WINAPI
INT_Int09SendScan( BYTE scan
, BYTE ascii
)
81 if (kbdinfo
.queuelen
== QUEUELEN
) {
82 ERR("keyboard queue overflow\n");
85 /* add scancode to queue */
86 kbdinfo
.queue
[kbdinfo
.queuelen
] = scan
;
87 kbdinfo
.ascii
[kbdinfo
.queuelen
++] = ascii
;
88 /* tell app to read it by triggering IRQ 1 (int 09) */
89 DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD
,KbdRelay
,NULL
);
92 BYTE WINAPI
INT_Int09ReadScan( BYTE
*ascii
)
94 if (ascii
) *ascii
= kbdinfo
.ascii
[0];
95 return kbdinfo
.queue
[0];