dlgTextEntry_Keyboard: rename to TouchTextEntry
[xcsoar.git] / src / Input / InputKeys.cpp
blobbc9ca62aaf8419c3f7d746d4284417aefe66cf0b
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "InputKeys.hpp"
25 #include "Screen/Key.h"
26 #include "Util/CharUtil.hpp"
28 #include <string.h>
30 struct string_to_key {
31 const TCHAR *name;
32 unsigned key;
35 static constexpr struct string_to_key string_to_key[] = {
36 { _T("APP1"), KEY_APP1 },
37 { _T("APP2"), KEY_APP2 },
38 { _T("APP3"), KEY_APP3 },
39 { _T("APP4"), KEY_APP4 },
40 { _T("APP5"), KEY_APP5 },
41 { _T("APP6"), KEY_APP6 },
42 { _T("F1"), KEY_F1 },
43 { _T("F2"), KEY_F2 },
44 { _T("F3"), KEY_F3 },
45 { _T("F4"), KEY_F4 },
46 { _T("F5"), KEY_F5 },
47 { _T("F6"), KEY_F6 },
48 { _T("F7"), KEY_F7 },
49 { _T("F8"), KEY_F8 },
50 { _T("F9"), KEY_F9 },
51 { _T("F10"), KEY_F10 },
52 { _T("F11"), KEY_F11 },
53 { _T("F12"), KEY_F12 },
54 #ifdef USE_GDI
55 /* These Keys are used for the Triadis-RemoteStick, as well as for
56 expanded Keyboard-Events */
57 { _T("F13"), KEY_F13 },
58 { _T("F14"), KEY_F14 },
59 { _T("F15"), KEY_F15 },
60 { _T("F16"), KEY_F16 },
61 { _T("F17"), KEY_F17 },
62 { _T("F18"), KEY_F18 },
63 { _T("F19"), KEY_F19 },
64 { _T("F20"), KEY_F20 },
65 #endif
66 { _T("LEFT"), KEY_LEFT },
67 { _T("RIGHT"), KEY_RIGHT },
68 { _T("UP"), KEY_UP },
69 { _T("DOWN"), KEY_DOWN },
70 { _T("RETURN"), KEY_RETURN },
71 { _T("ESCAPE"), KEY_ESCAPE },
72 { _T("MENU"), KEY_MENU },
73 { NULL }
76 unsigned
77 ParseKeyCode(const TCHAR *data)
79 for (const struct string_to_key *p = &string_to_key[0]; p->name != NULL; ++p)
80 if (_tcscmp(data, p->name) == 0)
81 return p->key;
83 if (_tcslen(data) == 1)
84 return ToUpperASCII(data[0]);
86 else
87 return 0;