-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyDownHandler.h
44 lines (42 loc) · 886 Bytes
/
KeyDownHandler.h
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
#ifndef KEY_DOWN_HANDLER_H
#define KEY_DOWN_HANDLER_H
#include "HandlerBase.h"
#include "KeyboardMessage.h"
class KeyDownHandler: public HandlerBase
{
public:
KeyDownHandler(){};
virtual ~KeyDownHandler()
{
}
virtual bool doHandle(MessageBase *msg, MessageBase *&newMsg)
{
MSG_TYPE type = msg->getMsg();
if (!(type == MSG_KEY_DOWN || type == MSG_KEY_UP)) return false;
KeyboardMessage* keyMsg = (KeyboardMessage*) msg;
bool res = true;
switch(keyMsg->m_key)
{
case KEY_UP:
res = proc_key_rotate();
break;
case KEY_DOWN:
res = proc_key_down();
break;
case KEY_LEFT:
res = proc_key_left();
break;
case KEY_RIGHT:
res = proc_key_right();
break;
default:
break;
}
return res;
}
virtual bool proc_key_rotate();
virtual bool proc_key_down();
virtual bool proc_key_left();
virtual bool proc_key_right();
};
#endif