|
1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2004-2019 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 * |
|
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; version 2 of the License |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
17 */ |
|
18 |
|
19 /** |
|
20 * @file |
|
21 * @brief KeyMap class definition |
|
22 */ |
|
23 |
|
24 #ifndef HEDGEWARS_KEYMAP_H |
|
25 #define HEDGEWARS_KEYMAP_H |
|
26 |
|
27 #include <QFile> |
|
28 #include <QHash> |
|
29 #include "SDL.h" |
|
30 |
|
31 class KeyMap |
|
32 { |
|
33 public: |
|
34 /** |
|
35 * @brief Returns reference to the <i>singleton</i> instance of this class. |
|
36 * |
|
37 * @see <a href="https://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> |
|
38 * |
|
39 * @return reference to the instance. |
|
40 */ |
|
41 static KeyMap & instance(); |
|
42 SDL_Scancode getScancodeFromKeyname(QString keyname); |
|
43 QString getKeynameFromScancode(int scancode); |
|
44 QString getKeynameFromScancodeConverted(int scancode); |
|
45 QString getKeynameFromKeycode(int keycode); |
|
46 |
|
47 private: |
|
48 // TODO: Optimize data structures |
|
49 QHash<SDL_Scancode, QString> mapOfKeynames; |
|
50 QHash<QString, SDL_Scancode> mapOfScancodes; |
|
51 bool getKeyMap(); |
|
52 bool keyMapGenerated = false; |
|
53 |
|
54 }; |
|
55 |
|
56 #endif // HEDGEWARS_KEYMAP_H |