Changeset 4582 in orxonox.OLD for orxonox/trunk/src/lib/event
- Timestamp:
- Jun 10, 2005, 3:30:52 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/event/key_mapper.cc
r4457 r4582 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 12 12 main-programmer: Patrick Boenzli 13 13 co-programmer: Christian Meyer 14 14 15 15 This code was inspired by the command_node.cc code from Christian Meyer in revision 16 16 4386 and earlier. … … 45 45 int KeyMapper::PEV_VIEW3 = EV_UNKNOWN; 46 46 int KeyMapper::PEV_VIEW4 = EV_UNKNOWN; 47 int KeyMapper::PEV_VIEW5 = EV_UNKNOWN; 47 int KeyMapper::PEV_VIEW5 = EV_UNKNOWN; 48 48 49 49 int KeyMapper::PEV_NEXT_WORLD = EV_UNKNOWN; … … 57 57 //! this is the mapping array from names to ids: enter all orxonox.conf keys here 58 58 orxKeyMapping map[] = { {&KeyMapper::PEV_UP, "Up"}, 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 59 {&KeyMapper::PEV_DOWN, "Down"}, 60 {&KeyMapper::PEV_LEFT, "Left"}, 61 {&KeyMapper::PEV_RIGHT, "Right"}, 62 {&KeyMapper::PEV_STRAFE_LEFT, "StrafeLeft"}, 63 {&KeyMapper::PEV_STRAFE_RIGHT, "StrafeRight"}, 64 65 {&KeyMapper::PEV_FIRE1, "Fire"}, 66 {&KeyMapper::PEV_FIRE1, "Fire1"}, 67 {&KeyMapper::PEV_FIRE2, "Fire2"}, 68 {&KeyMapper::PEV_NEXT_WEAPON, "Next"}, 69 {&KeyMapper::PEV_PREVIOUS_WEAPON, "Prev"}, 70 71 72 {&KeyMapper::PEV_VIEW0, "view0"}, 73 {&KeyMapper::PEV_VIEW1, "view1"}, 74 {&KeyMapper::PEV_VIEW2, "view2"}, 75 {&KeyMapper::PEV_VIEW3, "view3"}, 76 {&KeyMapper::PEV_VIEW4, "view4"}, 77 {&KeyMapper::PEV_VIEW5, "view5"}, 78 79 {&KeyMapper::PEV_NEXT_WORLD, "Next-World"}, 80 {&KeyMapper::PEV_PREVIOUS_WORLD, "Prev-World"}, 81 82 {&KeyMapper::PEV_PAUSE, "Pause"}, 83 {&KeyMapper::PEV_QUIT, "Quit"}, 84 84 {NULL, NULL}}; 85 85 … … 89 89 \brief standard constructor 90 90 */ 91 KeyMapper::KeyMapper () 92 { 93 this->setClassID(CL_KEY_MAPPER, "KeyMapper"); 91 KeyMapper::KeyMapper () 92 { 93 this->setClassID(CL_KEY_MAPPER, "KeyMapper"); 94 94 } 95 95 … … 98 98 \brief standard deconstructor 99 99 */ 100 KeyMapper::~KeyMapper () 100 KeyMapper::~KeyMapper () 101 101 { 102 102 } … … 110 110 { 111 111 FILE* stream; 112 112 113 113 PRINTF(4)("Loading key bindings from %s\n", fileName); 114 114 115 115 // create parser 116 116 IniParser parser(fileName); … … 121 121 } 122 122 // allocate empty lookup table 123 123 124 124 char namebuf[256]; 125 125 char valuebuf[256]; … … 127 127 memset (valuebuf, 0, 256); 128 128 int* index; 129 129 130 130 while( parser.nextVar (namebuf, valuebuf) != -1) 131 131 { … … 136 136 /* 137 137 switch( index[0]) 138 139 140 141 142 143 144 145 146 147 138 { 139 case 0: 140 this->mapKeys(namebuf, index[1]); 141 break; 142 case 1: 143 this->mapKeys(namebuf, index[1]); 144 break; 145 default: 146 break; 147 } 148 148 */ 149 149 memset (namebuf, 0, 256); … … 162 162 { 163 163 PRINTF(3)("MISC: Parsing %s, %s now.\n", namebuf, valuebuf); 164 index = nameToIndex (valuebuf); 164 index = nameToIndex (valuebuf); 165 165 this->mapKeys(namebuf, index[1]); 166 166 /* 167 167 switch( index[0]) 168 169 170 171 172 173 174 175 176 177 168 { 169 case 0: 170 this->mapKeys(namebuf, index[1]); 171 break; 172 case 1: 173 this->mapKeys(namebuf, index[1]); 174 break; 175 default: 176 break; 177 } 178 178 */ 179 179 memset (namebuf, 0, 256); … … 215 215 for(int i = 0; map[i].pValue != NULL; ++i ) 216 216 { 217 if( !strcmp (name, map[i].pName)) { *map[i].pValue = keyID; break;} 218 PRINTF(0)("Mapping %s to id %i\n", name, keyID); 217 if( !strcmp (name, map[i].pName)) 218 { 219 *map[i].pValue = keyID; 220 PRINTF(0)("Mapping %s to id %i\n", name, keyID); 221 break; 222 } 219 223 } 220 224 } … … 226 230 void KeyMapper::debug() 227 231 { 228 PRINT(0)("\n==========================| KeyMapper::debug() |===\n"); 232 PRINT(0)("\n==========================| KeyMapper::debug() |===\n"); 229 233 for(int i = 0; map[i].pValue != NULL; ++i) 230 234 { 231 235 PRINT(0)("%s = %i\n",map[i].pName, *map[i].pValue); 232 236 } 233 PRINT(0)("=======================================================\n"); 234 } 237 PRINT(0)("=======================================================\n"); 238 }
Note: See TracChangeset
for help on using the changeset viewer.