attempt at menu navigation from gamepad
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3349 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
59ba8f1e44
commit
ef9206b569
@ -92,7 +92,7 @@ namespace StateManager
|
||||
w2->addLabel("MiniBjorn");
|
||||
|
||||
GUIEngine::ModelViewWidget* w3 = dynamic_cast<GUIEngine::ModelViewWidget*>
|
||||
(GUIEngine::getCurrentScreen()->getWidget("modelview"));
|
||||
(GUIEngine::getCurrentScreen()->getWidget("modelview"));
|
||||
|
||||
assert( w3 != NULL );
|
||||
|
||||
@ -125,6 +125,9 @@ namespace StateManager
|
||||
(GUIEngine::getCurrentScreen()->getWidget("difficulty"));
|
||||
assert( w != NULL );
|
||||
w->setSelection(user_config->getDefaultDifficulty());
|
||||
|
||||
// TODO - if user arrived to this screen by pressing esc from teh enxt, the behaviour below might be incorrect
|
||||
// it would be better to restore previously set settings.
|
||||
race_manager->setDifficulty( (RaceManager::Difficulty)user_config->getDefaultDifficulty() );
|
||||
}
|
||||
else if(name == "difficulty")
|
||||
|
@ -985,7 +985,10 @@ void ModelViewWidget::add()
|
||||
{
|
||||
rect<s32> widget_size = rect<s32>(x, y, x + w, y + h);
|
||||
stringw message = m_properties[PROP_TEXT].c_str();
|
||||
m_element = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter);
|
||||
|
||||
|
||||
IGUIMeshViewer* mesh_view = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter);
|
||||
m_element = mesh_view;
|
||||
|
||||
id = m_element->getID();
|
||||
m_element->setTabOrder(id);
|
||||
@ -995,6 +998,12 @@ void ModelViewWidget::add()
|
||||
void ModelViewWidget::setModel(SAnimatedMesh* mesh)
|
||||
{
|
||||
((IGUIMeshViewer*)m_element)->setMesh( mesh );
|
||||
|
||||
video::SMaterial mat = mesh->getMeshBuffer(0)->getMaterial(); //mesh_view->getMaterial();
|
||||
mat.setFlag(EMF_LIGHTING , false);
|
||||
//mat.setFlag(EMF_GOURAUD_SHADING, false);
|
||||
//mat.setFlag(EMF_NORMALIZE_NORMALS, true);
|
||||
((IGUIMeshViewer*)m_element)->setMaterial(mat);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -300,12 +300,10 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
|
||||
// menu navigation. TODO : enable navigation with gamepads
|
||||
if(!StateManager::isGameState())
|
||||
{
|
||||
irr::SEvent::SKeyInput evt;
|
||||
|
||||
if(type == Input::IT_KEYBOARD)
|
||||
{
|
||||
irr::SEvent::SKeyInput evt;
|
||||
|
||||
// std::cout << id0 << std::endl;
|
||||
|
||||
if(id0 == SDLK_RETURN)
|
||||
evt.Key = irr::KEY_RETURN;
|
||||
else if(id0 == SDLK_UP)
|
||||
@ -318,15 +316,37 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
|
||||
evt.Key = irr::KEY_LEFT;
|
||||
else
|
||||
return; // only those keys are accepted in menus for now.
|
||||
|
||||
evt.PressedDown = value > MAX_VALUE/2;
|
||||
|
||||
irr::SEvent wrapper;
|
||||
wrapper.KeyInput = evt;
|
||||
wrapper.EventType = EET_KEY_INPUT_EVENT;
|
||||
|
||||
GUIEngine::getDevice()->postEventFromUser(wrapper);
|
||||
}
|
||||
else // allow menu navigation with gamepads and other devices too
|
||||
{
|
||||
int player;
|
||||
PlayerAction action;
|
||||
|
||||
const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, id0, id1, id2, value, &player, &action );
|
||||
if(!action_found) return;
|
||||
|
||||
if(action == PA_FIRE || action == PA_NITRO)
|
||||
evt.Key = irr::KEY_RETURN;
|
||||
else if(action == PA_ACCEL)
|
||||
evt.Key = irr::KEY_UP;
|
||||
else if(action == PA_BRAKE)
|
||||
evt.Key = irr::KEY_DOWN;
|
||||
else if(action == PA_RIGHT)
|
||||
evt.Key = irr::KEY_RIGHT;
|
||||
else if(action == PA_LEFT)
|
||||
evt.Key = irr::KEY_LEFT;
|
||||
else
|
||||
return; // only those bindings are accepted in menus for now.
|
||||
}
|
||||
|
||||
// send event to irrLicht
|
||||
evt.PressedDown = value > MAX_VALUE/2;
|
||||
|
||||
irr::SEvent wrapper;
|
||||
wrapper.KeyInput = evt;
|
||||
wrapper.EventType = EET_KEY_INPUT_EVENT;
|
||||
|
||||
GUIEngine::getDevice()->postEventFromUser(wrapper);
|
||||
|
||||
}
|
||||
// in-game event handling
|
||||
|
Loading…
Reference in New Issue
Block a user