Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4355 in orxonox.OLD


Ignore:
Timestamp:
May 28, 2005, 1:19:13 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: started implementing the process function

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

Legend:

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

    r4354 r4355  
    3737  for(int i = 0; i < ES_NUMBER; ++i)
    3838    this->listeners[i] = new EventListener*[SDLK_LAST];
     39
     40  /* now initialize them all to zero */
     41  for(int i = 0; i < ES_NUMBER; ++i)
     42    {
     43      for(int j = 0; j < SDLK_LAST; ++j)
     44        {
     45          this->listeners[i][j] = NULL;
     46        }
     47    }
    3948}
    4049
     
    182191
    183192
    184 void EventHandler::unsubscribeListener(EventListener* el, elState state)
    185 {}
     193void EventHandler::unsubscribeListener(int eventType, elState state)
     194{
     195  this->listeners[state][eventType] = NULL;
     196}
    186197
    187198void EventHandler::flush()
    188 {}
     199{
     200  for(int i = 0; i < ES_NUMBER; ++i)
     201    {
     202      for(int j = 0; j < SDLK_LAST; ++j)
     203        {
     204          this->listeners[i][j] = NULL;
     205        }
     206    }
     207}
     208
     209
     210
     211void EventHandler::process()
     212{
     213  SDL_Event event;
     214  //Command cmd;
     215  while( SDL_PollEvent (&event))
     216    {
     217      //  memset (cmd.cmd, 0, CMD_LENGHT);
     218      switch( event.type)
     219        {
     220        case SDL_KEYDOWN:
     221          /*
     222          strcpy (cmd.cmd, aliases->keys[event.key.keysym.sym]);
     223          cmd.bUp = false;
     224          if( strlen (cmd.cmd) > 0) relay(&cmd);
     225          */
     226          break;
     227        case SDL_KEYUP:
     228          /*
     229          strcpy( cmd.cmd, aliases->keys[event.key.keysym.sym]);
     230          cmd.bUp = true;
     231          if( strlen (cmd.cmd) > 0) relay(&cmd);
     232          */
     233          break;
     234        case SDL_MOUSEMOTION:
     235          /*
     236          strcpy( cmd.cmd, "cursor");
     237          cmd.x = event.motion.x;
     238          cmd.y = event.motion.y;
     239          cmd.xrel = event.motion.xrel;
     240          cmd.yrel = event.motion.yrel;
     241          if( strlen (cmd.cmd) > 0) relay(&cmd);
     242          */
     243          break;
     244        case SDL_MOUSEBUTTONUP:
     245          /*
     246          strcpy( cmd.cmd, aliases->buttons[event.button.button]);
     247          cmd.bUp = true;
     248          if( strlen (cmd.cmd) > 0) relay(&cmd);
     249          */
     250          break;
     251        case SDL_MOUSEBUTTONDOWN:
     252          /*
     253          strcpy( cmd.cmd, aliases->buttons[event.button.button]);
     254          cmd.bUp = false;
     255          if( strlen (cmd.cmd) > 0) relay(&cmd);
     256          */
     257          break;
     258        case SDL_JOYAXISMOTION:
     259        case SDL_JOYBALLMOTION:
     260        case SDL_JOYHATMOTION:
     261        case SDL_JOYBUTTONDOWN:
     262        case SDL_JOYBUTTONUP:
     263          break;
     264        default:
     265          break;
     266        }
     267    }
     268}
  • orxonox/trunk/src/util/event/event_handler.h

    r4354 r4355  
    5050
    5151  void subscribeListener(EventListener* el, elState state, int eventType);
    52   void unsubscribeListener(EventListener* el, elState state);
    5352  void unsubscribeListener(int eventType, elState state);
    5453  void flush();
Note: See TracChangeset for help on using the changeset viewer.