Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 14, 2005, 10:38:21 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: Iniparser is passed on to the EvenetHandler over orxonox

File:
1 edited

Legend:

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

    r4864 r4866  
    115115void KeyMapper::loadKeyBindings (const char* fileName)
    116116{
    117   FILE* stream;
    118 
    119   PRINTF(4)("Loading key bindings from %s\n", fileName);
    120 
    121   // create parser
    122117  IniParser parser(fileName);
    123   if( parser.getSection (CONFIG_SECTION_PLAYER "1") == -1)
    124     {
    125       PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1 in %s\n", fileName);
    126       return;
    127     }
     118  this->loadKeyBindings(&parser);
     119}
     120
     121void KeyMapper::loadKeyBindings(IniParser* iniParser)
     122{
     123  if( iniParser->getSection (CONFIG_SECTION_PLAYER "1") == -1)
     124  {
     125    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n");
     126    return;
     127  }
    128128  // allocate empty lookup table
    129129
     
    134134  int* index;
    135135
    136   while( parser.nextVar (namebuf, valuebuf) != -1)
    137     {
    138       PRINTF(3)("Keys: Parsing %s, %s now.\n", namebuf, valuebuf);
    139       index = nameToIndex (valuebuf);
    140       this->mapKeys(namebuf, index[1]);
     136  while( iniParser->nextVar (namebuf, valuebuf) != -1)
     137  {
     138    PRINTF(3)("Keys: Parsing %s, %s now.\n", namebuf, valuebuf);
     139    index = nameToIndex (valuebuf);
     140    this->mapKeys(namebuf, index[1]);
    141141
    142142      /*
    143       switch( index[0])
    144         {
    145         case 0:
    146           this->mapKeys(namebuf, index[1]);
    147           break;
    148         case 1:
    149           this->mapKeys(namebuf, index[1]);
    150           break;
    151         default:
    152           break;
    153         }
     143    switch( index[0])
     144    {
     145    case 0:
     146    this->mapKeys(namebuf, index[1]);
     147    break;
     148    case 1:
     149    this->mapKeys(namebuf, index[1]);
     150    break;
     151    default:
     152    break;
     153  }
    154154      */
    155       memset (namebuf, 0, 256);
    156       memset (valuebuf, 0, 256);
    157     }
     155    memset (namebuf, 0, 256);
     156    memset (valuebuf, 0, 256);
     157  }
    158158
    159159
    160160  // PARSE MISC SECTION
    161   if( parser.getSection (CONFIG_SECTION_MISC_KEYS) == -1)
    162     {
    163       PRINTF(1)("Could not find key bindings in %s\n", fileName);
    164       return;
    165     }
    166 
    167   while( parser.nextVar (namebuf, valuebuf) != -1)
    168     {
    169       PRINTF(3)("MISC: Parsing %s, %s now.\n", namebuf, valuebuf);
    170       index = nameToIndex (valuebuf);
    171       this->mapKeys(namebuf, index[1]);
     161  if( iniParser->getSection (CONFIG_SECTION_MISC_KEYS) == -1)
     162  {
     163    PRINTF(1)("Could not find key bindings\n");
     164    return;
     165  }
     166
     167  while( iniParser->nextVar (namebuf, valuebuf) != -1)
     168  {
     169    PRINTF(3)("MISC: Parsing %s, %s now.\n", namebuf, valuebuf);
     170    index = nameToIndex (valuebuf);
     171    this->mapKeys(namebuf, index[1]);
    172172      /*
    173       switch( index[0])
    174         {
    175         case 0:
    176           this->mapKeys(namebuf, index[1]);
    177           break;
    178         case 1:
    179         this->mapKeys(namebuf, index[1]);
    180           break;
    181         default:
    182           break;
    183         }
     173    switch( index[0])
     174    {
     175    case 0:
     176    this->mapKeys(namebuf, index[1]);
     177    break;
     178    case 1:
     179    this->mapKeys(namebuf, index[1]);
     180    break;
     181    default:
     182    break;
     183  }
    184184      */
    185       memset (namebuf, 0, 256);
    186       memset (valuebuf, 0, 256);
    187     }
    188 }
    189 
     185    memset (namebuf, 0, 256);
     186    memset (valuebuf, 0, 256);
     187  }
     188}
    190189
    191190/**
Note: See TracChangeset for help on using the changeset viewer.