Skip to content

Commit

Permalink
[input] fix long press fallback handling after xbmc#7846
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaggi authored and stevegal committed Jan 9, 2016
1 parent 50cd1cb commit 46c785e
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions xbmc/input/ButtonTranslator.cpp
Expand Up @@ -1185,34 +1185,38 @@ CAction CButtonTranslator::GetGlobalAction(const CKey &key)
bool CButtonTranslator::HasLonpressMapping(int window, const CKey &key)
{
std::map<int, buttonMap>::const_iterator it = m_translatorMap.find(window);
if (it == m_translatorMap.end())
if (it != m_translatorMap.end())
{
// first check if we have a fallback for the window
int fallbackWindow = GetFallbackWindow(window);
if (fallbackWindow > -1 && HasLonpressMapping(fallbackWindow, key))
uint32_t code = key.GetButtonCode();
code |= CKey::MODIFIER_LONG;
buttonMap::const_iterator it2 = (*it).second.find(code);

if (it2 != (*it).second.end())
return true;

// fallback to default section if there is no key mapping found
return HasLonpressMapping(-1, key);
#ifdef TARGET_POSIX
// Some buttoncodes changed in Hardy
if ((code & KEY_VKEY) == KEY_VKEY && (code & 0x0F00))
{
code &= ~0x0F00;
it2 = (*it).second.find(code);
if (it2 != (*it).second.end())
return true;
}
#endif
}

uint32_t code = key.GetButtonCode();
code |= CKey::MODIFIER_LONG;
buttonMap::const_iterator it2 = (*it).second.find(code);

if (it2 != (*it).second.end())
return true;

#ifdef TARGET_POSIX
// Some buttoncodes changed in Hardy
if ((code & KEY_VKEY) == KEY_VKEY && (code & 0x0F00))
// no key mapping found for the current window do the fallback handling
if (window > -1)
{
code &= ~0x0F00;
it2 = (*it).second.find(code);
if (it2 != (*it).second.end())
// first check if we have a fallback for the window
int fallbackWindow = GetFallbackWindow(window);
if (fallbackWindow > -1 && HasLonpressMapping(fallbackWindow, key))
return true;

// fallback to default section
return HasLonpressMapping(-1, key);
}
#endif

return false;
}
Expand Down

0 comments on commit 46c785e

Please sign in to comment.