Check, Radio & 3State buttons send WM_CTLCOLORSTATIC instead of
[wine/multimedia.git] / dlls / winedos / int09.c
blob96f65e4faf2fe87c54d235fb86007a67085333f9
1 /*
2 * DOS interrupt 09h handler (IRQ1 - KEYBOARD)
3 */
5 #include <stdlib.h>
6 #include <string.h>
8 #include "windef.h"
9 #include "winbase.h"
10 #include "wingdi.h"
11 #include "winuser.h"
12 #include "miscemu.h"
13 #include "debugtools.h"
14 #include "dosexe.h"
16 DEFAULT_DEBUG_CHANNEL(int);
18 #define QUEUELEN 31
20 static struct
22 BYTE queuelen,queue[QUEUELEN],ascii[QUEUELEN];
23 } kbdinfo;
26 /**********************************************************************
27 * DOSVM_Int09Handler
29 * Handler for int 09h.
31 void WINAPI DOSVM_Int09Handler( CONTEXT86 *context )
33 BYTE ascii, scan = DOSVM_Int09ReadScan(&ascii);
34 BYTE ch[2];
35 int cnt, c2;
37 TRACE("scan=%02x\n",scan);
38 if (!(scan & 0x80)) {
39 if (ascii) {
40 /* we already have an ASCII code, no translation necessary */
41 ch[0] = ascii;
42 cnt = 1;
43 } else {
44 UINT vkey = MapVirtualKeyA(scan&0x7f, 1);
45 BYTE keystate[256];
46 GetKeyboardState(keystate);
47 cnt = ToAscii(vkey, scan, keystate, (LPWORD)ch, 0);
49 if (cnt>0) {
50 for (c2=0; c2<cnt; c2++)
51 DOSVM_Int16AddChar(ch[c2], scan);
52 } else
53 if (cnt==0) {
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");
80 return;
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];