1 /** 2 * Copyright (c) 2006-2012 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 #ifndef LOVE_KEYBOARD_KEYBOARD_H 22 #define LOVE_KEYBOARD_KEYBOARD_H 23 24 // LOVE 25 #include <common/Module.h> 26 #include <common/StringMap.h> 27 28 namespace love 29 { 30 namespace keyboard 31 { 32 class Keyboard : public Module 33 { 34 public: 35 36 enum Key 37 { 38 KEY_UNKNOWN, 39 KEY_BACKSPACE, 40 KEY_TAB, 41 KEY_CLEAR, 42 KEY_RETURN, 43 KEY_PAUSE, 44 KEY_ESCAPE, 45 KEY_SPACE, 46 KEY_EXCLAIM, 47 KEY_QUOTEDBL, 48 KEY_HASH, 49 KEY_DOLLAR, 50 KEY_AMPERSAND, 51 KEY_QUOTE, 52 KEY_LEFTPAREN, 53 KEY_RIGHTPAREN, 54 KEY_ASTERISK, 55 KEY_PLUS, 56 KEY_COMMA, 57 KEY_MINUS, 58 KEY_PERIOD, 59 KEY_SLASH, 60 KEY_0, 61 KEY_1, 62 KEY_2, 63 KEY_3, 64 KEY_4, 65 KEY_5, 66 KEY_6, 67 KEY_7, 68 KEY_8, 69 KEY_9, 70 KEY_COLON, 71 KEY_SEMICOLON, 72 KEY_LESS, 73 KEY_EQUALS, 74 KEY_GREATER, 75 KEY_QUESTION, 76 KEY_AT, 77 78 KEY_LEFTBRACKET, 79 KEY_BACKSLASH, 80 KEY_RIGHTBRACKET, 81 KEY_CARET, 82 KEY_UNDERSCORE, 83 KEY_BACKQUOTE, 84 KEY_A, 85 KEY_B, 86 KEY_C, 87 KEY_D, 88 KEY_E, 89 KEY_F, 90 KEY_G, 91 KEY_H, 92 KEY_I, 93 KEY_J, 94 KEY_K, 95 KEY_L, 96 KEY_M, 97 KEY_N, 98 KEY_O, 99 KEY_P, 100 KEY_Q, 101 KEY_R, 102 KEY_S, 103 KEY_T, 104 KEY_U, 105 KEY_V, 106 KEY_W, 107 KEY_X, 108 KEY_Y, 109 KEY_Z, 110 KEY_DELETE, 111 112 KEY_KP0, 113 KEY_KP1, 114 KEY_KP2, 115 KEY_KP3, 116 KEY_KP4, 117 KEY_KP5, 118 KEY_KP6, 119 KEY_KP7, 120 KEY_KP8, 121 KEY_KP9, 122 KEY_KP_PERIOD, 123 KEY_KP_DIVIDE, 124 KEY_KP_MULTIPLY, 125 KEY_KP_MINUS, 126 KEY_KP_PLUS, 127 KEY_KP_ENTER, 128 KEY_KP_EQUALS, 129 130 KEY_UP, 131 KEY_DOWN, 132 KEY_RIGHT, 133 KEY_LEFT, 134 KEY_INSERT, 135 KEY_HOME, 136 KEY_END, 137 KEY_PAGEUP, 138 KEY_PAGEDOWN, 139 140 KEY_F1, 141 KEY_F2, 142 KEY_F3, 143 KEY_F4, 144 KEY_F5, 145 KEY_F6, 146 KEY_F7, 147 KEY_F8, 148 KEY_F9, 149 KEY_F10, 150 KEY_F11, 151 KEY_F12, 152 KEY_F13, 153 KEY_F14, 154 KEY_F15, 155 156 KEY_NUMLOCK, 157 KEY_CAPSLOCK, 158 KEY_SCROLLOCK, 159 KEY_RSHIFT, 160 KEY_LSHIFT, 161 KEY_RCTRL, 162 KEY_LCTRL, 163 KEY_RALT, 164 KEY_LALT, 165 KEY_RMETA, 166 KEY_LMETA, 167 KEY_LSUPER, 168 KEY_RSUPER, 169 KEY_MODE, 170 KEY_COMPOSE, 171 172 KEY_HELP, 173 KEY_PRINT, 174 KEY_SYSREQ, 175 KEY_BREAK, 176 KEY_MENU, 177 KEY_POWER, 178 KEY_EURO, 179 KEY_UNDO, 180 KEY_MAX_ENUM = 512 181 }; 182 183 static const int DEFAULT = -1; 184 ~Keyboard()185 virtual ~Keyboard(){} 186 187 /** 188 * Checks whether a certain key is down or not. 189 * @param key A key identifier. 190 * @return boolean 191 **/ 192 virtual bool isDown(Key * keylist) const = 0; 193 194 /** 195 * Enables key repeating. 196 * @param delay The amount of delay before repeating the key (in milliseconds) 197 * @param interval Specifies the amount of time between repeats (in milliseconds) 198 **/ 199 virtual void setKeyRepeat(int delay, int interval) const = 0; 200 201 /** 202 * Gets the specified delay for the key repeat. 203 * @return int 204 **/ 205 virtual int getKeyRepeatDelay() const = 0; 206 207 /** 208 * Gets the specified interval for the key repeat. 209 * @return int 210 **/ 211 virtual int getKeyRepeatInterval() const = 0; 212 213 static bool getConstant(const char * in, Key & out); 214 static bool getConstant(Key in, const char *& out); 215 216 private: 217 218 static StringMap<Key, KEY_MAX_ENUM>::Entry keyEntries[]; 219 static StringMap<Key, KEY_MAX_ENUM> keys; 220 221 }; // Keyboard 222 223 } // keyboard 224 } // love 225 226 #endif // LOVE_KEYBOARD_KEYBOARD_H 227