Skip to content

Commit

Permalink
Revert "restoring functionality broken by earlier re factor. But stil…
Browse files Browse the repository at this point in the history
…l remains refactored"

This reverts commit d433569c1538738ff40ebadf132bb67ab16d6d53.

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@35010 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information
mkortstiege committed Oct 25, 2010
1 parent e46fd8d commit 2c8c9c6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 26 deletions.
65 changes: 40 additions & 25 deletions xbmc/ButtonTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ void CButtonTranslator::MapJoystickActions(int windowID, TiXmlNode *pJoystick)
// CLog::Log(LOGDEBUG, "Found Joystick map for window %d using %s", windowID, it->c_str());
it++;
}

return;
}

bool CButtonTranslator::TranslateJoystickString(int window, const char* szDevice, int id, short inputType, int& action, CStdString& strAction, bool &fullrange)
Expand Down Expand Up @@ -776,15 +778,27 @@ void CButtonTranslator::MapAction(uint32_t buttonCode, const char *szAction, but
}
}

bool CButtonTranslator::HasDeviceType(TiXmlNode *pWindow, CStdString type)
enum CButtonTranslator::ButtonDeviceType CButtonTranslator::GetDeviceType(TiXmlNode *pWindow)
{
return pWindow->FirstChild(type) != NULL;
TiXmlNode *firstChild = pWindow->FirstChild();
if (firstChild != NULL)
{
const char *value = firstChild->Value();
if (value == "gamepad")
return Gamepad;
if (value == "remote")
return Remote;
if (value == "universalremote")
return UniversalRemote;
if (value == "keyboard")
return Keyboard;
}
return Unknown;
}

void CButtonTranslator::MapWindowActions(TiXmlNode *pWindow, int windowID)
{
if (!pWindow || windowID == WINDOW_INVALID)
return;
if (!pWindow || windowID == WINDOW_INVALID) return;
buttonMap map;
std::map<int, buttonMap>::iterator it = translatorMap.find(windowID);
if (it != translatorMap.end())
Expand All @@ -793,31 +807,32 @@ void CButtonTranslator::MapWindowActions(TiXmlNode *pWindow, int windowID)
translatorMap.erase(it);
}
TiXmlNode* pDevice;

const char* types[] = {"gamepad", "remote", "keyboard", "universalremote", NULL};
for (int i = 0; types[i]; ++i)
ButtonDeviceType remoteType = GetDeviceType(pWindow);
if (remoteType != Unknown)
{
CStdString type(types[i]);
if (HasDeviceType(pWindow, type))
pDevice = pWindow->FirstChild();
TiXmlElement *pButton = pDevice->FirstChildElement();
while (pButton)
{
pDevice = pWindow->FirstChild(type);
TiXmlElement *pButton = pDevice->FirstChildElement();
while (pButton)
uint32_t buttonCode;
switch (remoteType)
{
uint32_t buttonCode;
if (type == "gamepad")
buttonCode = TranslateGamepadString(pButton->Value());
else if (type == "remote")
buttonCode = TranslateRemoteString(pButton->Value());
else if (type == "universalremote")
buttonCode = TranslateUniversalRemoteString(pButton->Value());
else if (type == "keyboard")
buttonCode = TranslateKeyboardButton(pButton);

if (buttonCode && pButton->FirstChild())
MapAction(buttonCode, pButton->FirstChild()->Value(), map);
pButton = pButton->NextSiblingElement();
case Gamepad:
buttonCode = TranslateGamepadString(pButton->Value());
break;
case Remote:
buttonCode = TranslateRemoteString(pButton->Value());
break;
case UniversalRemote:
buttonCode = TranslateUniversalRemoteString(pButton->Value());
break;
case Keyboard:
buttonCode = TranslateKeyboardButton(pButton);
break;
}
if (buttonCode && pButton->FirstChild())
MapAction(buttonCode, pButton->FirstChild()->Value(), map);
pButton = pButton->NextSiblingElement();
}
}
#if defined(HAS_SDL_JOYSTICK) || defined(HAS_EVENT_SERVER)
Expand Down
10 changes: 9 additions & 1 deletion xbmc/ButtonTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ class CButtonTranslator
CButtonTranslator(const CButtonTranslator&);
CButtonTranslator const& operator=(CButtonTranslator const&);
virtual ~CButtonTranslator();
bool HasDeviceType(TiXmlNode *pWindow, CStdString type);
enum ButtonDeviceType
{
Unknown,
Gamepad,
Remote,
Keyboard,
UniversalRemote
};
enum ButtonDeviceType GetDeviceType(TiXmlNode *pWindow);
public:
///access to singleton
static CButtonTranslator& GetInstance();
Expand Down

0 comments on commit 2c8c9c6

Please sign in to comment.