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
DOSVM_Int09Handler( CONTEXT86
*context
)
33 BYTE ascii
, scan
= DOSVM_Int09ReadScan(&ascii
);
37 TRACE("scan=%02x\n",scan
);
40 /* we already have an ASCII code, no translation necessary */
44 UINT vkey
= MapVirtualKeyA(scan
&0x7f, 1);
46 GetKeyboardState(keystate
);
47 cnt
= ToAscii(vkey
, scan
, keystate
, (LPWORD
)ch
, 0);
50 for (c2
=0; c2
<cnt
; c2
++)
51 DOSVM_Int16AddChar(ch
[c2
], scan
);
54 /* FIXME: need to handle things like shift-F-keys,
55 * 0xE0 extended keys, etc */
56 DOSVM_Int16AddChar(0, scan
);
59 DOSVM_PIC_ioport_out( 0x20, 0x20 ); /* send EOI */
62 static void KbdRelay( CONTEXT86
*context
, void *data
)
64 if (kbdinfo
.queuelen
) {
65 /* cleanup operation, called from DOSVM_PIC_ioport_out:
66 * we'll remove current scancode from keyboard buffer here,
67 * rather than in ReadScan, because some DOS apps depend on
68 * the scancode being available for reading multiple times... */
69 if (--kbdinfo
.queuelen
) {
70 memmove(kbdinfo
.queue
,kbdinfo
.queue
+1,kbdinfo
.queuelen
);
71 memmove(kbdinfo
.ascii
,kbdinfo
.ascii
+1,kbdinfo
.queuelen
);
76 void WINAPI
DOSVM_Int09SendScan( BYTE scan
, BYTE ascii
)
78 if (kbdinfo
.queuelen
== QUEUELEN
) {
79 ERR("keyboard queue overflow\n");
82 /* add scancode to queue */
83 kbdinfo
.queue
[kbdinfo
.queuelen
] = scan
;
84 kbdinfo
.ascii
[kbdinfo
.queuelen
++] = ascii
;
85 /* tell app to read it by triggering IRQ 1 (int 09) */
86 DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD
,KbdRelay
,NULL
);
89 /**********************************************************************
90 * KbdReadScan (WINEDOS.@)
92 BYTE WINAPI
DOSVM_Int09ReadScan( BYTE
*ascii
)
94 if (ascii
) *ascii
= kbdinfo
.ascii
[0];
95 return kbdinfo
.queue
[0];