blob: 2ab32ae27368215c405c98b1da4840c45d0d6f9c (
plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
client/key.cc
This file is part of the Osirion project and is distributed under
the terms and conditions of the GNU General Public License version 2
*/
#include "auxiliary/functions.h"
#include "client/key.h"
namespace client
{
Key::Key(const char *name, int keysym, char ascii)
{
key_sym = keysym;
key_ascii = ascii;
key_pressed = 0;
key_lastpressed = 0;
key_waspressed = 0;
key_name.assign(name);
clear();
}
Key::~Key()
{
clear();
}
std::string const & Key::bind(Modifier mod) const
{
switch (mod) {
case None:
return key_bind;
break;
case Shift:
return key_bind_shift;
break;
case Ctrl:
return key_bind_ctrl;
break;
case Alt:
return key_bind_alt;
break;
}
return key_bind;
}
void Key::clear()
{
key_bind.clear();
key_bind_shift.clear();
key_bind_ctrl.clear();
key_bind_alt.clear();
key_action = 0;
}
void Key::clear(Modifier mod)
{
switch (mod) {
case None:
key_action = 0;
key_bind.clear();
break;
case Shift:
key_bind_shift.clear();
break;
case Ctrl:
key_bind_ctrl.clear();
break;
case Alt:
key_bind_alt.clear();
break;
}
}
void Key::assign(Modifier mod, const char *bind, Action *action)
{
if (!bind) {
clear(mod);
return;
}
switch (mod) {
case None:
key_action = action;
key_bind.assign(bind);
aux::trim(key_bind);
break;
case Shift:
key_bind_shift.assign(bind);
aux::trim(key_bind_shift);
break;
case Ctrl:
key_bind_ctrl.assign(bind);
aux::trim(key_bind_ctrl);
break;
case Alt:
key_bind_alt.assign(bind);
aux::trim(key_bind_alt);
break;
}
}
}
|