Release 940614
[wine] / windows / keyboard.c
1 /*
2  * Keyboard related functions
3  *
4  * Copyright 1993 Bob Amstadt
5  */
6
7 static char Copyright[] = "Copyright  Bob Amstadt, 1993";
8
9 #include "win.h"
10 #include "windows.h"
11
12 extern BOOL MouseButtonsStates[3];
13 extern BOOL AsyncMouseButtonsStates[3];
14 extern BYTE KeyStateTable[256];
15
16 /**********************************************************************
17  *              GetKeyState                     [USER.106]
18  */
19 int GetKeyState(int keycode)
20 {
21         switch(keycode) {
22                 case VK_LBUTTON:
23                     return MouseButtonsStates[0];
24                 case VK_MBUTTON:
25                     return MouseButtonsStates[1];
26                 case VK_RBUTTON:
27                     return MouseButtonsStates[2];
28                 default:
29                     return 0;
30                 }
31 }
32
33 /**********************************************************************
34  *              GetKeyboardState                        [USER.222]
35  */
36 void GetKeyboardState(BYTE FAR *lpKeyState)
37 {
38         if (lpKeyState != NULL) {
39                 memcpy(lpKeyState, KeyStateTable, 256);
40                 }
41 }
42
43 /**********************************************************************
44  *
45  *            GetAsyncKeyState        (USER.249)
46  *
47  *      Determine if a key is or was pressed.  retval has high-order 
48  * byte set to 1 if currently pressed, low-order byte 1 if key has
49  * been pressed.
50  *
51  *      This uses the variable AsyncMouseButtonsStates (set in event.c)
52  * which have the mouse button number set to true if the mouse had been
53  * depressed since the last call to GetAsyncKeyState.
54  *
55  *      There should also be some keyboard stuff here... it isn't here
56  * yet.
57  */
58 int GetAsyncKeyState(int nKey)
59 {
60         short   retval; 
61
62         switch (nKey) {
63
64            case VK_LBUTTON:
65                 retval = AsyncMouseButtonsStates[0] | 
66                               (MouseButtonsStates[0] << 8);
67                 break;
68            case VK_MBUTTON:
69                 retval = AsyncMouseButtonsStates[1] |
70                               (MouseButtonsStates[1] << 8);
71                 break;
72            case VK_RBUTTON:
73                 retval = AsyncMouseButtonsStates[2] |
74                               MouseButtonsStates[2] << 8;
75                 break;
76            default:
77                 retval = 0;
78                 break;
79         }
80
81         bzero(AsyncMouseButtonsStates, 3);      /* all states to false */
82
83         return retval;
84 }
85