-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeystream.cpp
More file actions
63 lines (46 loc) · 1.08 KB
/
keystream.cpp
File metadata and controls
63 lines (46 loc) · 1.08 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
55
56
57
58
59
60
61
62
63
#include <SDL/SDL.h>
#include <assert.h>
#include "keystream.h"
namespace dragonfighting {
CtrlKeyReaderWriter::CtrlKeyReaderWriter()
{
}
CtrlKeyReaderWriter::~CtrlKeyReaderWriter()
{
}
void CtrlKeyReaderWriter::writeEvent(struct Ctrl_KeyEvent *event)
{
this->keyEventList.push_back(*event);
}
int CtrlKeyReaderWriter::readEvent(struct Ctrl_KeyEvent *event, Uint32 frameStamp)
{
if (keyEventList.size() == 0) return 0;
if (frameStamp == this->keyEventList.front().frameStamp) {
*event = this->keyEventList.front();
this->keyEventList.pop_front();
return 1;
}
return 0;
}
ReplayWriter::ReplayWriter() :
index(0)
{
buffer = (struct Ctrl_KeyEvent *)malloc(4096);
}
void ReplayWriter::writeEvent(struct Ctrl_KeyEvent *event)
{
buffer[index++] = *event;
}
SDLKeyConverter::SDLKeyConverter()
{
memset(keyMap, 0, sizeof(keyMap));
}
void SDLKeyConverter::registerKey(unsigned char sdlKey, unsigned char ctrlKey)
{
keyMap[sdlKey] = ctrlKey;
}
unsigned char SDLKeyConverter::convert(unsigned char sdlKey)
{
return keyMap[sdlKey];
}
}