Let navigate through the worldmap using Tux keys as well.
authorRicardo Cruz <rick2@aeiou.pt>
Mon, 25 Oct 2004 10:49:07 +0000 (10:49 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Mon, 25 Oct 2004 10:49:07 +0000 (10:49 +0000)
Requested by Jonas Koelker <jonaskoelker@yahoo.com>.

SVN-Revision: 2060

src/worldmap.cpp

index e7eed6d..d746f8f 100644 (file)
@@ -681,7 +681,8 @@ void
 WorldMap::get_input()
 {
   enter_level = false;
-   
+  SDLKey key;
+
   SDL_Event event;
   while (SDL_PollEvent(&event))
     {
@@ -698,32 +699,22 @@ WorldMap::get_input()
               break;
           
             case SDL_KEYDOWN:
-              switch(event.key.keysym.sym)
-                {
-                case SDLK_ESCAPE:
-                  on_escape_press();
-                  break;
-                case SDLK_LCTRL:
-                case SDLK_RETURN:
-                  enter_level = true;
-                  break;
-
-                case SDLK_LEFT:
-                  tux->set_direction(D_WEST);
-                  break;
-                case SDLK_RIGHT:
-                  tux->set_direction(D_EAST);
-                  break;
-                case SDLK_UP:
-                  tux->set_direction(D_NORTH);
-                  break;
-                case SDLK_DOWN:
-                  tux->set_direction(D_SOUTH);
-                  break;
+              key = event.key.keysym.sym;
 
-                default:
-                  break;
-                }
+              if(key == SDLK_ESCAPE)
+                on_escape_press();
+              else if(key == SDLK_RETURN || key == keymap.power)
+                enter_level = true;
+              else if(key == SDLK_LEFT || key == keymap.power)
+                tux->set_direction(D_WEST);
+              else if(key == SDLK_RIGHT || key == keymap.right)
+                tux->set_direction(D_EAST);
+              else if(key == SDLK_UP || key == keymap.up ||
+                key == keymap.jump)
+                  // there might be ppl that use jump as up key
+                tux->set_direction(D_NORTH);
+              else if(key == SDLK_DOWN || key == keymap.down)
+                tux->set_direction(D_SOUTH);
               break;
 
             case SDL_JOYHATMOTION: