* Fix wrong pointer dereference in InputTask.
[matthijs/ABM2.git] / ABM2 / Engine / InputTask.h
1 // InputTask.h: interface for the CInputTask class.\r
2 //\r
3 //////////////////////////////////////////////////////////////////////\r
4 \r
5 #if !defined(AFX_KEYBOARDTASK_H__4953EF06_7C18_4433_B590_47E045E43576__INCLUDED_)\r
6 #define AFX_KEYBOARDTASK_H__4953EF06_7C18_4433_B590_47E045E43576__INCLUDED_\r
7 \r
8 #if _MSC_VER > 1000\r
9 #pragma once\r
10 #endif // _MSC_VER > 1000\r
11 \r
12 #include "engine.h"\r
13 #include "Amaltheia/Input.h"\r
14 #ifdef WIN32\r
15 #define DIRECTINPUT_VERSION 0x0800\r
16 #include <dinput.h>\r
17 #endif // WIN32\r
18 \r
19 class CInputTask : public ITask  \r
20 {\r
21 public:\r
22         CInputTask(CKernel* kernel);\r
23         virtual ~CInputTask();\r
24 \r
25         bool Start();\r
26         void Update();\r
27         void Stop();\r
28         /* XXX: Yuck, static crapjes */\r
29         static BYTE *keys, *oldKeys;\r
30         //static CMMPointer<CMMDynamicBlob<unsigned char> > oldKeys;\r
31         static int keyCount;\r
32         \r
33         static int dX,dY;\r
34         static unsigned int buttons;\r
35         static unsigned int oldButtons;\r
36 \r
37         static bool inline curKey(int index) { return (keys[index]) != 0; }\r
38         static bool inline oldKey(int index) { return (oldKeys[index]) != 0; }\r
39 \r
40         //some helper functions to make certain things easier\r
41         //static bool inline keyDown(int index)         { return ( curKey(index))&&(!oldKey(index)); }\r
42         static bool inline keyDown(int index)           { return ( curKey(index)); }\r
43         static bool inline keyStillDown(int index)      { return ( curKey(index))&&( oldKey(index)); }\r
44         static bool inline keyUp(int index)             { return (!curKey(index))&&( oldKey(index)); }\r
45         static bool inline keyStillUp(int index)        { return (!curKey(index))&&(!oldKey(index)); }\r
46 \r
47         //static bool inline curMouse(int button) { return (buttons&SDL_BUTTON(button))!=0; }\r
48         //static bool inline oldMouse(int button) { return (oldButtons&SDL_BUTTON(button))!=0; }\r
49 \r
50         //static bool inline mouseDown(int button)      { return ( curMouse(button))&&(!oldMouse(button)); }\r
51         //static bool inline mouseStillDown(int button) { return ( curMouse(button))&&( oldMouse(button)); }\r
52         //static bool inline mouseUp(int button)                { return (!curMouse(button))&&( oldMouse(button)); }\r
53         //static bool inline mouseStillUp(int button)   { return (!curMouse(button))&&(!oldMouse(button)); }\r
54 \r
55         AUTO_SIZE;\r
56 #ifdef WIN32\r
57 private:\r
58         LPDIRECTINPUT8 din;    // the pointer to our DirectInput interface\r
59         LPDIRECTINPUTDEVICE8 dinkeyboard;    // the pointer to the keyboard device\r
60 #endif\r
61 };\r
62 \r
63 #endif // !defined(AFX_KEYBOARDTASK_H__4953EF06_7C18_4433_B590_47E045E43576__INCLUDED_)\r