2 * DOS interrupt 16h handler
13 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(int16
)
19 /**********************************************************************
22 * Handler for int 16h (keyboard)
26 * KEYB.COM (DOS >3.2) adds functions to this interrupt, they are
27 * not currently listed here.
30 void WINAPI
INT_Int16Handler( CONTEXT86
*context
)
32 switch AH_reg(context
) {
34 case 0x00: /* Get Keystroke */
35 /* Returns: AH = Scan code
36 AL = ASCII character */
37 TRACE("Get Keystroke\n");
38 CONSOLE_GetKeystroke(&AH_reg(context
), &AL_reg(context
));
41 case 0x01: /* Check for Keystroke */
42 /* Returns: ZF set if no keystroke */
44 /* AL = ASCII character */
45 TRACE("Check for Keystroke\n");
46 if (!CONSOLE_CheckForKeystroke(&AH_reg(context
), &AL_reg(context
)))
56 case 0x02: /* Get Shift Flags */
59 if (GetAsyncKeyState(VK_RSHIFT
))
60 AL_reg(context
) |= 0x01;
61 if (GetAsyncKeyState(VK_LSHIFT
))
62 AL_reg(context
) |= 0x02;
63 if (GetAsyncKeyState(VK_LCONTROL
) || GetAsyncKeyState(VK_RCONTROL
))
64 AL_reg(context
) |= 0x04;
65 if (GetAsyncKeyState(VK_LMENU
) || GetAsyncKeyState(VK_RMENU
))
66 AL_reg(context
) |= 0x08;
67 if (GetAsyncKeyState(VK_SCROLL
))
68 AL_reg(context
) |= 0x10;
69 if (GetAsyncKeyState(VK_NUMLOCK
))
70 AL_reg(context
) |= 0x20;
71 if (GetAsyncKeyState(VK_CAPITAL
))
72 AL_reg(context
) |= 0x40;
73 if (GetAsyncKeyState(VK_INSERT
))
74 AL_reg(context
) |= 0x80;
75 TRACE("Get Shift Flags: returning 0x%02x\n", AL_reg(context
));
78 case 0x03: /* Set Typematic Rate and Delay */
79 FIXME("Set Typematic Rate and Delay - Not Supported\n");
82 case 0x09: /* Get Keyboard Functionality */
83 FIXME("Get Keyboard Functionality - Not Supported\n");
84 /* As a temporary measure, say that "nothing" is supported... */
88 case 0x0a: /* Get Keyboard ID */
89 FIXME("Get Keyboard ID - Not Supported\n");
92 case 0x10: /* Get Enhanced Keystroke */
93 TRACE("Get Enhanced Keystroke - Partially supported\n");
94 /* Returns: AH = Scan code
95 AL = ASCII character */
96 CONSOLE_GetKeystroke(&AH_reg(context
), &AL_reg(context
));
100 case 0x11: /* Check for Enhanced Keystroke */
101 /* Returns: ZF set if no keystroke */
103 /* AL = ASCII character */
104 TRACE("Check for Enhanced Keystroke - Partially supported\n");
105 if (!CONSOLE_CheckForKeystroke(&AH_reg(context
), &AL_reg(context
)))
111 RESET_ZFLAG(context
);
115 case 0x12: /* Get Extended Shift States */
116 FIXME("Get Extended Shift States - Not Supported\n");
120 FIXME("Unknown INT 16 function - 0x%x\n", AH_reg(context
));
126 int WINAPI
INT_Int16AddChar(BYTE ascii
,BYTE scan
)
128 BIOSDATA
*data
= DOSMEM_BiosData();
129 WORD CurOfs
= data
->FirstKbdCharPtr
;
130 WORD NextOfs
= CurOfs
+ 2;
132 if (NextOfs
>= data
->KbdBufferEnd
) NextOfs
= data
->KbdBufferStart
;
133 /* check if buffer is full */
134 if (NextOfs
== data
->NextKbdCharPtr
) return 0;
136 /* okay, insert character in ring buffer */
137 ((BYTE
*)data
)[CurOfs
] = ascii
;
138 ((BYTE
*)data
)[CurOfs
+1] = scan
;
140 data
->FirstKbdCharPtr
= NextOfs
;