Changeset 5474 in orxonox.OLD for trunk/src/lib/event
- Timestamp:
- Nov 3, 2005, 2:13:48 PM (19 years ago)
- Location:
- trunk/src/lib/event
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/event/event_handler.cc
r5388 r5474 279 279 case SDL_MOUSEBUTTONUP: 280 280 ev.bPressed = false; 281 ev.type = event.button.button + SDLK_LAST; 281 ev.type = event.button.button + SDLK_LAST -1; 282 printf(">>>>>>>>>>type = %i\n", ev.type); 282 283 break; 283 284 case SDL_MOUSEBUTTONDOWN: 284 285 ev.bPressed = true; 285 ev.type = event.button.button + SDLK_LAST ;286 ev.type = event.button.button + SDLK_LAST -1; 286 287 break; 287 288 case SDL_JOYAXISMOTION: -
trunk/src/lib/event/key_mapper.cc
r5299 r5474 133 133 { 134 134 PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue()); 135 // map the name to an sdl index 135 136 index = nameToIndex (iniParser->getCurrentValue()); 136 this->mapKeys(iniParser->getCurrentName(), index[1]); 137 // map the index to a internal name 138 this->mapKeys(iniParser->getCurrentName(), index); 137 139 iniParser->nextVar(); 138 140 } … … 151 153 PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue()); 152 154 index = nameToIndex (iniParser->getCurrentValue()); 153 this->mapKeys(iniParser->getCurrentName(), index [1]);155 this->mapKeys(iniParser->getCurrentName(), index); 154 156 iniParser->nextVar(); 155 157 } … … 165 167 coord[1] = -1; 166 168 int c; 167 if( (c = keynameToSDLK (name)) != -1) 168 { 169 if( (c = keynameToSDLK (name)) != -1) { 169 170 coord[1] = c; 170 171 coord[0] = 0; 171 172 } 172 if( (c = buttonnameToSDLB (name)) != -1) 173 { 173 if( (c = buttonnameToSDLB (name)) != -1) { 174 174 coord[1] = c; 175 175 coord[0] = 1; … … 184 184 * @param id of the key 185 185 */ 186 void KeyMapper::mapKeys(const char* name, int keyID)187 { 188 for( int i = 0; map[i].pValue != NULL; ++i )186 void KeyMapper::mapKeys(const char* name, int* index) 187 { 188 for( int i = 0; map[i].pValue != NULL; ++i ) 189 189 { 190 190 if( !strcmp (name, map[i].pName)) 191 191 { 192 *map[i].pValue = keyID; 193 PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLKToKeyname(keyID), keyID); 194 break; 192 if( index[0] == 0) 193 { 194 *map[i].pValue = index[1]; 195 PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLKToKeyname(index[1]), index[1]); 196 break; 197 } 198 else { 199 *map[i].pValue = index[1]; 200 PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLBToButtonname(index[1]), index[1]); 201 break; 202 } 195 203 } 196 204 } -
trunk/src/lib/event/key_mapper.h
r5039 r5474 36 36 private: 37 37 int* nameToIndex (const char* name); 38 void mapKeys(const char* name, int keyID);38 void mapKeys(const char* name, int* index); 39 39 40 40 public: -
trunk/src/lib/event/key_names.cc
r4780 r5474 15 15 16 16 #include "key_names.h" 17 #include "event_def.h" 17 18 18 19 #include "stdincl.h" … … 24 25 int buttonnameToSDLB(const char* name) 25 26 { 26 if( !strcmp (name, "BUTTON_LEFT")) return SDL_BUTTON_LEFT; 27 if( !strcmp (name, "BUTTON_LEFT")) 28 return EV_MOUSE_BUTTON_LEFT; 27 29 if( !strcmp (name, "BUTTON_MIDDLE")) return SDL_BUTTON_MIDDLE; 28 30 if( !strcmp (name, "BUTTON_RIGHT")) return SDL_BUTTON_RIGHT; … … 32 34 } 33 35 34 c har* SDLBToButtonname( int button)36 const char* SDLBToButtonname( int button) 35 37 { 36 if( button == SDL_BUTTON_LEFT) return "BUTTON_LEFT";38 if( button == EV_MOUSE_BUTTON_LEFT) return "BUTTON_LEFT"; 37 39 if( button == SDL_BUTTON_MIDDLE) return "BUTTON_MIDDLE"; 38 40 if( button == SDL_BUTTON_RIGHT) return "BUTTON_RIGHT"; … … 180 182 } 181 183 182 c har* SDLKToKeyname( int key)184 const char* SDLKToKeyname( int key) 183 185 { 184 186 if( key == SDLK_BACKSPACE) return "BACKSPACE"; -
trunk/src/lib/event/key_names.h
r5039 r5474 20 20 * @return a pointer to a string containing the name of the mouse button 21 21 */ 22 c har* SDLBToButtonname( int button);22 const char* SDLBToButtonname( int button); 23 23 24 24 /** … … 34 34 * @return a pointer to a string containig the name of the key 35 35 */ 36 c har* SDLKToKeyname( int key);36 const char* SDLKToKeyname( int key); 37 37 38 38
Note: See TracChangeset
for help on using the changeset viewer.