\r
//unsigned char *CInputTask::keys=0;\r
//CMMPointer<CMMDynamicBlob<unsigned char> > CInputTask::oldKeys=0;\r
-//int CInputTask::keyCount=0;\r
-BYTE CInputTask::keys[256];\r
-BYTE CInputTask::oldKeys[256];\r
+int CInputTask::keyCount=0;\r
+BYTE *CInputTask::keys;\r
+BYTE *CInputTask::oldKeys;\r
int CInputTask::dX=0;\r
int CInputTask::dY=0;\r
unsigned int CInputTask::buttons=0;\r
\r
CInputTask::CInputTask(CKernel* kernel) : ITask(kernel)\r
{\r
-#ifdef WIN32\r
- din = NULL;\r
- dinkeyboard = NULL;\r
- memset(keys, 0, 256);\r
- memset(oldKeys, 0, 256);\r
-\r
- // create the DirectInput interface\r
- DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL);\r
-\r
- assert(din != NULL);\r
-\r
- // create the keyboard device\r
- din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL);\r
-\r
- dinkeyboard->SetDataFormat(&c_dfDIKeyboard); // set the data format to keyboard format\r
-\r
- // set the control you will have over the keyboard\r
- dinkeyboard->SetCooperativeLevel(hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);\r
-#endif // WIN32\r
+ keys=0;\r
+ oldKeys=0;\r
}\r
\r
CInputTask::~CInputTask()\r
{\r
-#ifdef WIN32\r
- if (dinkeyboard != NULL) \r
- {\r
- dinkeyboard->Unacquire();\r
- dinkeyboard->Release();\r
- }\r
- if (din != NULL) din->Release();\r
-#endif // WIN32\r
}\r
\r
bool CInputTask::Start()\r
{\r
-#ifdef WIN32\r
- dinkeyboard->Acquire();\r
-#endif // WIN32\r
-\r
-\r
-// keys=SDL_GetKeyState(&keyCount);\r
-// oldKeys=new CMMDynamicBlob<unsigned char>(keyCount);\r
-// dX=dY=0;\r
-// SDL_PumpEvents(); SDL_PumpEvents();\r
+ keys=SDL_GetKeyState(&keyCount);\r
+ oldKeys=new BYTE[keyCount];\r
+ dX=dY=0;\r
+ SDL_PumpEvents(); SDL_PumpEvents();\r
return true;\r
}\r
\r
void CInputTask::Update()\r
{\r
-#ifdef WIN32\r
- dinkeyboard->Acquire();\r
- memcpy(oldKeys, keys, 256*sizeof(BYTE));\r
- dinkeyboard->GetDeviceState(256, (LPVOID)keys);\r
-\r
-#endif // WIN32\r
-// SDL_PumpEvents();\r
-// oldButtons=buttons;\r
-// buttons=SDL_GetRelativeMouseState(&dX,&dY);\r
-// memcpy((unsigned char*)(*oldKeys),keys,sizeof(unsigned char)*keyCount);\r
-// keys=SDL_GetKeyState(&keyCount);\r
+ SDL_PumpEvents();\r
+ oldButtons=buttons;\r
+ buttons=SDL_GetRelativeMouseState(&dX,&dY);\r
+ memcpy((unsigned char*)(*oldKeys),keys,sizeof(unsigned char)*keyCount);\r
+ keys=SDL_GetKeyState(&keyCount);\r
}\r
\r
void CInputTask::Stop()\r
{\r
- //keys=0;\r
- //oldKeys=0;\r
- memset(keys, 0, 256);\r
- memset(oldKeys, 0, 256);\r
+ if (oldKeys)\r
+ delete oldKeys;\r
+ keys=0;\r
+ oldKeys=0;\r
}\r