-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyfilter.h
More file actions
54 lines (38 loc) · 1.02 KB
/
keyfilter.h
File metadata and controls
54 lines (38 loc) · 1.02 KB
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
54
#ifndef _KEYFILTER_H_
#define _KEYFILTER_H_
#include <list>
#include <SDL/SDL.h>
using std::list;
namespace dragonfighting {
const size_t KEY_BUFFER_LEN = 128;
class Command {
public:
char name[16];
unsigned char ftgKeyArray[16];
size_t length;
Command(const char *name, const unsigned char *cmd, size_t length);
};
class KeyFilter {
struct FTGKeyNode {
unsigned char ftgkey;
Uint32 numFrames;
};
protected:
list<Command*> commandTable;
struct FTGKeyNode ftgKeyStateBuffer[KEY_BUFFER_LEN];
int ftgKeyCurIndex;
int ftgKeyPreIndex;
int beginIndex;
char curCommandName[16];
public:
KeyFilter();
~KeyFilter();
void addCommand(const char *name, const unsigned char *cmd, size_t length);
void updateKeys(unsigned char currentFtgKeyState);//every frame
bool pollCurrentCommandName(char *cmdname, size_t bufflen);
Uint32 getKeyState(unsigned char key);
// ugly way to handle charactor direction change
void flipHorizontal();
};
}
#endif