Changeset 7203 in orxonox.OLD for branches/std/src/lib/event
- Timestamp:
- Mar 9, 2006, 5:28:10 PM (19 years ago)
- Location:
- branches/std/src/lib/event
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/std/src/lib/event/key_mapper.cc
r6998 r7203 129 129 * @param filename: The path and name of the file to load the bindings from 130 130 */ 131 void KeyMapper::loadKeyBindings (const char*fileName)131 void KeyMapper::loadKeyBindings (const std::string& fileName) 132 132 { 133 133 IniParser parser(fileName); … … 145 145 146 146 iniParser->firstVar(); 147 while(iniParser->getCurrentName() )147 while(iniParser->getCurrentName() != "") 148 148 { 149 149 PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue()); … … 164 164 165 165 iniParser->firstVar(); 166 while(iniParser->getCurrentName() )166 while(iniParser->getCurrentName() != "") 167 167 { 168 168 PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue()); … … 177 177 * @param the name of the button 178 178 */ 179 int* KeyMapper::nameToIndex (const char*name)179 int* KeyMapper::nameToIndex (const std::string& name) 180 180 { 181 181 coord[0] = -1; … … 199 199 * @param id of the key 200 200 */ 201 void KeyMapper::mapKeys(const char*name, int* index)201 void KeyMapper::mapKeys(const std::string& name, int* index) 202 202 { 203 203 for( int i = 0; map[i].pValue != NULL; ++i ) 204 204 { 205 if( !strcmp (name, map[i].pName))205 if( name == map[i].pName) 206 206 { 207 207 if( index[0] == 0) -
branches/std/src/lib/event/key_mapper.h
r6998 r7203 29 29 virtual ~KeyMapper(); 30 30 31 void loadKeyBindings(const char*fileName = NULL);31 void loadKeyBindings(const std::string& fileName = NULL); 32 32 void loadKeyBindings(IniParser* iniParser); 33 33 … … 35 35 36 36 private: 37 int* nameToIndex (const char*name);38 void mapKeys(const char*name, int* index);37 int* nameToIndex (const std::string& name); 38 void mapKeys(const std::string& name, int* index); 39 39 40 40 public: -
branches/std/src/lib/event/key_names.cc
r5476 r7203 23 23 using namespace std; 24 24 25 int buttonnameToSDLB(const char*name)25 int buttonnameToSDLB(const std::string& name) 26 26 { 27 if( !strcmp (name,"BUTTON_LEFT")) return EV_MOUSE_BUTTON_LEFT;28 if( !strcmp (name,"BUTTON_MIDDLE")) return EV_MOUSE_BUTTON_MIDDLE;29 if( !strcmp (name,"BUTTON_RIGHT")) return EV_MOUSE_BUTTON_RIGHT;30 if( !strcmp (name,"BUTTON_WHEELUP")) return EV_MOUSE_BUTTON_WHEELUP;31 if( !strcmp (name,"BUTTON_WHEELDOWN")) return EV_MOUSE_BUTTON_WHEELDOWN;27 if((name == "BUTTON_LEFT")) return EV_MOUSE_BUTTON_LEFT; 28 if((name == "BUTTON_MIDDLE")) return EV_MOUSE_BUTTON_MIDDLE; 29 if((name == "BUTTON_RIGHT")) return EV_MOUSE_BUTTON_RIGHT; 30 if((name == "BUTTON_WHEELUP")) return EV_MOUSE_BUTTON_WHEELUP; 31 if((name == "BUTTON_WHEELDOWN")) return EV_MOUSE_BUTTON_WHEELDOWN; 32 32 return -1; 33 33 } … … 43 43 } 44 44 45 int keynameToSDLK(const char*name)45 int keynameToSDLK(const std::string& name) 46 46 { 47 if( !strcmp (name,"BACKSPACE")) return SDLK_BACKSPACE;48 if( !strcmp (name,"TAB")) return SDLK_TAB;49 if( !strcmp (name,"CLEAR")) return SDLK_CLEAR;50 if( !strcmp (name,"RETURN")) return SDLK_RETURN;51 if( !strcmp (name,"ESCAPE")) return SDLK_ESCAPE;52 if( !strcmp (name,"SPACE")) return SDLK_SPACE;53 if( !strcmp (name,"EXCLAIM")) return SDLK_EXCLAIM;54 if( !strcmp (name,"QUOTEDBL")) return SDLK_QUOTEDBL;55 if( !strcmp (name,"HASH")) return SDLK_HASH;56 if( !strcmp (name,"PAUSE")) return SDLK_PAUSE;57 if( !strcmp (name,"DOLLAR")) return SDLK_DOLLAR;58 if( !strcmp (name,"AMPERSAND")) return SDLK_AMPERSAND;59 if( !strcmp (name,"QUOTE")) return SDLK_QUOTE;60 if( !strcmp (name,"LEFTPAREN")) return SDLK_LEFTPAREN;61 if( !strcmp (name,"RIGHTPAREN")) return SDLK_RIGHTPAREN;62 if( !strcmp (name,"ASTERISK")) return SDLK_ASTERISK;63 if( !strcmp (name,"PLUS")) return SDLK_PLUS;64 if( !strcmp (name,"COMMA")) return SDLK_COMMA;65 if( !strcmp (name,"MINUS")) return SDLK_MINUS;66 if( !strcmp (name,"PERIOD")) return SDLK_PERIOD;67 if( !strcmp (name,"SLASH")) return SDLK_SLASH;68 if( !strcmp (name,"0")) return SDLK_0;69 if( !strcmp (name,"1")) return SDLK_1;70 if( !strcmp (name,"2")) return SDLK_2;71 if( !strcmp (name,"3")) return SDLK_3;72 if( !strcmp (name,"4")) return SDLK_4;73 if( !strcmp (name,"5")) return SDLK_5;74 if( !strcmp (name,"6")) return SDLK_6;75 if( !strcmp (name,"7")) return SDLK_7;76 if( !strcmp (name,"8")) return SDLK_8;77 if( !strcmp (name,"9")) return SDLK_9;78 if( !strcmp (name,"COLON")) return SDLK_COLON;79 if( !strcmp (name,"SEMICOLON")) return SDLK_SEMICOLON;80 if( !strcmp (name,"LESS")) return SDLK_LESS;81 if( !strcmp (name,"EQUALS")) return SDLK_EQUALS;82 if( !strcmp (name,"GREATER")) return SDLK_GREATER;83 if( !strcmp (name,"QUESTION")) return SDLK_QUESTION;84 if( !strcmp (name,"AT")) return SDLK_AT;85 if( !strcmp (name,"LEFTBRACKET")) return SDLK_LEFTBRACKET;86 if( !strcmp (name,"BACKSLASH")) return SDLK_BACKSLASH;87 if( !strcmp (name,"RIGHTBRACKET")) return SDLK_RIGHTBRACKET;88 if( !strcmp (name,"CARET")) return SDLK_CARET;89 if( !strcmp (name,"UNDERSCORE")) return SDLK_UNDERSCORE;90 if( !strcmp (name,"BACKQUOTE")) return SDLK_BACKQUOTE;91 if( !strcmp (name,"a")) return SDLK_a;92 if( !strcmp (name,"b")) return SDLK_b;93 if( !strcmp (name,"c")) return SDLK_c;94 if( !strcmp (name,"d")) return SDLK_d;95 if( !strcmp (name,"e")) return SDLK_e;96 if( !strcmp (name,"f")) return SDLK_f;97 if( !strcmp (name,"g")) return SDLK_g;98 if( !strcmp (name,"h")) return SDLK_h;99 if( !strcmp (name,"i")) return SDLK_i;100 if( !strcmp (name,"j")) return SDLK_j;101 if( !strcmp (name,"k")) return SDLK_k;102 if( !strcmp (name,"l")) return SDLK_l;103 if( !strcmp (name,"m")) return SDLK_m;104 if( !strcmp (name,"n")) return SDLK_n;105 if( !strcmp (name,"o")) return SDLK_o;106 if( !strcmp (name,"p")) return SDLK_p;107 if( !strcmp (name,"q")) return SDLK_q;108 if( !strcmp (name,"r")) return SDLK_r;109 if( !strcmp (name,"s")) return SDLK_s;110 if( !strcmp (name,"t")) return SDLK_t;111 if( !strcmp (name,"u")) return SDLK_u;112 if( !strcmp (name,"v")) return SDLK_v;113 if( !strcmp (name,"w")) return SDLK_w;114 if( !strcmp (name,"x")) return SDLK_x;115 if( !strcmp (name,"y")) return SDLK_y;116 if( !strcmp (name,"z")) return SDLK_z;117 if( !strcmp (name,"DELETE")) return SDLK_DELETE;118 if( !strcmp (name,"KP0")) return SDLK_KP0;119 if( !strcmp (name,"KP1")) return SDLK_KP1;120 if( !strcmp (name,"KP2")) return SDLK_KP2;121 if( !strcmp (name,"KP3")) return SDLK_KP3;122 if( !strcmp (name,"KP4")) return SDLK_KP4;123 if( !strcmp (name,"KP5")) return SDLK_KP5;124 if( !strcmp (name,"KP6")) return SDLK_KP6;125 if( !strcmp (name,"KP7")) return SDLK_KP7;126 if( !strcmp (name,"KP8")) return SDLK_KP8;127 if( !strcmp (name,"KP9")) return SDLK_KP9;128 if( !strcmp (name,"KP_PERIOD")) return SDLK_KP_PERIOD;129 if( !strcmp (name,"KP_DIVIDE")) return SDLK_KP_DIVIDE;130 if( !strcmp (name,"KP_MULTIPLY")) return SDLK_KP_MULTIPLY;131 if( !strcmp (name,"KP_MINUS")) return SDLK_KP_MINUS;132 if( !strcmp (name,"KP_PLUS")) return SDLK_KP_PLUS;133 if( !strcmp (name,"KP_ENTER")) return SDLK_KP_ENTER;134 if( !strcmp (name,"KP_EQUALS")) return SDLK_KP_EQUALS;135 if( !strcmp (name,"UP")) return SDLK_UP;136 if( !strcmp (name,"DOWN")) return SDLK_DOWN;137 if( !strcmp (name,"RIGHT")) return SDLK_RIGHT;138 if( !strcmp (name,"LEFT")) return SDLK_LEFT;139 if( !strcmp (name,"INSERT")) return SDLK_INSERT;140 if( !strcmp (name,"HOME")) return SDLK_HOME;141 if( !strcmp (name,"END")) return SDLK_END;142 if( !strcmp (name,"PAGEUP")) return SDLK_PAGEUP;143 if( !strcmp (name,"PAGEDOWN")) return SDLK_PAGEDOWN;144 if( !strcmp (name,"F1")) return SDLK_F1;145 if( !strcmp (name,"F2")) return SDLK_F2;146 if( !strcmp (name,"F3")) return SDLK_F3;147 if( !strcmp (name,"F4")) return SDLK_F4;148 if( !strcmp (name,"F5")) return SDLK_F5;149 if( !strcmp (name,"F6")) return SDLK_F6;150 if( !strcmp (name,"F7")) return SDLK_F7;151 if( !strcmp (name,"F8")) return SDLK_F8;152 if( !strcmp (name,"F9")) return SDLK_F9;153 if( !strcmp (name,"F10")) return SDLK_F10;154 if( !strcmp (name,"F11")) return SDLK_F11;155 if( !strcmp (name,"F12")) return SDLK_F12;156 if( !strcmp (name,"F13")) return SDLK_F13;157 if( !strcmp (name,"F14")) return SDLK_F14;158 if( !strcmp (name,"F15")) return SDLK_F15;159 if( !strcmp (name,"NUMLOCK")) return SDLK_NUMLOCK;160 if( !strcmp (name,"CAPSLOCK")) return SDLK_CAPSLOCK;161 if( !strcmp (name,"SCROLLOCK")) return SDLK_SCROLLOCK;162 if( !strcmp (name,"RSHIFT")) return SDLK_RSHIFT;163 if( !strcmp (name,"LSHIFT")) return SDLK_LSHIFT;164 if( !strcmp (name,"RCTRL")) return SDLK_RCTRL;165 if( !strcmp (name,"LCTRL")) return SDLK_LCTRL;166 if( !strcmp (name,"RALT")) return SDLK_RALT;167 if( !strcmp (name,"LALT")) return SDLK_LALT;168 if( !strcmp (name,"RMETA")) return SDLK_RMETA;169 if( !strcmp (name,"LMETA")) return SDLK_LMETA;170 if( !strcmp (name,"LSUPER")) return SDLK_LSUPER;171 if( !strcmp (name,"RSUPER")) return SDLK_RSUPER;172 if( !strcmp (name,"MODE")) return SDLK_MODE;173 if( !strcmp (name,"HELP")) return SDLK_HELP;174 if( !strcmp (name,"PRINT")) return SDLK_PRINT;175 if( !strcmp (name,"SYSREQ")) return SDLK_SYSREQ;176 if( !strcmp (name,"BREAK")) return SDLK_BREAK;177 if( !strcmp (name,"MENU")) return SDLK_MENU;178 if( !strcmp (name,"POWER")) return SDLK_POWER;179 if( !strcmp (name,"EURO")) return SDLK_EURO;47 if((name == "BACKSPACE")) return SDLK_BACKSPACE; 48 if((name == "TAB")) return SDLK_TAB; 49 if((name == "CLEAR")) return SDLK_CLEAR; 50 if((name == "RETURN")) return SDLK_RETURN; 51 if((name == "ESCAPE")) return SDLK_ESCAPE; 52 if((name == "SPACE")) return SDLK_SPACE; 53 if((name == "EXCLAIM")) return SDLK_EXCLAIM; 54 if((name == "QUOTEDBL")) return SDLK_QUOTEDBL; 55 if((name == "HASH")) return SDLK_HASH; 56 if((name == "PAUSE")) return SDLK_PAUSE; 57 if((name == "DOLLAR")) return SDLK_DOLLAR; 58 if((name == "AMPERSAND")) return SDLK_AMPERSAND; 59 if((name == "QUOTE")) return SDLK_QUOTE; 60 if((name == "LEFTPAREN")) return SDLK_LEFTPAREN; 61 if((name == "RIGHTPAREN")) return SDLK_RIGHTPAREN; 62 if((name == "ASTERISK")) return SDLK_ASTERISK; 63 if((name == "PLUS")) return SDLK_PLUS; 64 if((name == "COMMA")) return SDLK_COMMA; 65 if((name == "MINUS")) return SDLK_MINUS; 66 if((name == "PERIOD")) return SDLK_PERIOD; 67 if((name == "SLASH")) return SDLK_SLASH; 68 if((name == "0")) return SDLK_0; 69 if((name == "1")) return SDLK_1; 70 if((name == "2")) return SDLK_2; 71 if((name == "3")) return SDLK_3; 72 if((name == "4")) return SDLK_4; 73 if((name == "5")) return SDLK_5; 74 if((name == "6")) return SDLK_6; 75 if((name == "7")) return SDLK_7; 76 if((name == "8")) return SDLK_8; 77 if((name == "9")) return SDLK_9; 78 if((name == "COLON")) return SDLK_COLON; 79 if((name == "SEMICOLON")) return SDLK_SEMICOLON; 80 if((name == "LESS")) return SDLK_LESS; 81 if((name == "EQUALS")) return SDLK_EQUALS; 82 if((name == "GREATER")) return SDLK_GREATER; 83 if((name == "QUESTION")) return SDLK_QUESTION; 84 if((name == "AT")) return SDLK_AT; 85 if((name == "LEFTBRACKET")) return SDLK_LEFTBRACKET; 86 if((name == "BACKSLASH")) return SDLK_BACKSLASH; 87 if((name == "RIGHTBRACKET")) return SDLK_RIGHTBRACKET; 88 if((name == "CARET")) return SDLK_CARET; 89 if((name == "UNDERSCORE")) return SDLK_UNDERSCORE; 90 if((name == "BACKQUOTE")) return SDLK_BACKQUOTE; 91 if((name == "a")) return SDLK_a; 92 if((name == "b")) return SDLK_b; 93 if((name == "c")) return SDLK_c; 94 if((name == "d")) return SDLK_d; 95 if((name == "e")) return SDLK_e; 96 if((name == "f")) return SDLK_f; 97 if((name == "g")) return SDLK_g; 98 if((name == "h")) return SDLK_h; 99 if((name == "i")) return SDLK_i; 100 if((name == "j")) return SDLK_j; 101 if((name == "k")) return SDLK_k; 102 if((name == "l")) return SDLK_l; 103 if((name == "m")) return SDLK_m; 104 if((name == "n")) return SDLK_n; 105 if((name == "o")) return SDLK_o; 106 if((name == "p")) return SDLK_p; 107 if((name == "q")) return SDLK_q; 108 if((name == "r")) return SDLK_r; 109 if((name == "s")) return SDLK_s; 110 if((name == "t")) return SDLK_t; 111 if((name == "u")) return SDLK_u; 112 if((name == "v")) return SDLK_v; 113 if((name == "w")) return SDLK_w; 114 if((name == "x")) return SDLK_x; 115 if((name == "y")) return SDLK_y; 116 if((name == "z")) return SDLK_z; 117 if((name == "DELETE")) return SDLK_DELETE; 118 if((name == "KP0")) return SDLK_KP0; 119 if((name == "KP1")) return SDLK_KP1; 120 if((name == "KP2")) return SDLK_KP2; 121 if((name == "KP3")) return SDLK_KP3; 122 if((name == "KP4")) return SDLK_KP4; 123 if((name == "KP5")) return SDLK_KP5; 124 if((name == "KP6")) return SDLK_KP6; 125 if((name == "KP7")) return SDLK_KP7; 126 if((name == "KP8")) return SDLK_KP8; 127 if((name == "KP9")) return SDLK_KP9; 128 if((name == "KP_PERIOD")) return SDLK_KP_PERIOD; 129 if((name == "KP_DIVIDE")) return SDLK_KP_DIVIDE; 130 if((name == "KP_MULTIPLY")) return SDLK_KP_MULTIPLY; 131 if((name == "KP_MINUS")) return SDLK_KP_MINUS; 132 if((name == "KP_PLUS")) return SDLK_KP_PLUS; 133 if((name == "KP_ENTER")) return SDLK_KP_ENTER; 134 if((name == "KP_EQUALS")) return SDLK_KP_EQUALS; 135 if((name == "UP")) return SDLK_UP; 136 if((name == "DOWN")) return SDLK_DOWN; 137 if((name == "RIGHT")) return SDLK_RIGHT; 138 if((name == "LEFT")) return SDLK_LEFT; 139 if((name == "INSERT")) return SDLK_INSERT; 140 if((name == "HOME")) return SDLK_HOME; 141 if((name == "END")) return SDLK_END; 142 if((name == "PAGEUP")) return SDLK_PAGEUP; 143 if((name == "PAGEDOWN")) return SDLK_PAGEDOWN; 144 if((name == "F1")) return SDLK_F1; 145 if((name == "F2")) return SDLK_F2; 146 if((name == "F3")) return SDLK_F3; 147 if((name == "F4")) return SDLK_F4; 148 if((name == "F5")) return SDLK_F5; 149 if((name == "F6")) return SDLK_F6; 150 if((name == "F7")) return SDLK_F7; 151 if((name == "F8")) return SDLK_F8; 152 if((name == "F9")) return SDLK_F9; 153 if((name == "F10")) return SDLK_F10; 154 if((name == "F11")) return SDLK_F11; 155 if((name == "F12")) return SDLK_F12; 156 if((name == "F13")) return SDLK_F13; 157 if((name == "F14")) return SDLK_F14; 158 if((name == "F15")) return SDLK_F15; 159 if((name == "NUMLOCK")) return SDLK_NUMLOCK; 160 if((name == "CAPSLOCK")) return SDLK_CAPSLOCK; 161 if((name == "SCROLLOCK")) return SDLK_SCROLLOCK; 162 if((name == "RSHIFT")) return SDLK_RSHIFT; 163 if((name == "LSHIFT")) return SDLK_LSHIFT; 164 if((name == "RCTRL")) return SDLK_RCTRL; 165 if((name == "LCTRL")) return SDLK_LCTRL; 166 if((name == "RALT")) return SDLK_RALT; 167 if((name == "LALT")) return SDLK_LALT; 168 if((name == "RMETA")) return SDLK_RMETA; 169 if((name == "LMETA")) return SDLK_LMETA; 170 if((name == "LSUPER")) return SDLK_LSUPER; 171 if((name == "RSUPER")) return SDLK_RSUPER; 172 if((name == "MODE")) return SDLK_MODE; 173 if((name == "HELP")) return SDLK_HELP; 174 if((name == "PRINT")) return SDLK_PRINT; 175 if((name == "SYSREQ")) return SDLK_SYSREQ; 176 if((name == "BREAK")) return SDLK_BREAK; 177 if((name == "MENU")) return SDLK_MENU; 178 if((name == "POWER")) return SDLK_POWER; 179 if((name == "EURO")) return SDLK_EURO; 180 180 return -1; 181 181 } 182 182 183 const char* SDLKToKeyname( 183 const char* SDLKToKeyname(int key) 184 184 { 185 185 if( key == SDLK_BACKSPACE) return "BACKSPACE"; -
branches/std/src/lib/event/key_names.h
r5474 r7203 1 1 /*! 2 2 * @file keynames.h 3 4 5 6 */3 * Key/button naming functions 4 * 5 * Converts strings to SDLK/SDL_BUTTON values and vice versa 6 */ 7 7 #ifndef _KEY_NAMES_H 8 8 #define _KEY_NAMES_H 9 9 10 /** 11 * converts a button name string to a integer representing the corresponding SDL mouse button identifier 12 * @param name: the name of the mouse button 13 * @return an int containing the SDL identifier of the mouse button or -1 if the button name is not valid 14 */ 15 int buttonnameToSDLB(const char* name); 10 #include <string> 16 11 17 12 /** 18 * converst a SDL mouse button identifier to a name string 19 * @param button: an SDL mouse button identifier 20 * @return a pointer to a string containing the name of the mouse button 21 */ 13 * converts a button name string to a integer representing the corresponding SDL mouse button identifier 14 * @param name: the name of the mouse button 15 * @return an int containing the SDL identifier of the mouse button or -1 if the button name is not valid 16 */ 17 int buttonnameToSDLB(const std::string& name); 18 19 /** 20 * converst a SDL mouse button identifier to a name string 21 * @param button: an SDL mouse button identifier 22 * @return a pointer to a string containing the name of the mouse button 23 */ 22 24 const char* SDLBToButtonname( int button); 23 25 24 26 /** 25 26 27 28 */29 int keynameToSDLK(const char*name);27 * converts a key name string to a integer representing the corresponding SDLK sym 28 * @param name: the name of the key 29 * @return the SDLK sym of the named key or -1 if the key name is not valid 30 */ 31 int keynameToSDLK(const std::string& name); 30 32 31 33 /** 32 33 34 35 */34 * converts an SDLK sym to a name string 35 * @param key: the SDLK sym 36 * @return a pointer to a string containig the name of the key 37 */ 36 38 const char* SDLKToKeyname( int key); 37 39
Note: See TracChangeset
for help on using the changeset viewer.