-
Notifications
You must be signed in to change notification settings - Fork 2
/
InputTask.cpp
53 lines (42 loc) · 1.1 KB
/
InputTask.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// InputTask.cpp: implementation of the CInputTask class.
//
//////////////////////////////////////////////////////////////////////
#include "InputTask.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
unsigned char *CInputTask::keys=0;
CMMPointer<CMMDynamicBlob<unsigned char> > CInputTask::oldKeys=0;
int CInputTask::keyCount=0;
int CInputTask::dX=0;
int CInputTask::dY=0;
unsigned int CInputTask::buttons=0;
unsigned int CInputTask::oldButtons=0;
CInputTask::CInputTask()
{
}
CInputTask::~CInputTask()
{
}
bool CInputTask::Start()
{
keys=SDL_GetKeyState(&keyCount);
oldKeys=new CMMDynamicBlob<unsigned char>(keyCount);
dX=dY=0;
SDL_PumpEvents(); SDL_PumpEvents();
return true;
}
void CInputTask::Update()
{
PROFILE("InputTask update");
SDL_PumpEvents();
oldButtons=buttons;
buttons=SDL_GetRelativeMouseState(&dX,&dY);
memcpy((unsigned char*)(*oldKeys),keys,sizeof(unsigned char)*keyCount);
keys=SDL_GetKeyState(&keyCount);
}
void CInputTask::Stop()
{
keys=0;
oldKeys=0;
}