fixed navigating players list from gamepad

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3429 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-25 23:37:04 +00:00
parent a18250a599
commit 36f5450c88
2 changed files with 33 additions and 29 deletions

View File

@ -436,7 +436,22 @@ void Screen::processAction(const int action, const unsigned int value, Input::In
{ {
IGUIListBox* list = dynamic_cast<IGUIListBox*>(w->m_element); IGUIListBox* list = dynamic_cast<IGUIListBox*>(w->m_element);
assert(list != NULL); assert(list != NULL);
if(list->getSelected()>0) break;
const bool stay_within_list = list->getSelected()>0;
if(type == Input::IT_STICKMOTION)
{
// simulate a key press
irr::SEvent::SKeyInput evt;
evt.PressedDown = true;
evt.Key = KEY_UP;
irr::SEvent wrapper;
wrapper.KeyInput = evt;
wrapper.EventType = EET_KEY_INPUT_EVENT;
GUIEngine::getDevice()->postEventFromUser(wrapper);
}
if(stay_within_list) break;
} }
if(el != NULL && el->getTabGroup() != NULL && if(el != NULL && el->getTabGroup() != NULL &&
@ -468,7 +483,22 @@ void Screen::processAction(const int action, const unsigned int value, Input::In
{ {
IGUIListBox* list = dynamic_cast<IGUIListBox*>(w->m_element); IGUIListBox* list = dynamic_cast<IGUIListBox*>(w->m_element);
assert(list != NULL); assert(list != NULL);
if(list->getSelected() < (int)list->getItemCount()-1) break;
const bool stay_within_list = list->getSelected() < (int)list->getItemCount()-1;
if(type == Input::IT_STICKMOTION)
{
// simulate a key press
irr::SEvent::SKeyInput evt;
evt.PressedDown = true;
evt.Key = KEY_DOWN;
irr::SEvent wrapper;
wrapper.KeyInput = evt;
wrapper.EventType = EET_KEY_INPUT_EVENT;
GUIEngine::getDevice()->postEventFromUser(wrapper);
}
if(stay_within_list) break;
} }
if(el != NULL && el->getTabGroup() != NULL && if(el != NULL && el->getTabGroup() != NULL &&

View File

@ -187,27 +187,9 @@ InputManager::~InputManager()
#define MAX_VALUE 32768 #define MAX_VALUE 32768
/*
void InputManager::postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const int x, const int y)
{
irr::SEvent::SMouseInput evt;
evt.Event = type;
evt.X = x;
evt.Y = y;
irr::SEvent wrapper;
wrapper.MouseInput = evt;
wrapper.EventType = EET_MOUSE_INPUT_EVENT;
GUIEngine::getDevice()->postEventFromUser(wrapper);
}
*/
// TODO - make this do something
void InputManager::handleStaticAction(int key, int value) void InputManager::handleStaticAction(int key, int value)
{ {
//if (value) return;
static int isWireframe = false; static int isWireframe = false;
switch (key) switch (key)
@ -388,14 +370,6 @@ void InputManager::input(const SEvent& event)
if(event.EventType == EET_JOYSTICK_INPUT_EVENT) if(event.EventType == EET_JOYSTICK_INPUT_EVENT)
{ {
/*
std::cout << "x=" << event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]
<< " y=" << event.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]
<< " 1=" << event.JoystickEvent.IsButtonPressed(0)
<< " 2=" << event.JoystickEvent.IsButtonPressed(1)
<< " 3=" << event.JoystickEvent.IsButtonPressed(2)
<< " 4=" << event.JoystickEvent.IsButtonPressed(3) << std::endl;
*/
// Axes - FIXME, instead of checking all of them, ask the bindings which ones to poll // Axes - FIXME, instead of checking all of them, ask the bindings which ones to poll
for(int axis_id=0; axis_id<SEvent::SJoystickEvent::NUMBER_OF_AXES ; axis_id++) for(int axis_id=0; axis_id<SEvent::SJoystickEvent::NUMBER_OF_AXES ; axis_id++)
{ {