Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4402 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 30, 2005, 6:12:24 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: key mapping works just fine

Location:
orxonox/trunk/src/util/event
Files:
2 edited

Legend:

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

    r4401 r4402  
    130130          PRINTF(3)("Key binding %d(%s) set to %s\n", index[1], SDLKToKeyname( index[1]), namebuf);
    131131          strcpy (this->keyAliases->keys[index[1]], namebuf);
     132          this->mapKeys(namebuf, index[1]);
    132133          break;
    133134        case 1:
     
    171172      memset (valuebuf, 0, 256);
    172173    }
    173   this->mapKeys();
    174174}
    175175
     
    196196
    197197
    198 void KeyMapper::mapKeys()
    199 {
    200   for(int i = 0; i < N_STD_KEYS; ++i)
    201     {
    202       if( !strcmp (this->keyAliases->keys[i], "Up")) PEV_UP = i;
    203 
    204     }
    205   PRINTF(0)("fire = %i\n", PEV_FIRE1);
     198void KeyMapper::mapKeys(char* name, int keyID)
     199{
     200  for(int i = 0; map[i].pValue != NULL; ++i )
     201    {
     202      if( !strcmp (name, map[i].pName)) { *map[i].pValue = keyID; break;}
     203    }
    206204}
    207205
     
    210208{
    211209  //PRINT(0)("\n==========================| KeyMapper::debug() |===\n"); 
    212   PRINT(0)("Command 'up' got SDL key-ref nr %i \n", keynameToSDLK("UP"));
    213   PRINT(0)("Command 'down' got SDL key-ref nr %i \n", (this->nameToIndex("DOWN"))[1]);
    214   PRINT(0)("Command 'right' got SDL key-ref nr %i \n", (this->nameToIndex("RIGHT"))[1]);
    215   PRINT(0)("Command 'left' got SDL key-ref nr %i \n", (this->nameToIndex("LEFT"))[1]);
     210  PRINT(0)("PEV_UP = %i\n", PEV_UP);
     211  PRINT(0)("PEV_DOWN = %i\n", PEV_DOWN);
     212  PRINT(0)("PEV_LEFT = %i\n", PEV_LEFT);
     213  PRINT(0)("PEV_RIGHT = %i\n", PEV_RIGHT);
    216214
    217215  //PRINT(0)("=======================================================\n");       
  • orxonox/trunk/src/util/event/key_mapper.h

    r4401 r4402  
    2828{
    2929  int* pValue;
    30   char* name;
     30  char* pName;
    3131};
    3232
     
    4545 private:
    4646  int* nameToIndex (char* name);
    47   void mapKeys();
     47  void mapKeys(char* name, int keyID);
    4848
    4949 public:
Note: See TracChangeset for help on using the changeset viewer.