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
This commit is contained in:
auria 2009-03-23 19:41:14 +00:00
parent 38ff0a3d46
commit bcd8287033
4 changed files with 34 additions and 26 deletions

View File

@ -2852,6 +2852,7 @@
"$(OTHER_CFLAGS_QUOTED_FOR_TARGET_1)", "$(OTHER_CFLAGS_QUOTED_FOR_TARGET_1)",
"-DHAVE_GLUT=1", "-DHAVE_GLUT=1",
"-DHAVE_IRRLICHT=1", "-DHAVE_IRRLICHT=1",
"-DDEBUG=1",
); );
OTHER_CFLAGS_QUOTED_FOR_TARGET_1 = "-DPACKAGE=\"\\\"supertuxkart\\\"\""; OTHER_CFLAGS_QUOTED_FOR_TARGET_1 = "-DPACKAGE=\"\\\"supertuxkart\\\"\"";
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (

View File

@ -157,6 +157,7 @@ enum StaticAction
}; };
/* Some constants to make future changes more easier to handle. If you use /* 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 * 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. ;) * or denote a count then something is wrong with your code. ;)

View File

@ -198,17 +198,17 @@ void InputManager::postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const in
GUIEngine::getDevice()->postEventFromUser(wrapper); GUIEngine::getDevice()->postEventFromUser(wrapper);
} }
// TODO - make this do something
void InputManager::handleStaticAction(StaticAction ga, int value) void InputManager::handleStaticAction(int key, int value)
{ {
if (value) //if (value) return;
return;
static int isWireframe = false; static int isWireframe = false;
switch (ga) switch (key)
{ {
case GA_DEBUG_ADD_BOWLING: #ifdef DEBUG
case SDLK_F1:
if (race_manager->getNumPlayers() ==1 ) if (race_manager->getNumPlayers() ==1 )
{ {
Kart* kart = RaceManager::getWorld()->getLocalPlayerKart(0); Kart* kart = RaceManager::getWorld()->getLocalPlayerKart(0);
@ -216,28 +216,29 @@ void InputManager::handleStaticAction(StaticAction ga, int value)
kart->attach(ATTACH_ANVIL, 5); kart->attach(ATTACH_ANVIL, 5);
} }
break; break;
case GA_DEBUG_ADD_MISSILE: case SDLK_F2:
if (race_manager->getNumPlayers() ==1 ) if (race_manager->getNumPlayers() ==1 )
{ {
Kart* kart = RaceManager::getPlayerKart(0); Kart* kart = RaceManager::getPlayerKart(0);
kart->setPowerup(POWERUP_PLUNGER, 10000); kart->setPowerup(POWERUP_PLUNGER, 10000);
} }
break; break;
case GA_DEBUG_ADD_HOMING: case SDLK_F3:
if (race_manager->getNumPlayers() ==1 ) if (race_manager->getNumPlayers() ==1 )
{ {
Kart* kart = RaceManager::getPlayerKart(0); Kart* kart = RaceManager::getPlayerKart(0);
kart->setPowerup(POWERUP_CAKE, 10000); kart->setPowerup(POWERUP_CAKE, 10000);
} }
break; break;
case GA_DEBUG_TOGGLE_FPS: #endif
case SDLK_F12:
user_config->m_display_fps = !user_config->m_display_fps; user_config->m_display_fps = !user_config->m_display_fps;
if(user_config->m_display_fps) if(user_config->m_display_fps)
{ {
getRaceGUI()->resetFPSCounter(); getRaceGUI()->resetFPSCounter();
} }
break; break;
case GA_DEBUG_TOGGLE_WIREFRAME: case SDLK_F11:
glPolygonMode(GL_FRONT_AND_BACK, isWireframe ? GL_FILL : GL_LINE); glPolygonMode(GL_FRONT_AND_BACK, isWireframe ? GL_FILL : GL_LINE);
isWireframe = ! isWireframe; isWireframe = ! isWireframe;
break; break;
@ -245,23 +246,22 @@ void InputManager::handleStaticAction(StaticAction ga, int value)
// For now disable F9 toggling fullscreen, since windows requires // For now disable F9 toggling fullscreen, since windows requires
// to reload all textures, display lists etc. Fullscreen can // to reload all textures, display lists etc. Fullscreen can
// be toggled from the main menu (options->display). // be toggled from the main menu (options->display).
case GA_TOGGLE_FULLSCREEN: case SDLK_F9:
SDLManager::toggleFullscreen(false); // 0: do not reset textures SDLManager::toggleFullscreen(false); // 0: do not reset textures
// Fall through to put the game into pause mode. // Fall through to put the game into pause mode.
#endif #endif
case GA_LEAVE_RACE: case SDLK_ESCAPE:
// TODO - show race menu // TODO - show race menu
/* // RaceManager::getWorld()->pause();
RaceManager::getWorld()->pause(); //menu_manager->pushMenu(MENUID_RACEMENU);
menu_manager->pushMenu(MENUID_RACEMENU);
*/
break; break;
case GA_DEBUG_HISTORY: case SDLK_F10:
history->Save(); history->Save();
break; break;
default: default:
break; break;
} // switch } // switch
} }
@ -303,8 +303,7 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
else if(id0 == SDLK_LEFT) else if(id0 == SDLK_LEFT)
evt.Key = irr::KEY_LEFT; evt.Key = irr::KEY_LEFT;
else 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; 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} } // if m_mode==INPUT_SENSE_PREFER_{AXIS,BUTTON}
else else
#endif #endif
if (action_found) if (action_found)
{ {
RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, value); 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 } // input
@ -498,7 +502,8 @@ void InputManager::input()
if(ev.jaxis.value < 0) 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) 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); input(Input::IT_STICKMOTION, !m_mode ? 0 : stickIndex, ev.jaxis.axis, Input::AD_POSITIVE, 0);
@ -509,7 +514,8 @@ void InputManager::input()
} }
else 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) 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); input(Input::IT_STICKMOTION, !m_mode ? 0 : stickIndex, ev.jaxis.axis, Input::AD_NEGATIVE, 0);

View File

@ -65,7 +65,7 @@ private:
void input(Input::InputType, int, int, int, int); void input(Input::InputType, int, int, int, int);
void postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const int x, const int y); 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); void handlePlayerAction(PlayerAction pa, const int playerNo, int value);
public: public:
InputManager(); InputManager();