-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKeyFunctionMap.cpp
58 lines (51 loc) · 1.27 KB
/
KeyFunctionMap.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
54
55
56
57
58
#include "KeyFunctionMap.h"
#include <cstdio>
namespace AwpSoftGameModule
{
FunctionToKey::FunctionToKey()
{
memset(KeysOfFunction, 0x00, 0x400);
}
FunctionToKey::~FunctionToKey()
{
}
void FunctionToKey::setKeysOfFunction(int functionIndex, unsigned char key1, unsigned char key2, unsigned char key3, unsigned char key4)
{
if (functionIndex < 0x0 || functionIndex >= 0x100)
{
return;
}
unsigned int temp = key4;
temp <<= 8;
temp |= key3;
temp <<= 8;
temp |= key2;
temp <<= 8;
temp |= key1;
KeysOfFunction[functionIndex] = temp;
}
unsigned int FunctionToKey::getKeysOfFunction(int functionIndex)
{
if (functionIndex < 0x0 || functionIndex >= 0x100)
{
return 0x0;
}
return KeysOfFunction[functionIndex];
}
bool FunctionToKey::getFunctionState(int functionIndex)
{
if (functionIndex < 0x0 || functionIndex >= 0x100)
{
return false;
}
unsigned int temp = KeysOfFunction[functionIndex];
if ((temp & 0xFF) && GetAsyncKeyState(temp & 0xFF) < 0) return true;
temp >>= 8;
if ((temp & 0xFF) && GetAsyncKeyState(temp & 0xFF) < 0) return true;
temp >>= 8;
if ((temp & 0xFF) && GetAsyncKeyState(temp & 0xFF) < 0) return true;
temp >>= 8;
if ((temp & 0xFF) && GetAsyncKeyState(temp & 0xFF) < 0) return true;
return false;
}
};