1 /***************************************************************************
2 * Copyright (C) 2005 by Dimitris Saougos & Filippos Papadopoulos *
3 * <psybases@gmail.com> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License as *
7 * published by the Free Software Foundation; either version 2 of the *
8 * License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU Library General Public *
16 * License along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place* Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
27 + *LEFT_BUTTON* the left mouse button
28 + *MIDDLE_BUTTON* the middle mouse button
29 + *RIGHT_BUTTON* the right mouse button
31 + *KEY_ESC* the escape key
166 extern const int LEFT_BUTTON;
167 extern const int MIDDLE_BUTTON;
168 extern const int RIGHT_BUTTON;
170 extern const int KEY_ESC;
171 extern const int KEY_ESCAPE;
173 extern const int KEY_MINUS;
174 extern const int KEY_EQUALS;
175 extern const int KEY_BACKSPACE;
176 extern const int KEY_TAB;
178 extern const int KEY_LBRACKET;
179 extern const int KEY_RBRACKET;
181 extern const int KEY_ENTER;
182 extern const int KEY_RETURN;
184 extern const int KEY_CTRL;
185 extern const int KEY_LCTRL;
186 extern const int KEY_RCTRL;
188 extern const int KEY_SHIFT;
189 extern const int KEY_LSHIFT;
190 extern const int KEY_RSHIFT;
192 extern const int KEY_ALT;
193 extern const int KEY_LALT;
194 extern const int KEY_RALT;
196 extern const int KEY_0;
197 extern const int KEY_1;
198 extern const int KEY_2;
199 extern const int KEY_3;
200 extern const int KEY_4;
201 extern const int KEY_5;
202 extern const int KEY_6;
203 extern const int KEY_7;
204 extern const int KEY_8;
205 extern const int KEY_9;
207 extern const int KEY_A;
208 extern const int KEY_B;
209 extern const int KEY_C;
210 extern const int KEY_D;
211 extern const int KEY_E;
212 extern const int KEY_F;
213 extern const int KEY_G;
214 extern const int KEY_H;
215 extern const int KEY_I;
216 extern const int KEY_J;
217 extern const int KEY_K;
218 extern const int KEY_L;
219 extern const int KEY_M;
220 extern const int KEY_N;
221 extern const int KEY_O;
222 extern const int KEY_P;
223 extern const int KEY_Q;
224 extern const int KEY_R;
225 extern const int KEY_S;
226 extern const int KEY_T;
227 extern const int KEY_U;
228 extern const int KEY_V;
229 extern const int KEY_W;
230 extern const int KEY_X;
231 extern const int KEY_Y;
232 extern const int KEY_Z;
234 extern const int KEY_SEMICOLON;
235 extern const int KEY_APOSTROPHE;
237 extern const int KEY_TILDE;
238 extern const int KEY_GRAVE;
240 extern const int KEY_BACKSLASH;
242 extern const int KEY_COMMA;
243 extern const int KEY_PERIOD;
244 extern const int KEY_FORWARDSLASH;
245 extern const int KEY_SLASH;
247 extern const int KEY_SPACE;
249 extern const int KEY_CAPSLOCK;
250 extern const int KEY_CAPITAL;
252 extern const int KEY_F1;
253 extern const int KEY_F2;
254 extern const int KEY_F3;
255 extern const int KEY_F4;
256 extern const int KEY_F5;
257 extern const int KEY_F6;
258 extern const int KEY_F7;
259 extern const int KEY_F8;
260 extern const int KEY_F9;
261 extern const int KEY_F10;
262 extern const int KEY_F11;
263 extern const int KEY_F12;
265 extern const int KEY_SYSRQ;
266 extern const int KEY_SCROLLLOCK;
267 extern const int KEY_PAUSE;
269 extern const int KEY_NUMLOCK;
270 extern const int KEY_NUMPAD0;
271 extern const int KEY_NUMPAD1;
272 extern const int KEY_NUMPAD2;
273 extern const int KEY_NUMPAD3;
274 extern const int KEY_NUMPAD4;
275 extern const int KEY_NUMPAD5;
276 extern const int KEY_NUMPAD6;
277 extern const int KEY_NUMPAD7;
278 extern const int KEY_NUMPAD8;
279 extern const int KEY_NUMPAD9;
280 extern const int KEY_ADD;
281 extern const int KEY_SUBTRACT;
282 extern const int KEY_DIVIDE;
283 extern const int KEY_MULTIPLY;
284 extern const int KEY_DECIMAL;
285 extern const int KEY_NUMPADENTER;
287 extern const int KEY_INSERT;
288 extern const int KEY_DELETE;
289 extern const int KEY_HOME;
290 extern const int KEY_END;
291 extern const int KEY_PAGEUP;
292 extern const int KEY_PAGEDOWN;
294 extern const int KEY_UP;
295 extern const int KEY_DOWN;
296 extern const int KEY_LEFT;
297 extern const int KEY_RIGHT;
299 extern const int KEY_LWIN;
300 extern const int KEY_RWIN;
301 extern const int KEY_APPS;
309 extern bool key_press;
314 Handles keyboard and mouse input*/
319 int mouseLockBuffer[4];
322 int buttonLockDuration;
330 //group: Constructors
333 keyb - *true* to enable the keyboard subsystem, *false* otherwise
334 mous - *true* to enable the mouse subsystem, *false* otherwise
336 Input(bool keyb, bool mous);
341 /*method: mousePrepare
342 This method is the actual method that makes the reading from the hardware.
343 It should be called at regular intervals. If called too often or too sparsely it will result in missing some information
344 from the input. In general terms it is safe just to call it in every frame. But if the frame rate if very high it might
345 result in strange behavior from the mouse. We suggest assigning a timer of X ms to the calling of the function
346 and fine-tune it for better results.
349 <mouseGetButtonState>, <mouseGetXDelta> and <mouseGetYDelta>*/
352 /*method: mouseGetButtonState
353 Checks whether a speficic mouse button is pressed
356 button - the mouse button to check. Valid values are
363 *true* if _button_ is pressed, *false* otherwise
367 bool mouseGetButtonState(int button);
369 /*method: mouseGetXDelta
370 Reports deltas for mouse movement in X axis
373 the units of the mouse movement in the X axis. A negative integer will be returned when the mouse is moved in the
374 left direction, and a positive when moved in the right. Zero will be returned when there is no movement
378 long mouseGetXDelta(void);
380 /*method: mouseGetYDelta
381 Reports deltas for mouse movement in Y axis
384 the units of the mouse movement in the Y axis
388 long mouseGetYDelta(void);
391 Locks a mouse button for _duration_ milliseconds. When you lock a button it will not report its state for _duration_ millis
393 button - the desired button to lock
394 duration - duration of the locking in milliseconds
397 <mouseGetButtonState>*/
398 void lockButton(int button, int duration=100);
400 /*method: keyboardGetKeyState
401 Checks whether a speficic key on the keyboard is pressed
404 key - the key to check. See the <KEY codes>
407 *true* if _key_ is pressed, *false* otherwise*/
408 bool keyboardGetKeyState(int key);
411 Returns the character that has been pressed on the keyboard*/
415 void lockKey(int key, int duration=100);