fixed going back in menus with gamepad (use rescue, should now work)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3373 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-10 23:07:21 +00:00
parent d7a032944e
commit de53cd22c1
2 changed files with 28 additions and 19 deletions

View File

@ -797,13 +797,14 @@ void RibbonGridWidget::add()
// add arrow buttons on each side
// FIXME? these arrow buttons are outside of the widget's boundaries
// create sub-widgets if they don't already exist
//if(m_left_widget == NULL)
//{
// FIXME - memory leak, irrlicht will probably delete its own widget; I don't delete mine however.
m_left_widget = new Widget();
m_right_widget = new Widget();
//}
if(m_left_widget != NULL)
{
// FIXME - do proper memory management, find why it crashes when i try to clean-up
//delete m_left_widget;
//delete m_right_widget;
}
m_left_widget = new Widget();
m_right_widget = new Widget();
const int average_y = y + (h-label_height)/2;
const int button_w = 30, button_h = 50;

View File

@ -339,7 +339,7 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, id0, id1, id2, value, &player, &action );
if(!action_found) return;
if(m_timer_in_use) return; // time between keys not elapsed yet
evt.PressedDown = abs(value) > MAX_VALUE/2;
if(action == PA_FIRE || action == PA_NITRO)
evt.Key = irr::KEY_RETURN;
@ -352,26 +352,34 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
else if(action == PA_LEFT)
evt.Key = irr::KEY_LEFT;
else if(action == PA_RESCUE)
evt.Key = irr::KEY_ESCAPE;
{
// escape (or 'rescue' on gamepad) is a little special
if(evt.PressedDown) StateManager::escapePressed();
return;
}
else
return; // only those bindings are accepted in menus for now.
evt.PressedDown = abs(value) > MAX_VALUE/2;
if(evt.PressedDown && type == Input::IT_STICKMOTION)
if(type == Input::IT_STICKMOTION)
{
// minimum time between two gamepad events in menu
m_timer_in_use = true;
m_timer = 0.25;
}
}
if(m_timer_in_use) return; // time between keys not elapsed yet
if(evt.PressedDown)
{
// minimum time between two gamepad events in menu
m_timer_in_use = true;
m_timer = 0.25;
}
} // end if (gamepad input type)
} // end if (keyboard vs gamepad)
// send event to irrLicht
irr::SEvent wrapper;
wrapper.KeyInput = evt;
wrapper.EventType = EET_KEY_INPUT_EVENT;
GUIEngine::getDevice()->postEventFromUser(wrapper);
}
// in-game event handling
else
@ -475,7 +483,7 @@ void InputManager::input()
case SDL_KEYDOWN:
// escape is a little special
if(ev.key.keysym.sym == 27)
if(ev.key.keysym.sym == SDLK_ESCAPE)
{
StateManager::escapePressed();
return;