From bcd82870333c4b8308ac4f836fe4fcbf7f0be987 Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 23 Mar 2009 19:41:14 +0000 Subject: [PATCH] brought back static keypress detection (mostly F-keys) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3297 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- .../Xcode/STK_XCode.xcodeproj/project.pbxproj | 1 + src/input/input.hpp | 1 + src/input/input_manager.cpp | 56 ++++++++++--------- src/input/input_manager.hpp | 2 +- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj index a2a450dc3..223915549 100644 --- a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj +++ b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj @@ -2852,6 +2852,7 @@ "$(OTHER_CFLAGS_QUOTED_FOR_TARGET_1)", "-DHAVE_GLUT=1", "-DHAVE_IRRLICHT=1", + "-DDEBUG=1", ); OTHER_CFLAGS_QUOTED_FOR_TARGET_1 = "-DPACKAGE=\"\\\"supertuxkart\\\"\""; OTHER_LDFLAGS = ( diff --git a/src/input/input.hpp b/src/input/input.hpp index ef2e1e14b..4fbc6b843 100644 --- a/src/input/input.hpp +++ b/src/input/input.hpp @@ -157,6 +157,7 @@ enum StaticAction }; + /* Some constants to make future changes more easier to handle. If you use * any of the GameAction constants to mark the beginning or end of a range * or denote a count then something is wrong with your code. ;) diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 56e68b5c0..519f74341 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -198,17 +198,17 @@ void InputManager::postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const in GUIEngine::getDevice()->postEventFromUser(wrapper); } - -void InputManager::handleStaticAction(StaticAction ga, int value) +// TODO - make this do something +void InputManager::handleStaticAction(int key, int value) { - if (value) - return; + //if (value) return; static int isWireframe = false; - switch (ga) + switch (key) { - case GA_DEBUG_ADD_BOWLING: +#ifdef DEBUG + case SDLK_F1: if (race_manager->getNumPlayers() ==1 ) { Kart* kart = RaceManager::getWorld()->getLocalPlayerKart(0); @@ -216,28 +216,29 @@ void InputManager::handleStaticAction(StaticAction ga, int value) kart->attach(ATTACH_ANVIL, 5); } break; - case GA_DEBUG_ADD_MISSILE: + case SDLK_F2: if (race_manager->getNumPlayers() ==1 ) { Kart* kart = RaceManager::getPlayerKart(0); kart->setPowerup(POWERUP_PLUNGER, 10000); } break; - case GA_DEBUG_ADD_HOMING: + case SDLK_F3: if (race_manager->getNumPlayers() ==1 ) { Kart* kart = RaceManager::getPlayerKart(0); kart->setPowerup(POWERUP_CAKE, 10000); } break; - case GA_DEBUG_TOGGLE_FPS: +#endif + case SDLK_F12: user_config->m_display_fps = !user_config->m_display_fps; if(user_config->m_display_fps) { getRaceGUI()->resetFPSCounter(); } break; - case GA_DEBUG_TOGGLE_WIREFRAME: + case SDLK_F11: glPolygonMode(GL_FRONT_AND_BACK, isWireframe ? GL_FILL : GL_LINE); isWireframe = ! isWireframe; break; @@ -245,23 +246,22 @@ void InputManager::handleStaticAction(StaticAction ga, int value) // For now disable F9 toggling fullscreen, since windows requires // to reload all textures, display lists etc. Fullscreen can // be toggled from the main menu (options->display). - case GA_TOGGLE_FULLSCREEN: + case SDLK_F9: SDLManager::toggleFullscreen(false); // 0: do not reset textures // Fall through to put the game into pause mode. #endif - case GA_LEAVE_RACE: + case SDLK_ESCAPE: // TODO - show race menu - /* - RaceManager::getWorld()->pause(); - menu_manager->pushMenu(MENUID_RACEMENU); - */ + // RaceManager::getWorld()->pause(); + //menu_manager->pushMenu(MENUID_RACEMENU); break; - case GA_DEBUG_HISTORY: + case SDLK_F10: history->Save(); break; default: break; } // switch + } @@ -303,8 +303,7 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2, else if(id0 == SDLK_LEFT) evt.Key = irr::KEY_LEFT; else - evt.Key = (irr::EKEY_CODE) id0; // FIXME - probably won't work, need better input handling - + return; // only those keys are accepted in menus for now. evt.PressedDown = value > MAX_VALUE/2; @@ -370,10 +369,15 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2, } // if m_mode==INPUT_SENSE_PREFER_{AXIS,BUTTON} else #endif - if (action_found) - { - RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, value); - } + if (action_found) + { + RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, value); + } + else if(type == Input::IT_KEYBOARD) + { + // keyboard press not handled by device manager / bindings. Check static bindings... + handleStaticAction( id0, value ); + } } } // input @@ -498,7 +502,8 @@ void InputManager::input() if(ev.jaxis.value < 0) { - /* TODO - bring back those weird axis tricks + /* TODO - bring back those weird axis tricks. would be cool if + // they could happen inside the GamePadDevice class, for encapsulation if (m_stick_infos[ev.jaxis.which]->m_prevAxisDirections[ev.jaxis.axis] == Input::AD_POSITIVE) { input(Input::IT_STICKMOTION, !m_mode ? 0 : stickIndex, ev.jaxis.axis, Input::AD_POSITIVE, 0); @@ -509,7 +514,8 @@ void InputManager::input() } else { - /* TODO - bring back those weird axis tricks + /* TODO - bring back those weird axis tricks. would be cool if + // they could happen inside the GamePadDevice class, for encapsulation if (m_stick_infos[ev.jaxis.which]->m_prevAxisDirections[ev.jaxis.axis] == Input::AD_NEGATIVE) { input(Input::IT_STICKMOTION, !m_mode ? 0 : stickIndex, ev.jaxis.axis, Input::AD_NEGATIVE, 0); diff --git a/src/input/input_manager.hpp b/src/input/input_manager.hpp index f38b51afa..b6daa17d5 100644 --- a/src/input/input_manager.hpp +++ b/src/input/input_manager.hpp @@ -65,7 +65,7 @@ private: void input(Input::InputType, int, int, int, int); void postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const int x, const int y); - void handleStaticAction(StaticAction ga, int value); + void handleStaticAction(int id0, int value); void handlePlayerAction(PlayerAction pa, const int playerNo, int value); public: InputManager();