Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4582 in orxonox.OLD


Ignore:
Timestamp:
Jun 10, 2005, 3:30:52 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: fixed a small bug in the event handling system which caused to display a msg multiple times

File:
1 edited

Legend:

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

    r4457 r4582  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1212   main-programmer: Patrick Boenzli
    1313   co-programmer: Christian Meyer
    14    
     14
    1515   This code was inspired by the command_node.cc code from Christian Meyer in revision
    1616   4386 and earlier.
     
    4545int KeyMapper::PEV_VIEW3             = EV_UNKNOWN;
    4646int KeyMapper::PEV_VIEW4             = EV_UNKNOWN;
    47 int KeyMapper::PEV_VIEW5             = EV_UNKNOWN; 
     47int KeyMapper::PEV_VIEW5             = EV_UNKNOWN;
    4848
    4949int KeyMapper::PEV_NEXT_WORLD        = EV_UNKNOWN;
     
    5757//! this is the mapping array from names to ids: enter all orxonox.conf keys here
    5858orxKeyMapping map[] = { {&KeyMapper::PEV_UP, "Up"},
    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"},
     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"},
    8484                        {NULL, NULL}};
    8585
     
    8989   \brief standard constructor
    9090*/
    91 KeyMapper::KeyMapper () 
    92 {
    93    this->setClassID(CL_KEY_MAPPER, "KeyMapper"); 
     91KeyMapper::KeyMapper ()
     92{
     93   this->setClassID(CL_KEY_MAPPER, "KeyMapper");
    9494}
    9595
     
    9898   \brief standard deconstructor
    9999*/
    100 KeyMapper::~KeyMapper () 
     100KeyMapper::~KeyMapper ()
    101101{
    102102}
     
    110110{
    111111  FILE* stream;
    112  
     112
    113113  PRINTF(4)("Loading key bindings from %s\n", fileName);
    114  
     114
    115115  // create parser
    116116  IniParser parser(fileName);
     
    121121    }
    122122  // allocate empty lookup table
    123  
     123
    124124  char namebuf[256];
    125125  char valuebuf[256];
     
    127127  memset (valuebuf, 0, 256);
    128128  int* index;
    129  
     129
    130130  while( parser.nextVar (namebuf, valuebuf) != -1)
    131131    {
     
    136136      /*
    137137      switch( index[0])
    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         }
     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        }
    148148      */
    149149      memset (namebuf, 0, 256);
     
    162162    {
    163163      PRINTF(3)("MISC: Parsing %s, %s now.\n", namebuf, valuebuf);
    164       index = nameToIndex (valuebuf);     
     164      index = nameToIndex (valuebuf);
    165165      this->mapKeys(namebuf, index[1]);
    166166      /*
    167167      switch( index[0])
    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         }
     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        }
    178178      */
    179179      memset (namebuf, 0, 256);
     
    215215  for(int i = 0; map[i].pValue != NULL; ++i )
    216216    {
    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      }
    219223    }
    220224}
     
    226230void KeyMapper::debug()
    227231{
    228   PRINT(0)("\n==========================| KeyMapper::debug() |===\n"); 
     232  PRINT(0)("\n==========================| KeyMapper::debug() |===\n");
    229233  for(int i = 0; map[i].pValue != NULL; ++i)
    230234    {
    231235      PRINT(0)("%s = %i\n",map[i].pName, *map[i].pValue);
    232236    }
    233   PRINT(0)("=======================================================\n");       
    234 }
     237  PRINT(0)("=======================================================\n");
     238}
Note: See TracChangeset for help on using the changeset viewer.