Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / nel / src / misc / events.cpp
blob212f78e5de77db55b8d6cd565d5d6d80bc27e52c
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "stdmisc.h"
22 #include "nel/misc/events.h"
23 #include "nel/misc/string_conversion.h"
25 #ifdef DEBUG_NEW
26 #define new DEBUG_NEW
27 #endif
29 namespace NLMISC {
32 // ***************************************************************************
33 // The conversion table
34 static const CStringConversion<TKey>::CPair stringTable [] =
36 // BUFFER
37 { "Key0", Key0 },
38 { "Key1", Key1 },
39 { "Key2", Key2 },
40 { "Key3", Key3 },
41 { "Key4", Key4 },
42 { "Key5", Key5 },
43 { "Key6", Key6 },
44 { "Key7", Key7 },
45 { "Key8", Key8 },
46 { "Key9", Key9 },
47 { "KeyA", KeyA },
48 { "KeyB", KeyB },
49 { "KeyC", KeyC },
50 { "KeyD", KeyD },
51 { "KeyE", KeyE },
52 { "KeyF", KeyF },
53 { "KeyG", KeyG },
54 { "KeyH", KeyH },
55 { "KeyI", KeyI },
56 { "KeyJ", KeyJ },
57 { "KeyK", KeyK },
58 { "KeyL", KeyL },
59 { "KeyM", KeyM },
60 { "KeyN", KeyN },
61 { "KeyO", KeyO },
62 { "KeyP", KeyP },
63 { "KeyQ", KeyQ },
64 { "KeyR", KeyR },
65 { "KeyS", KeyS },
66 { "KeyT", KeyT },
67 { "KeyU", KeyU },
68 { "KeyV", KeyV },
69 { "KeyW", KeyW },
70 { "KeyX", KeyX },
71 { "KeyY", KeyY },
72 { "KeyZ", KeyZ },
73 { "KeyLBUTTON", KeyLBUTTON },
74 { "KeyRBUTTON", KeyRBUTTON },
75 { "KeyCANCEL", KeyCANCEL },
76 { "KeyMBUTTON", KeyMBUTTON },
77 { "KeyBACK", KeyBACK },
78 { "KeyTAB", KeyTAB },
79 { "KeyCLEAR", KeyCLEAR },
80 { "KeyRETURN", KeyRETURN },
81 { "KeySHIFT", KeySHIFT },
82 { "KeyCONTROL", KeyCONTROL },
83 { "KeyMENU", KeyMENU },
84 { "KeyPAUSE", KeyPAUSE },
85 { "KeyCAPITAL", KeyCAPITAL },
86 { "KeyKANA", KeyKANA },
87 { "KeyHANGEUL", KeyHANGEUL },
88 { "KeyHANGUL", KeyHANGUL },
89 { "KeyJUNJA", KeyJUNJA },
90 { "KeyFINAL", KeyFINAL },
91 { "KeyHANJA", KeyHANJA },
92 { "KeyKANJI", KeyKANJI },
93 { "KeyESCAPE", KeyESCAPE },
94 { "KeyCONVERT", KeyCONVERT },
95 { "KeyNONCONVERT", KeyNONCONVERT },
96 { "KeyACCEPT", KeyACCEPT },
97 { "KeyMODECHANGE", KeyMODECHANGE },
98 { "KeySPACE", KeySPACE },
99 { "KeyPRIOR", KeyPRIOR },
100 { "KeyNEXT", KeyNEXT },
101 { "KeyEND", KeyEND },
102 { "KeyHOME", KeyHOME },
103 { "KeyLEFT", KeyLEFT },
104 { "KeyUP", KeyUP },
105 { "KeyRIGHT", KeyRIGHT },
106 { "KeyDOWN", KeyDOWN },
107 { "KeySELECT", KeySELECT },
108 { "KeyPRINT", KeyPRINT },
109 { "KeyEXECUTE", KeyEXECUTE },
110 { "KeySNAPSHOT", KeySNAPSHOT },
111 { "KeyINSERT", KeyINSERT },
112 { "KeyDELETE", KeyDELETE },
113 { "KeyHELP", KeyHELP },
114 { "KeyLWIN", KeyLWIN },
115 { "KeyRWIN", KeyRWIN },
116 { "KeyAPPS", KeyAPPS },
117 { "KeyNUMPAD0", KeyNUMPAD0 },
118 { "KeyNUMPAD1", KeyNUMPAD1 },
119 { "KeyNUMPAD2", KeyNUMPAD2 },
120 { "KeyNUMPAD3", KeyNUMPAD3 },
121 { "KeyNUMPAD4", KeyNUMPAD4 },
122 { "KeyNUMPAD5", KeyNUMPAD5 },
123 { "KeyNUMPAD6", KeyNUMPAD6 },
124 { "KeyNUMPAD7", KeyNUMPAD7 },
125 { "KeyNUMPAD8", KeyNUMPAD8 },
126 { "KeyNUMPAD9", KeyNUMPAD9 },
127 { "KeyMULTIPLY", KeyMULTIPLY },
128 { "KeyADD", KeyADD },
129 { "KeySEPARATOR", KeySEPARATOR },
130 { "KeySUBTRACT", KeySUBTRACT },
131 { "KeyDECIMAL", KeyDECIMAL },
132 { "KeyDIVIDE", KeyDIVIDE },
133 { "KeyF1", KeyF1 },
134 { "KeyF2", KeyF2 },
135 { "KeyF3", KeyF3 },
136 { "KeyF4", KeyF4 },
137 { "KeyF5", KeyF5 },
138 { "KeyF6", KeyF6 },
139 { "KeyF7", KeyF7 },
140 { "KeyF8", KeyF8 },
141 { "KeyF9", KeyF9 },
142 { "KeyF10", KeyF10 },
143 { "KeyF11", KeyF11 },
144 { "KeyF12", KeyF12 },
145 { "KeyF13", KeyF13 },
146 { "KeyF14", KeyF14 },
147 { "KeyF15", KeyF15 },
148 { "KeyF16", KeyF16 },
149 { "KeyF17", KeyF17 },
150 { "KeyF18", KeyF18 },
151 { "KeyF19", KeyF19 },
152 { "KeyF20", KeyF20 },
153 { "KeyF21", KeyF21 },
154 { "KeyF22", KeyF22 },
155 { "KeyF23", KeyF23 },
156 { "KeyF24", KeyF24 },
157 { "KeyNUMLOCK", KeyNUMLOCK },
158 { "KeySCROLL", KeySCROLL },
159 { "KeyLSHIFT", KeyLSHIFT },
160 { "KeyRSHIFT", KeyRSHIFT },
161 { "KeyLCONTROL", KeyLCONTROL },
162 { "KeyRCONTROL", KeyRCONTROL },
163 { "KeyLMENU", KeyLMENU },
164 { "KeyRMENU", KeyRMENU },
165 { "KeyMUTE", KeyMUTE },
166 { "KeyPLAYPAUSE", KeyPLAYPAUSE },
167 { "KeyVOLUMEDOWN", KeyVOLUMEDOWN },
168 { "KeyVOLUMEUP", KeyVOLUMEUP },
169 { "KeyCALC", KeyCALC },
170 { "KeySEMICOLON", KeySEMICOLON },
171 { "KeyEQUALS", KeyEQUALS },
172 { "KeyCOMMA", KeyCOMMA },
173 { "KeyDASH", KeyDASH },
174 { "KeyPERIOD", KeyPERIOD },
175 { "KeySLASH", KeySLASH },
176 { "KeyTILDE", KeyTILDE },
177 { "KeyLBRACKET", KeyLBRACKET },
178 { "KeyBACKSLASH", KeyBACKSLASH },
179 { "KeyRBRACKET", KeyRBRACKET },
180 { "KeyAPOSTROPHE", KeyAPOSTROPHE },
181 { "KeyPARAGRAPH", KeyPARAGRAPH },
182 { "KeyOEM_102", KeyOEM_102 },
183 { "KeyPROCESSKEY", KeyPROCESSKEY },
184 { "KeyATTN", KeyATTN },
185 { "KeyCRSEL", KeyCRSEL },
186 { "KeyEXSEL", KeyEXSEL },
187 { "KeyEREOF", KeyEREOF },
188 { "KeyPLAY", KeyPLAY },
189 { "KeyZOOM", KeyZOOM },
190 { "KeyNONAME", KeyNONAME },
191 { "KeyPA1", KeyPA1 },
192 { "KeyOEM_CLEAR", KeyOEM_CLEAR }
196 static CStringConversion<TKey> KeyConversion(stringTable, sizeof(stringTable) / sizeof(stringTable[0]), KeyCount);
199 // ***************************************************************************
200 TKey CEventKey::getKeyFromString(const std::string &str)
202 return KeyConversion.fromString(str);
205 // ***************************************************************************
206 const std::string &CEventKey::getStringFromKey(TKey k)
208 return KeyConversion.toString(k);
213 } // NLMISC