From 35fa5542fadf1848919363620c7a76b04150c283 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Mon, 25 Oct 2004 10:49:07 +0000 Subject: [PATCH] Let navigate through the worldmap using Tux keys as well. Requested by Jonas Koelker . SVN-Revision: 2060 --- src/worldmap.cpp | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/worldmap.cpp b/src/worldmap.cpp index e7eed6d1c..d746f8f70 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -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: -- 2.11.0