Release 941017
[wine/gsoc-2012-control.git] / windows / keyboard.c
blobab15b9db6d3a05731f207372190838343842c5a9
1 /*
2 * Keyboard related functions
4 * Copyright 1993 Bob Amstadt
5 */
7 static char Copyright[] = "Copyright Bob Amstadt, 1993";
9 #include <string.h>
10 #include "win.h"
11 #include "windows.h"
13 extern BOOL MouseButtonsStates[3];
14 extern BOOL AsyncMouseButtonsStates[3];
15 extern BYTE KeyStateTable[256];
16 extern BYTE AsyncKeyStateTable[256];
18 /**********************************************************************
19 * GetKeyState [USER.106]
21 int GetKeyState(int keycode)
23 switch(keycode) {
24 case VK_LBUTTON:
25 return MouseButtonsStates[0];
26 case VK_MBUTTON:
27 return MouseButtonsStates[1];
28 case VK_RBUTTON:
29 return MouseButtonsStates[2];
30 default:
31 return KeyStateTable[keycode];
35 /**********************************************************************
36 * GetKeyboardState [USER.222]
38 void GetKeyboardState(BYTE FAR *lpKeyState)
40 if (lpKeyState != NULL) {
41 KeyStateTable[VK_LBUTTON] = MouseButtonsStates[0];
42 KeyStateTable[VK_MBUTTON] = MouseButtonsStates[1];
43 KeyStateTable[VK_RBUTTON] = MouseButtonsStates[2];
44 memcpy(lpKeyState, KeyStateTable, 256);
48 /**********************************************************************
49 * GetAsyncKeyState (USER.249)
51 * Determine if a key is or was pressed. retval has high-order
52 * byte set to 1 if currently pressed, low-order byte 1 if key has
53 * been pressed.
55 * This uses the variable AsyncMouseButtonsStates and
56 * AsyncKeyStateTable (set in event.c) which have the mouse button
57 * number or key number (whichever is applicable) set to true if the
58 * mouse or key had been depressed since the last call to
59 * GetAsyncKeyState.
61 int GetAsyncKeyState(int nKey)
63 short retval;
65 switch (nKey) {
67 case VK_LBUTTON:
68 retval = AsyncMouseButtonsStates[0] |
69 (MouseButtonsStates[0] << 8);
70 break;
71 case VK_MBUTTON:
72 retval = AsyncMouseButtonsStates[1] |
73 (MouseButtonsStates[1] << 8);
74 break;
75 case VK_RBUTTON:
76 retval = AsyncMouseButtonsStates[2] |
77 (MouseButtonsStates[2] << 8);
78 break;
79 default:
80 retval = AsyncKeyStateTable[nKey] |
81 (KeyStateTable[nKey] << 8);
82 break;
85 bzero(AsyncMouseButtonsStates, 3); /* all states to false */
86 bzero(AsyncKeyStateTable, 256);
88 return retval;