2 * DOS interrupt 09h handler (IRQ1 - KEYBOARD)
13 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(int);
23 BYTE queuelen
,queue
[QUEUELEN
],ascii
[QUEUELEN
];
27 /**********************************************************************
30 * Handler for int 09h.
32 void WINAPI
INT_Int09Handler( CONTEXT86
*context
)
34 BYTE ascii
, scan
= INT_Int09ReadScan(&ascii
);
38 TRACE("scan=%02x\n",scan
);
41 /* we already have an ASCII code, no translation necessary */
45 UINT vkey
= MapVirtualKeyA(scan
&0x7f, 1);
47 GetKeyboardState(keystate
);
48 cnt
= ToAscii(vkey
, scan
, keystate
, (LPWORD
)ch
, 0);
51 for (c2
=0; c2
<cnt
; c2
++)
52 INT_Int16AddChar(ch
[c2
], scan
);
55 /* FIXME: need to handle things like shift-F-keys,
56 * 0xE0 extended keys, etc */
57 INT_Int16AddChar(0, scan
);
60 Dosvm
.OutPIC(0x20, 0x20); /* send EOI */
63 static void KbdRelay( CONTEXT86
*context
, void *data
)
65 if (kbdinfo
.queuelen
) {
66 /* cleanup operation, called from Dosvm.OutPIC:
67 * we'll remove current scancode from keyboard buffer here,
68 * rather than in ReadScan, because some DOS apps depend on
69 * the scancode being available for reading multiple times... */
70 if (--kbdinfo
.queuelen
) {
71 memmove(kbdinfo
.queue
,kbdinfo
.queue
+1,kbdinfo
.queuelen
);
72 memmove(kbdinfo
.ascii
,kbdinfo
.ascii
+1,kbdinfo
.queuelen
);
77 void WINAPI
INT_Int09SendScan( BYTE scan
, BYTE ascii
)
79 if (kbdinfo
.queuelen
== QUEUELEN
) {
80 ERR("keyboard queue overflow\n");
83 /* add scancode to queue */
84 kbdinfo
.queue
[kbdinfo
.queuelen
] = scan
;
85 kbdinfo
.ascii
[kbdinfo
.queuelen
++] = ascii
;
86 /* tell app to read it by triggering IRQ 1 (int 09) */
87 Dosvm
.QueueEvent(1,DOS_PRIORITY_KEYBOARD
,KbdRelay
,NULL
);
90 /**********************************************************************
91 * KbdReadScan (WINEDOS.@)
93 BYTE WINAPI
INT_Int09ReadScan( BYTE
*ascii
)
95 if (ascii
) *ascii
= kbdinfo
.ascii
[0];
96 return kbdinfo
.queue
[0];