2 * Keyboard related functions
4 * Copyright 1993 Bob Amstadt
7 static char Copyright
[] = "Copyright Bob Amstadt, 1993";
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
)
25 return MouseButtonsStates
[0];
27 return MouseButtonsStates
[1];
29 return MouseButtonsStates
[2];
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
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
61 int GetAsyncKeyState(int nKey
)
68 retval
= AsyncMouseButtonsStates
[0] |
69 (MouseButtonsStates
[0] << 8);
72 retval
= AsyncMouseButtonsStates
[1] |
73 (MouseButtonsStates
[1] << 8);
76 retval
= AsyncMouseButtonsStates
[2] |
77 (MouseButtonsStates
[2] << 8);
80 retval
= AsyncKeyStateTable
[nKey
] |
81 (KeyStateTable
[nKey
] << 8);
85 bzero(AsyncMouseButtonsStates
, 3); /* all states to false */
86 bzero(AsyncKeyStateTable
, 256);