2 * Keyboard related functions
4 * Copyright 1993 Bob Amstadt
10 extern BOOL MouseButtonsStates
[3];
11 extern BOOL AsyncMouseButtonsStates
[3];
12 extern BYTE KeyStateTable
[256];
13 extern BYTE AsyncKeyStateTable
[256];
15 /**********************************************************************
16 * GetKeyState [USER.106]
18 int GetKeyState(int keycode
)
22 return MouseButtonsStates
[0];
24 return MouseButtonsStates
[1];
26 return MouseButtonsStates
[2];
28 return KeyStateTable
[keycode
];
32 /**********************************************************************
33 * GetKeyboardState [USER.222]
35 void GetKeyboardState(BYTE FAR
*lpKeyState
)
37 if (lpKeyState
!= NULL
) {
38 KeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0];
39 KeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1];
40 KeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2];
41 memcpy(lpKeyState
, KeyStateTable
, 256);
45 /**********************************************************************
46 * GetAsyncKeyState (USER.249)
48 * Determine if a key is or was pressed. retval has high-order
49 * byte set to 1 if currently pressed, low-order byte 1 if key has
52 * This uses the variable AsyncMouseButtonsStates and
53 * AsyncKeyStateTable (set in event.c) which have the mouse button
54 * number or key number (whichever is applicable) set to true if the
55 * mouse or key had been depressed since the last call to
58 int GetAsyncKeyState(int nKey
)
65 retval
= AsyncMouseButtonsStates
[0] |
66 (MouseButtonsStates
[0] << 8);
69 retval
= AsyncMouseButtonsStates
[1] |
70 (MouseButtonsStates
[1] << 8);
73 retval
= AsyncMouseButtonsStates
[2] |
74 (MouseButtonsStates
[2] << 8);
77 retval
= AsyncKeyStateTable
[nKey
] |
78 (KeyStateTable
[nKey
] << 8);
82 bzero(AsyncMouseButtonsStates
, 3); /* all states to false */
83 bzero(AsyncKeyStateTable
, 256);