1 /** 2 * Copyright (c) 2006-2011 LOVE Development Team 3 * 4 * This software is provided 'as-is', without any express or implied 5 * warranty. In no event will the authors be held liable for any damages 6 * arising from the use of this software. 7 * 8 * Permission is granted to anyone to use this software for any purpose, 9 * including commercial applications, and to alter it and redistribute it 10 * freely, subject to the following restrictions: 11 * 12 * 1. The origin of this software must not be misrepresented; you must not 13 * claim that you wrote the original software. If you use this software 14 * in a product, an acknowledgment in the product documentation would be 15 * appreciated but is not required. 16 * 2. Altered source versions must be plainly marked as such, and must not be 17 * misrepresented as being the original software. 18 * 3. This notice may not be removed or altered from any source distribution. 19 **/ 20 21 #include "Keyboard.h" 22 23 namespace love 24 { 25 namespace keyboard 26 { 27 getConstant(const char * in,Keyboard::Key & out)28 bool Keyboard::getConstant(const char * in, Keyboard::Key & out) 29 { 30 return keys.find(in, out); 31 } 32 getConstant(Keyboard::Key in,const char * & out)33 bool Keyboard::getConstant(Keyboard::Key in, const char *& out) 34 { 35 return keys.find(in, out); 36 } 37 38 StringMap<Keyboard::Key, Keyboard::KEY_MAX_ENUM>::Entry Keyboard::keyEntries[] = 39 { 40 {"backspace", Keyboard::KEY_BACKSPACE}, 41 {"tab", Keyboard::KEY_TAB}, 42 {"clear", Keyboard::KEY_CLEAR}, 43 {"return", Keyboard::KEY_RETURN}, 44 {"pause", Keyboard::KEY_PAUSE}, 45 {"escape", Keyboard::KEY_ESCAPE}, 46 {" ", Keyboard::KEY_SPACE}, 47 {"!", Keyboard::KEY_EXCLAIM}, 48 {"\"", Keyboard::KEY_QUOTEDBL}, 49 {"#", Keyboard::KEY_HASH}, 50 {"$", Keyboard::KEY_DOLLAR}, 51 {"&", Keyboard::KEY_AMPERSAND}, 52 {"'", Keyboard::KEY_QUOTE}, 53 {"(", Keyboard::KEY_LEFTPAREN}, 54 {")", Keyboard::KEY_RIGHTPAREN}, 55 {"*", Keyboard::KEY_ASTERISK}, 56 {"+", Keyboard::KEY_PLUS}, 57 {",", Keyboard::KEY_COMMA}, 58 {"-", Keyboard::KEY_MINUS}, 59 {".", Keyboard::KEY_PERIOD}, 60 {"/", Keyboard::KEY_SLASH}, 61 {"0", Keyboard::KEY_0}, 62 {"1", Keyboard::KEY_1}, 63 {"2", Keyboard::KEY_2}, 64 {"3", Keyboard::KEY_3}, 65 {"4", Keyboard::KEY_4}, 66 {"5", Keyboard::KEY_5}, 67 {"6", Keyboard::KEY_6}, 68 {"7", Keyboard::KEY_7}, 69 {"8", Keyboard::KEY_8}, 70 {"9", Keyboard::KEY_9}, 71 {":", Keyboard::KEY_COLON}, 72 {";", Keyboard::KEY_SEMICOLON}, 73 {"<", Keyboard::KEY_LESS}, 74 {"=", Keyboard::KEY_EQUALS}, 75 {">", Keyboard::KEY_GREATER}, 76 {"?", Keyboard::KEY_QUESTION}, 77 {"@", Keyboard::KEY_AT}, 78 79 {"[", Keyboard::KEY_LEFTBRACKET}, 80 {"\\", Keyboard::KEY_BACKSLASH}, 81 {"]", Keyboard::KEY_RIGHTBRACKET}, 82 {"^", Keyboard::KEY_CARET}, 83 {"_", Keyboard::KEY_UNDERSCORE}, 84 {"`", Keyboard::KEY_BACKQUOTE}, 85 {"a", Keyboard::KEY_A}, 86 {"b", Keyboard::KEY_B}, 87 {"c", Keyboard::KEY_C}, 88 {"d", Keyboard::KEY_D}, 89 {"e", Keyboard::KEY_E}, 90 {"f", Keyboard::KEY_F}, 91 {"g", Keyboard::KEY_G}, 92 {"h", Keyboard::KEY_H}, 93 {"i", Keyboard::KEY_I}, 94 {"j", Keyboard::KEY_J}, 95 {"k", Keyboard::KEY_K}, 96 {"l", Keyboard::KEY_L}, 97 {"m", Keyboard::KEY_M}, 98 {"n", Keyboard::KEY_N}, 99 {"o", Keyboard::KEY_O}, 100 {"p", Keyboard::KEY_P}, 101 {"q", Keyboard::KEY_Q}, 102 {"r", Keyboard::KEY_R}, 103 {"s", Keyboard::KEY_S}, 104 {"t", Keyboard::KEY_T}, 105 {"u", Keyboard::KEY_U}, 106 {"v", Keyboard::KEY_V}, 107 {"w", Keyboard::KEY_W}, 108 {"x", Keyboard::KEY_X}, 109 {"y", Keyboard::KEY_Y}, 110 {"z", Keyboard::KEY_Z}, 111 {"delete", Keyboard::KEY_DELETE}, 112 113 {"kp0", Keyboard::KEY_KP0}, 114 {"kp1", Keyboard::KEY_KP1}, 115 {"kp2", Keyboard::KEY_KP2}, 116 {"kp3", Keyboard::KEY_KP3}, 117 {"kp4", Keyboard::KEY_KP4}, 118 {"kp5", Keyboard::KEY_KP5}, 119 {"kp6", Keyboard::KEY_KP6}, 120 {"kp7", Keyboard::KEY_KP7}, 121 {"kp8", Keyboard::KEY_KP8}, 122 {"kp9", Keyboard::KEY_KP9}, 123 {"kp.", Keyboard::KEY_KP_PERIOD}, 124 {"kp/", Keyboard::KEY_KP_DIVIDE}, 125 {"kp*", Keyboard::KEY_KP_MULTIPLY}, 126 {"kp-", Keyboard::KEY_KP_MINUS}, 127 {"kp+", Keyboard::KEY_KP_PLUS}, 128 {"kpenter", Keyboard::KEY_KP_ENTER}, 129 {"kp=", Keyboard::KEY_KP_EQUALS}, 130 131 {"up", Keyboard::KEY_UP}, 132 {"down", Keyboard::KEY_DOWN}, 133 {"right", Keyboard::KEY_RIGHT}, 134 {"left", Keyboard::KEY_LEFT}, 135 {"insert", Keyboard::KEY_INSERT}, 136 {"home", Keyboard::KEY_HOME}, 137 {"end", Keyboard::KEY_END}, 138 {"pageup", Keyboard::KEY_PAGEUP}, 139 {"pagedown", Keyboard::KEY_PAGEDOWN}, 140 141 {"f1", Keyboard::KEY_F1}, 142 {"f2", Keyboard::KEY_F2}, 143 {"f3", Keyboard::KEY_F3}, 144 {"f4", Keyboard::KEY_F4}, 145 {"f5", Keyboard::KEY_F5}, 146 {"f6", Keyboard::KEY_F6}, 147 {"f7", Keyboard::KEY_F7}, 148 {"f8", Keyboard::KEY_F8}, 149 {"f9", Keyboard::KEY_F9}, 150 {"f10", Keyboard::KEY_F10}, 151 {"f11", Keyboard::KEY_F11}, 152 {"f12", Keyboard::KEY_F12}, 153 {"f13", Keyboard::KEY_F13}, 154 {"f14", Keyboard::KEY_F14}, 155 {"f15", Keyboard::KEY_F15}, 156 157 {"numlock", Keyboard::KEY_NUMLOCK}, 158 {"capslock", Keyboard::KEY_CAPSLOCK}, 159 {"scrollock", Keyboard::KEY_SCROLLOCK}, 160 {"rshift", Keyboard::KEY_RSHIFT}, 161 {"lshift", Keyboard::KEY_LSHIFT}, 162 {"rctrl", Keyboard::KEY_RCTRL}, 163 {"lctrl", Keyboard::KEY_LCTRL}, 164 {"ralt", Keyboard::KEY_RALT}, 165 {"lalt", Keyboard::KEY_LALT}, 166 {"rmeta", Keyboard::KEY_RMETA}, 167 {"lmeta", Keyboard::KEY_LMETA}, 168 {"lsuper", Keyboard::KEY_LSUPER}, 169 {"rsuper", Keyboard::KEY_RSUPER}, 170 {"mode", Keyboard::KEY_MODE}, 171 {"compose", Keyboard::KEY_COMPOSE}, 172 173 {"help", Keyboard::KEY_HELP}, 174 {"print", Keyboard::KEY_PRINT}, 175 {"sysreq", Keyboard::KEY_SYSREQ}, 176 {"break", Keyboard::KEY_BREAK}, 177 {"menu", Keyboard::KEY_MENU}, 178 {"power", Keyboard::KEY_POWER}, 179 {"euro", Keyboard::KEY_EURO}, 180 {"undo", Keyboard::KEY_UNDO}, 181 }; 182 183 StringMap<Keyboard::Key, Keyboard::KEY_MAX_ENUM> Keyboard::keys(Keyboard::keyEntries, sizeof(Keyboard::keyEntries)); 184 185 186 } // keyboard 187 } // love 188