337cd55f9916f53876f603ea56423bc7f10c8d77
[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 #ifdef WIN32\r
14 #define DIRECTINPUT_VERSION 0x0800\r
15 #include <dinput.h>\r
16 #endif // WIN32\r
17 \r
18 \r
19 #ifndef WIN32\r
20 /* HACK to make this compile */\r
21 #define BYTE unsigned char\r
22 #endif // !WIN32\r
23 \r
24 class CInputTask : public ITask  \r
25 {\r
26 public:\r
27         CInputTask();\r
28         virtual ~CInputTask();\r
29 \r
30         bool Start();\r
31         void Update();\r
32         void Stop();\r
33 \r
34         static BYTE keys[256], oldKeys[256];\r
35         //static CMMPointer<CMMDynamicBlob<unsigned char> > oldKeys;\r
36         //static int keyCount;\r
37         \r
38         static int dX,dY;\r
39         static unsigned int buttons;\r
40         static unsigned int oldButtons;\r
41 \r
42         static bool inline curKey(int index) { return (keys[index] & 0x80) != 0; }\r
43         static bool inline oldKey(int index) { return (oldKeys[index] & 0x80) != 0; }\r
44 \r
45         //some helper functions to make certain things easier\r
46         //static bool inline keyDown(int index)         { return ( curKey(index))&&(!oldKey(index)); }\r
47         static bool inline keyDown(int index)           { return ( curKey(index)); }\r
48         static bool inline keyStillDown(int index)      { return ( curKey(index))&&( oldKey(index)); }\r
49         static bool inline keyUp(int index)             { return (!curKey(index))&&( oldKey(index)); }\r
50         static bool inline keyStillUp(int index)        { return (!curKey(index))&&(!oldKey(index)); }\r
51 \r
52         //static bool inline curMouse(int button) { return (buttons&SDL_BUTTON(button))!=0; }\r
53         //static bool inline oldMouse(int button) { return (oldButtons&SDL_BUTTON(button))!=0; }\r
54 \r
55         //static bool inline mouseDown(int button)      { return ( curMouse(button))&&(!oldMouse(button)); }\r
56         //static bool inline mouseStillDown(int button) { return ( curMouse(button))&&( oldMouse(button)); }\r
57         //static bool inline mouseUp(int button)                { return (!curMouse(button))&&( oldMouse(button)); }\r
58         //static bool inline mouseStillUp(int button)   { return (!curMouse(button))&&(!oldMouse(button)); }\r
59 \r
60         AUTO_SIZE;\r
61 #ifdef WIN32\r
62 private:\r
63         LPDIRECTINPUT8 din;    // the pointer to our DirectInput interface\r
64         LPDIRECTINPUTDEVICE8 dinkeyboard;    // the pointer to the keyboard device\r
65 #endif\r
66 };\r
67 \r
68 #endif // !defined(AFX_KEYBOARDTASK_H__4953EF06_7C18_4433_B590_47E045E43576__INCLUDED_)\r