Added cmd line in new_process request.
[wine.git] / msdos / int09.c
blob26a77a12ce8058d4286fcc3e9b465749ec2b40f7
1 /*
2 * DOS interrupt 09h handler (IRQ1 - KEYBOARD)
3 */
5 #include <stdlib.h>
6 #include "winuser.h"
7 #include "miscemu.h"
8 #include "input.h"
9 #include "debug.h"
10 #include "dosexe.h"
12 typedef struct {
13 BYTE queuelen,queue[15];
14 } KBDSYSTEM;
16 /**********************************************************************
17 * INT_Int09Handler
19 * Handler for int 09h.
21 void WINAPI INT_Int09Handler( CONTEXT *context )
23 BYTE scan = INT_Int09ReadScan();
24 UINT vkey = MapVirtualKeyA(scan&0x7f, 1);
25 BYTE ch[2];
26 int cnt;
28 if (!(scan & 0x80)) {
29 /* as in TranslateMessage, windows/input.c */
30 cnt = ToAscii(vkey, scan&0x7f, QueueKeyStateTable, (LPWORD)ch, 0);
31 if (cnt==1) {
32 FIXME(int,"enter character %c into console input, not implemented\n",ch[0]);
35 DOSVM_PIC_ioport_out(0x20, 0x20); /* send EOI */
38 static void KbdRelay( LPDOSTASK lpDosTask, PCONTEXT context, void *data )
40 KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09);
42 if (sys && sys->queuelen) {
43 /* cleanup operation, called from DOSVM_PIC_ioport_out:
44 * we'll remove current scancode from keyboard buffer here,
45 * rather than in ReadScan, because some DOS apps depend on
46 * the scancode being available for reading multiple times... */
47 if (--sys->queuelen)
48 memmove(sys->queue,sys->queue+1,sys->queuelen);
52 void WINAPI INT_Int09SendScan( BYTE scan )
54 KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09);
55 if (!sys) {
56 sys = calloc(1,sizeof(KBDSYSTEM));
57 DOSVM_SetSystemData(0x09,sys);
59 /* add scancode to queue */
60 sys->queue[sys->queuelen++] = scan;
61 /* tell app to read it by triggering IRQ 1 (int 09) */
62 DOSVM_QueueEvent(1,DOS_PRIORITY_KEYBOARD,KbdRelay,NULL);
65 BYTE WINAPI INT_Int09ReadScan( void )
67 KBDSYSTEM *sys = (KBDSYSTEM *)DOSVM_GetSystemData(0x09);
68 if (sys)
69 return sys->queue[0];
70 else
71 return 0;