For ticket #82 : start adding the infrastructure to show in the UI which gamepad is which
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8566 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
922eb14a22
commit
15cdaf04bd
@ -171,6 +171,7 @@ bool EventHandler::OnEvent (const SEvent &event)
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void EventHandler::processGUIAction(const PlayerAction action,
|
||||
int deviceID,
|
||||
const unsigned int value,
|
||||
Input::InputType type,
|
||||
const int playerID)
|
||||
@ -178,7 +179,7 @@ void EventHandler::processGUIAction(const PlayerAction action,
|
||||
Screen* screen = GUIEngine::getCurrentScreen();
|
||||
if (screen != NULL)
|
||||
{
|
||||
EventPropagation propg = screen->filterActions(action, value,
|
||||
EventPropagation propg = screen->filterActions(action, deviceID, value,
|
||||
type, playerID);
|
||||
if (propg == EVENT_BLOCK) return;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ namespace GUIEngine
|
||||
* and this action needs to be applied to the GUI (e.g. fire pressed, left
|
||||
* pressed, etc.) this method is called back by the input module.
|
||||
*/
|
||||
void processGUIAction(const PlayerAction action, const unsigned int value,
|
||||
void processGUIAction(const PlayerAction action, int deviceID, const unsigned int value,
|
||||
Input::InputType type, const int playerID);
|
||||
|
||||
/** singleton access */
|
||||
|
@ -264,7 +264,7 @@ namespace GUIEngine
|
||||
/**
|
||||
* \brief override this if you need to be notified of player actions in subclasses
|
||||
*/
|
||||
virtual EventPropagation filterActions(PlayerAction action, const unsigned int value,
|
||||
virtual EventPropagation filterActions(PlayerAction action, int deviceID, const unsigned int value,
|
||||
Input::InputType type, int playerId) { return EVENT_LET; }
|
||||
|
||||
};
|
||||
|
@ -247,15 +247,23 @@ int ListWidget::getItemID(const std::string internalName) const
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ListWidget::markItemRed(const int id)
|
||||
void ListWidget::markItemRed(const int id, bool red)
|
||||
{
|
||||
// May only be called AFTER this widget has been add()ed
|
||||
assert(m_element != NULL);
|
||||
|
||||
IGUIListBox* irritem = getIrrlichtElement<IGUIListBox>();
|
||||
|
||||
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT, video::SColor(255,255,0,0) );
|
||||
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT_HIGHLIGHT, video::SColor(255,255,0,0) );
|
||||
if (red)
|
||||
{
|
||||
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT, video::SColor(255,255,0,0) );
|
||||
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT_HIGHLIGHT, video::SColor(255,255,0,0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT, video::SColor(255,0,0,0) );
|
||||
irritem->setItemOverrideColor( id, EGUI_LBC_TEXT_HIGHLIGHT, video::SColor(255,255,255,255) );
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -149,17 +149,17 @@ namespace GUIEngine
|
||||
* \brief Make an item red to mark an error, for instance
|
||||
* \pre may only be called after the widget has been added to the screen with add()
|
||||
*/
|
||||
void markItemRed(const int id);
|
||||
void markItemRed(const int id, bool red=true);
|
||||
|
||||
/**
|
||||
* \brief Make an item red to mark an error, for instance
|
||||
* \pre may only be called after the widget has been added to the screen with add()
|
||||
*/
|
||||
void markItemRed(const std::string internalName)
|
||||
void markItemRed(const std::string internalName, bool red=true)
|
||||
{
|
||||
const int id = getItemID(internalName);
|
||||
assert(id != -1);
|
||||
markItemRed( id );
|
||||
markItemRed( id, red );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int button
|
||||
}
|
||||
|
||||
// all is good, pass the translated input event on to the event handler
|
||||
GUIEngine::EventHandler::get()->processGUIAction(action, abs(value), type, playerID);
|
||||
GUIEngine::EventHandler::get()->processGUIAction(action, deviceID, abs(value), type, playerID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -244,3 +244,44 @@ void OptionsScreenInput::unloaded()
|
||||
m_icon_bank = NULL;
|
||||
} // unloaded
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
EventPropagation OptionsScreenInput::filterActions(PlayerAction action, int deviceID,
|
||||
const unsigned int value,
|
||||
Input::InputType type, int playerId)
|
||||
{
|
||||
/*
|
||||
if (type == Input::IT_STICKMOTION || type == Input::IT_STICKBUTTON)
|
||||
{
|
||||
GamePadDevice* gamepad = input_manager->getDeviceList()->getGamePadFromIrrID(deviceID);
|
||||
if (gamepad != NULL && gamepad->getConfiguration() != NULL)
|
||||
{
|
||||
//printf("'%s'\n", gamepad->getConfiguration()->getName().c_str());
|
||||
|
||||
ListWidget* devices = this->getWidget<ListWidget>("devices");
|
||||
assert(devices != NULL);
|
||||
|
||||
std::string internal_name;
|
||||
const int gpad_config_count = input_manager->getDeviceList()->getGamePadConfigAmount();
|
||||
for (int i = 0; i < gpad_config_count; i++)
|
||||
{
|
||||
GamepadConfig *config = input_manager->getDeviceList()->getGamepadConfig(i);
|
||||
|
||||
// Don't display the configuration if a matching device is not available
|
||||
if (config == gamepad->getConfiguration())
|
||||
{
|
||||
std::ostringstream gpname;
|
||||
gpname << "gamepad" << i;
|
||||
internal_name = gpname.str();
|
||||
}
|
||||
}
|
||||
|
||||
if (internal_name.size() > 0)
|
||||
{
|
||||
devices->markItemRed(internal_name.c_str(), value > Input::MAX_VALUE*2/3);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return EVENT_LET;
|
||||
}
|
||||
|
@ -65,6 +65,12 @@ public:
|
||||
*/
|
||||
void rebuildDeviceList();
|
||||
|
||||
/** \brief Override callback from base class */
|
||||
virtual GUIEngine::EventPropagation filterActions(PlayerAction action,
|
||||
int deviceID,
|
||||
const unsigned int value,
|
||||
Input::InputType type,
|
||||
int playerId);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -350,10 +350,11 @@ bool RaceResultGUI::onEscapePressed()
|
||||
* no widget is active, the event would be lost, so we act on fire events
|
||||
* here and trigger the next phase.
|
||||
*/
|
||||
GUIEngine::EventPropagation RaceResultGUI::filterActions(PlayerAction action,
|
||||
const unsigned int value,
|
||||
Input::InputType type,
|
||||
int playerId)
|
||||
GUIEngine::EventPropagation RaceResultGUI::filterActions(PlayerAction action,
|
||||
int deviceID,
|
||||
const unsigned int value,
|
||||
Input::InputType type,
|
||||
int playerId)
|
||||
{
|
||||
if(action!=PA_FIRE) return GUIEngine::EVENT_LET;
|
||||
|
||||
|
@ -178,7 +178,7 @@ public:
|
||||
virtual void tearDown();
|
||||
virtual bool onEscapePressed();
|
||||
virtual GUIEngine::EventPropagation
|
||||
filterActions(PlayerAction action, const unsigned int value,
|
||||
filterActions(PlayerAction action, int deviceID, const unsigned int value,
|
||||
Input::InputType type, int playerId);
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID);
|
||||
|
Loading…
Reference in New Issue
Block a user