Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5474 in orxonox.OLD for trunk/src/lib/event/key_mapper.cc


Ignore:
Timestamp:
Nov 3, 2005, 2:13:48 PM (18 years ago)
Author:
patrick
Message:

orxonox/lib/event: fixed the mouse button bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/event/key_mapper.cc

    r5299 r5474  
    133133  {
    134134    PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     135    // map the name to an sdl index
    135136    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);
    137139    iniParser->nextVar();
    138140  }
     
    151153    PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
    152154    index = nameToIndex (iniParser->getCurrentValue());
    153     this->mapKeys(iniParser->getCurrentName(), index[1]);
     155    this->mapKeys(iniParser->getCurrentName(), index);
    154156    iniParser->nextVar();
    155157  }
     
    165167  coord[1] = -1;
    166168  int c;
    167   if( (c = keynameToSDLK (name)) != -1)
    168     {
     169  if( (c = keynameToSDLK (name)) != -1) {
    169170      coord[1] = c;
    170171      coord[0] = 0;
    171172    }
    172   if( (c = buttonnameToSDLB (name)) != -1)
    173     {
     173  if( (c = buttonnameToSDLB (name)) != -1) {
    174174      coord[1] = c;
    175175      coord[0] = 1;
     
    184184 * @param id of the key
    185185*/
    186 void KeyMapper::mapKeys(const char* name, int keyID)
    187 {
    188   for(int i = 0; map[i].pValue != NULL; ++i )
     186void KeyMapper::mapKeys(const char* name, int* index)
     187{
     188  for( int i = 0; map[i].pValue != NULL; ++i )
    189189    {
    190190      if( !strcmp (name, map[i].pName))
    191191      {
    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        }
    195203      }
    196204    }
Note: See TracChangeset for help on using the changeset viewer.