Hacked some input and entity commands into the engine.
[peakengine.git] / engine / src / core / Keycode.cpp
blob18e15aae0040392172514c981b926f3e50339ac7
1 /*
2 Copyright (C) 2008 Lukas Kropatschek
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #include "core/Keycode.h"
24 namespace peak
26 KeyName keynames[] =
28 {EK_LBUTTON, "LBUTTON"},
29 {EK_RBUTTON, "RBUTTON"},
30 {EK_CANCEL, "CANCEL"},
31 {EK_MBUTTON, "MBUTTON"},
32 {EK_XBUTTON1, "XBUTTON1"},
33 {EK_XBUTTON2, "XBUTTON2"},
34 {EK_BACK, "BACK"},
35 {EK_TAB, "TAB"},
36 {EK_CLEAR, "CLEAR"},
37 {EK_RETURN, "RETURN"},
38 {EK_SHIFT, "SHIFT"},
39 {EK_CONTROL, "CONTROL"},
40 {EK_MENU, "MENU"},
41 {EK_PAUSE, "PAUSE"},
42 {EK_CAPITAL, "CAPITAL"},
43 {EK_KANA, "KANA"},
44 {EK_HANGUEL, "HANGUEL"},
45 {EK_HANGUL, "HANGUL"},
46 {EK_JUNJA, "JUNJA"},
47 {EK_FINAL, "FINAL"},
48 {EK_HANJA, "HANJA"},
49 {EK_KANJI, "KANJI"},
50 {EK_ESCAPE, "ESCAPE"},
51 {EK_CONVERT, "CONVERT"},
52 {EK_NONCONVERT, "NONCONVERT"},
53 {EK_ACCEPT, "ACCEPT"},
54 {EK_MODECHANGE, "MODECHANGE"},
55 {EK_SPACE, "SPACE"},
56 {EK_PRIOR, "PRIOR"},
57 {EK_NEXT, "NEXT"},
58 {EK_END, "END"},
59 {EK_HOME, "HOME"},
60 {EK_LEFT, "LEFT"},
61 {EK_UP, "UP"},
62 {EK_RIGHT, "RIGHT"},
63 {EK_DOWN, "DOWN"},
64 {EK_SELECT, "SELECT"},
65 {EK_PRINT, "PRINT"},
66 {EK_EXECUT, "EXECUT"},
67 {EK_SNAPSHOT, "SNAPSHOT"},
68 {EK_INSERT, "INSERT"},
69 {EK_DELETE, "DELETE"},
70 {EK_HELP, "HELP"},
71 {EK_KEY_0, "KEY_0"},
72 {EK_KEY_1, "KEY_1"},
73 {EK_KEY_2, "KEY_2"},
74 {EK_KEY_3, "KEY_3"},
75 {EK_KEY_4, "KEY_4"},
76 {EK_KEY_5, "KEY_5"},
77 {EK_KEY_6, "KEY_6"},
78 {EK_KEY_7, "KEY_7"},
79 {EK_KEY_8, "KEY_8"},
80 {EK_KEY_9, "KEY_9"},
81 {EK_KEY_A, "KEY_A"},
82 {EK_KEY_B, "KEY_B"},
83 {EK_KEY_C, "KEY_C"},
84 {EK_KEY_D, "KEY_D"},
85 {EK_KEY_E, "KEY_E"},
86 {EK_KEY_F, "KEY_F"},
87 {EK_KEY_G, "KEY_G"},
88 {EK_KEY_H, "KEY_H"},
89 {EK_KEY_I, "KEY_I"},
90 {EK_KEY_J, "KEY_J"},
91 {EK_KEY_K, "KEY_K"},
92 {EK_KEY_L, "KEY_L"},
93 {EK_KEY_M, "KEY_M"},
94 {EK_KEY_N, "KEY_N"},
95 {EK_KEY_O, "KEY_O"},
96 {EK_KEY_P, "KEY_P"},
97 {EK_KEY_Q, "KEY_Q"},
98 {EK_KEY_R, "KEY_R"},
99 {EK_KEY_S, "KEY_S"},
100 {EK_KEY_T, "KEY_T"},
101 {EK_KEY_U, "KEY_U"},
102 {EK_KEY_V, "KEY_V"},
103 {EK_KEY_W, "KEY_W"},
104 {EK_KEY_X, "KEY_X"},
105 {EK_KEY_Y, "KEY_Y"},
106 {EK_KEY_Z, "KEY_Z"},
107 {EK_LWIN, "LWIN"},
108 {EK_RWIN, "RWIN"},
109 {EK_APPS, "APPS"},
110 {EK_SLEEP, "SLEEP"},
111 {EK_NUMPAD0, "NUMPAD0"},
112 {EK_NUMPAD1, "NUMPAD1"},
113 {EK_NUMPAD2, "NUMPAD2"},
114 {EK_NUMPAD3, "NUMPAD3"},
115 {EK_NUMPAD4, "NUMPAD4"},
116 {EK_NUMPAD5, "NUMPAD5"},
117 {EK_NUMPAD6, "NUMPAD6"},
118 {EK_NUMPAD7, "NUMPAD7"},
119 {EK_NUMPAD8, "NUMPAD8"},
120 {EK_NUMPAD9, "NUMPAD9"},
121 {EK_MULTIPLY, "MULTIPLY"},
122 {EK_ADD, "ADD"},
123 {EK_SEPARATOR, "SEPARATOR"},
124 {EK_SUBTRACT, "SUBTRACT"},
125 {EK_DECIMAL, "DECIMAL"},
126 {EK_DIVIDE, "DIVIDE"},
127 {EK_F1, "F1"},
128 {EK_F2, "F2"},
129 {EK_F3, "F3"},
130 {EK_F4, "F4"},
131 {EK_F5, "F5"},
132 {EK_F6, "F6"},
133 {EK_F7, "F7"},
134 {EK_F8, "F8"},
135 {EK_F9, "F9"},
136 {EK_F10, "F10"},
137 {EK_F11, "F11"},
138 {EK_F12, "F12"},
139 {EK_F13, "F13"},
140 {EK_F14, "F14"},
141 {EK_F15, "F15"},
142 {EK_F16, "F16"},
143 {EK_F17, "F17"},
144 {EK_F18, "F18"},
145 {EK_F19, "F19"},
146 {EK_F20, "F20"},
147 {EK_F21, "F21"},
148 {EK_F22, "F22"},
149 {EK_F23, "F23"},
150 {EK_F24, "F24"},
151 {EK_NUMLOCK, "NUMLOCK"},
152 {EK_SCROLL, "SCROLL"},
153 {EK_LSHIFT, "LSHIFT"},
154 {EK_RSHIFT, "RSHIFT"},
155 {EK_LCONTROL, "LCONTROL"},
156 {EK_RCONTROL, "RCONTROL"},
157 {EK_LMENU, "LMENU"},
158 {EK_RMENU, "RMENU"},
159 {EK_PLUS, "PLUS"},
160 {EK_COMMA, "COMMA"},
161 {EK_MINUS, "MINUS"},
162 {EK_PERIOD, "PERIOD"},
163 {EK_ATTN, "ATTN"},
164 {EK_CRSEL, "CRSEL"},
165 {EK_EXSEL, "EXSEL"},
166 {EK_EREOF, "EREOF"},
167 {EK_PLAY, "PLAY"},
168 {EK_ZOOM, "ZOOM"},
169 {EK_PA1, "PA1"},
170 {EK_OEM_CLEAR, "OEM_CLEAR"},
171 {EK_NONE, ""}
174 Keycode getKey(std::string name)
176 int i = 0;
177 while (keynames[i].code != EK_NONE)
179 if (name == keynames[i].name)
181 return keynames[i].code;
183 i++;
185 return (Keycode)0;