Highlight gamepad when pressing its keys, to help the player tell them apart

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8683 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-05-23 20:51:17 +00:00
parent da6742d7b1
commit 30435bbde4
4 changed files with 28 additions and 16 deletions

View File

@ -272,6 +272,15 @@ namespace GUIEngine
virtual EventPropagation filterActions(PlayerAction action, int deviceID, const unsigned int value, virtual EventPropagation filterActions(PlayerAction action, int deviceID, const unsigned int value,
Input::InputType type, int playerId) { return EVENT_LET; } Input::InputType type, int playerId) { return EVENT_LET; }
/**
* \brief override this if you need to be notified of raw input in subclasses
*/
virtual void filterInput(Input::InputType type,
int deviceID,
int btnID,
int axisDir,
int value) {}
}; };
} }

View File

@ -348,6 +348,11 @@ bool DeviceManager::translateInput( Input::InputType type,
StateManager::ActivePlayer** player /* out */, StateManager::ActivePlayer** player /* out */,
PlayerAction* action /* out */ ) PlayerAction* action /* out */ )
{ {
if (GUIEngine::getCurrentScreen() != NULL)
{
GUIEngine::getCurrentScreen()->filterInput(type, deviceID, btnID, axisDir, value);
}
InputDevice *device = NULL; InputDevice *device = NULL;
// If the input event matches a bind on an input device, get a pointer to the device // If the input event matches a bind on an input device, get a pointer to the device

View File

@ -246,12 +246,13 @@ void OptionsScreenInput::unloaded()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
EventPropagation OptionsScreenInput::filterActions(PlayerAction action, int deviceID, void OptionsScreenInput::filterInput(Input::InputType type,
const unsigned int value, int deviceID,
Input::InputType type, int playerId) int btnID,
int axisDir,
int value)
{ {
/* if (type == Input::IT_STICKMOTION || type == Input::IT_STICKBUTTON)
if (value > Input::MAX_VALUE*2/3 && (type == Input::IT_STICKMOTION || type == Input::IT_STICKBUTTON))
{ {
GamePadDevice* gamepad = input_manager->getDeviceList()->getGamePadFromIrrID(deviceID); GamePadDevice* gamepad = input_manager->getDeviceList()->getGamePadFromIrrID(deviceID);
if (gamepad != NULL && gamepad->getConfiguration() != NULL) if (gamepad != NULL && gamepad->getConfiguration() != NULL)
@ -283,15 +284,12 @@ EventPropagation OptionsScreenInput::filterActions(PlayerAction action, int devi
} }
} }
} }
*/
return EVENT_LET;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void OptionsScreenInput::onUpdate(float dt, irr::video::IVideoDriver* drv) void OptionsScreenInput::onUpdate(float dt, irr::video::IVideoDriver* drv)
{ {
/*
std::map<std::string, float>::iterator it; std::map<std::string, float>::iterator it;
for (it = m_highlights.begin(); it != m_highlights.end();) for (it = m_highlights.begin(); it != m_highlights.end();)
{ {
@ -310,6 +308,5 @@ void OptionsScreenInput::onUpdate(float dt, irr::video::IVideoDriver* drv)
it++; it++;
} }
} }
*/
//m_highlights[internal_name] //m_highlights[internal_name]
} }

View File

@ -42,7 +42,7 @@ class OptionsScreenInput : public GUIEngine::Screen, public GUIEngine::ScreenSin
irr::gui::STKModifiedSpriteBank* m_icon_bank; irr::gui::STKModifiedSpriteBank* m_icon_bank;
// std::map<std::string, float> m_highlights; std::map<std::string, float> m_highlights;
public: public:
friend class GUIEngine::ScreenSingleton<OptionsScreenInput>; friend class GUIEngine::ScreenSingleton<OptionsScreenInput>;
@ -65,13 +65,14 @@ public:
*/ */
void rebuildDeviceList(); void rebuildDeviceList();
/** \brief Override callback from base class */ /** \brief implement callback from parent class GUIEngine::Screen */
virtual GUIEngine::EventPropagation filterActions(PlayerAction action, virtual void filterInput(Input::InputType type,
int deviceID, int deviceID,
const unsigned int value, int btnID,
Input::InputType type, int axisDir,
int playerId); int value);
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void onUpdate(float dt, irr::video::IVideoDriver* drv); virtual void onUpdate(float dt, irr::video::IVideoDriver* drv);
}; };