Implemented Get Shift Flags function.
[wine] / msdos / int16.c
1 /*
2  * DOS interrupt 16h handler
3  */
4
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
8
9 #include "config.h"
10 #include "module.h"
11 #include "console.h"
12 #include "wincon.h"
13 #include "debug.h"
14 #include "winuser.h"
15
16 /**********************************************************************
17  *          INT_Int16Handler
18  *
19  * Handler for int 16h (keyboard)
20  *
21  * NOTE:
22  * 
23  *    KEYB.COM (DOS >3.2) adds functions to this interrupt, they are
24  *    not currently listed here.
25  */
26
27 void WINAPI INT_Int16Handler( CONTEXT *context )
28 {
29    switch AH_reg(context) {
30
31    case 0x00: /* Get Keystroke */
32       /* Returns: AH = Scan code
33                   AL = ASCII character */   
34       TRACE(int16, "Get Keystroke\n");
35       CONSOLE_GetKeystroke(&AH_reg(context), &AL_reg(context));
36       break;
37
38    case 0x01: /* Check for Keystroke */
39       /* Returns: ZF set if no keystroke */
40       /*          AH = Scan code */
41       /*          AL = ASCII character */
42       TRACE(int16, "Check for Keystroke\n");
43       if (!CONSOLE_CheckForKeystroke(&AH_reg(context), &AL_reg(context)))
44       {
45           SET_ZFLAG(context);
46       }
47       else
48       {
49           RESET_ZFLAG(context);
50       }
51       break;
52
53    case 0x02: /* Get Shift Flags */      
54       AL_reg(context) = 0;
55
56       if (GetAsyncKeyState(VK_RSHIFT))
57           AL_reg(context) |= 0x01;
58       if (GetAsyncKeyState(VK_LSHIFT))
59           AL_reg(context) |= 0x02;
60       if (GetAsyncKeyState(VK_LCONTROL) || GetAsyncKeyState(VK_RCONTROL))
61           AL_reg(context) |= 0x04;
62       if (GetAsyncKeyState(VK_LMENU) || GetAsyncKeyState(VK_RMENU))
63           AL_reg(context) |= 0x08;
64       if (GetAsyncKeyState(VK_SCROLL))
65           AL_reg(context) |= 0x10;
66       if (GetAsyncKeyState(VK_NUMLOCK))
67           AL_reg(context) |= 0x20;
68       if (GetAsyncKeyState(VK_CAPITAL))
69           AL_reg(context) |= 0x40;
70       if (GetAsyncKeyState(VK_INSERT))
71           AL_reg(context) |= 0x80;
72       TRACE(int16, "Get Shift Flags: returning 0x%02x\n", AL_reg(context));
73       break;
74
75    case 0x03: /* Set Typematic Rate and Delay */
76       FIXME(int16, "Set Typematic Rate and Delay - Not Supported\n");
77       break;
78
79    case 0x09: /* Get Keyboard Functionality */
80       FIXME(int16, "Get Keyboard Functionality - Not Supported\n");
81       /* As a temporary measure, say that "nothing" is supported... */
82       AL_reg(context) = 0;
83       break;
84
85    case 0x0a: /* Get Keyboard ID */
86       FIXME(int16, "Get Keyboard ID - Not Supported\n");
87       break;
88
89    case 0x10: /* Get Enhanced Keystroke */
90       TRACE(int16, "Get Enhanced Keystroke - Partially supported\n");
91       /* Returns: AH = Scan code
92                   AL = ASCII character */   
93       CONSOLE_GetKeystroke(&AH_reg(context), &AL_reg(context));
94       break;
95   
96
97    case 0x11: /* Check for Enhanced Keystroke */
98       /* Returns: ZF set if no keystroke */
99       /*          AH = Scan code */
100       /*          AL = ASCII character */
101       TRACE(int16, "Check for Enhanced Keystroke - Partially supported\n");
102       if (!CONSOLE_CheckForKeystroke(&AH_reg(context), &AL_reg(context)))
103       {
104           SET_ZFLAG(context);
105       }
106       else
107       {
108           RESET_ZFLAG(context);
109       }
110       break;
111
112    case 0x12: /* Get Extended Shift States */
113       FIXME(int16, "Get Extended Shift States - Not Supported\n");
114       break;
115  
116    default:
117       FIXME(int16, "Unknown INT 16 function - 0x%x\n", AH_reg(context));   
118       break;
119
120    }
121 }
122