3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "main.h" // For g_settings
23 #define CHECKKEY(x){if(strcmp(name, #x)==0) return irr::x;}
25 irr::EKEY_CODE keyname_to_keycode(const char *name)
31 CHECKKEY(KEY_XBUTTON1)
32 CHECKKEY(KEY_XBUTTON2)
51 CHECKKEY(KEY_NONCONVERT)
53 CHECKKEY(KEY_MODECHANGE)
66 CHECKKEY(KEY_SNAPSHOT)
110 CHECKKEY(KEY_NUMPAD0)
111 CHECKKEY(KEY_NUMPAD1)
112 CHECKKEY(KEY_NUMPAD2)
113 CHECKKEY(KEY_NUMPAD3)
114 CHECKKEY(KEY_NUMPAD4)
115 CHECKKEY(KEY_NUMPAD5)
116 CHECKKEY(KEY_NUMPAD6)
117 CHECKKEY(KEY_NUMPAD7)
118 CHECKKEY(KEY_NUMPAD8)
119 CHECKKEY(KEY_NUMPAD9)
120 CHECKKEY(KEY_MULTIPLY)
122 CHECKKEY(KEY_SEPARATOR)
123 CHECKKEY(KEY_SUBTRACT)
124 CHECKKEY(KEY_DECIMAL)
150 CHECKKEY(KEY_NUMLOCK)
154 CHECKKEY(KEY_LCONTROL)
155 CHECKKEY(KEY_RCONTROL)
169 CHECKKEY(KEY_OEM_CLEAR)
171 return irr::KEY_KEY_CODES_COUNT;
178 // A simple cache for quicker lookup
179 core::map<std::string, irr::EKEY_CODE> g_key_setting_cache;
181 irr::EKEY_CODE getKeySetting(const char *settingname)
183 core::map<std::string, irr::EKEY_CODE>::Node *n;
184 n = g_key_setting_cache.find(settingname);
186 return n->getValue();
187 irr::EKEY_CODE c = keyname_to_keycode(g_settings.get(settingname).c_str());
188 g_key_setting_cache.insert(settingname, c);