bool CButtonTranslator::TranslateJoystickString(int window, const char* szDevice, int id, short inputType, int& action, CStdString& strAction, bool &fullrange) { bool found = false; map<string, JoystickMap>::iterator it; map<string, JoystickMap> *jmap; fullrange = false; if (inputType == JACTIVE_AXIS) jmap = &m_joystickAxisMap; else if (inputType == JACTIVE_BUTTON) jmap = &m_joystickButtonMap; else if (inputType == JACTIVE_HAT) jmap = &m_joystickHatMap; else { CLog::Log(LOGERROR, "Error reading joystick input type"); return false; } it = jmap->find(szDevice); if (it==jmap->end()) return false; JoystickMap wmap = it->second; JoystickMap::iterator it2; map<int, string> windowbmap; map<int, string> globalbmap; map<int, string>::iterator it3; it2 = wmap.find(window); // first try local window map if (it2!=wmap.end()) { windowbmap = it2->second; it3 = windowbmap.find(id); if (it3 != windowbmap.end()) { strAction = (it3->second).c_str(); found = true; } it3 = windowbmap.find(abs(id)|0xFFFF0000); if (it3 != windowbmap.end()) { strAction = (it3->second).c_str(); found = true; fullrange = true; } // Hats joystick it3 = windowbmap.find(id|0xFFF00000); if (it3 != windowbmap.end()) { strAction = (it3->second).c_str(); found = true; } } // if not found, try global map if (!found) { it2 = wmap.find(-1); if (it2 != wmap.end()) { globalbmap = it2->second; it3 = globalbmap.find(id); if (it3 != globalbmap.end()) { strAction = (it3->second).c_str(); found = true; } it3 = globalbmap.find(abs(id)|0xFFFF0000); if (it3 != globalbmap.end()) { strAction = (it3->second).c_str(); found = true; fullrange = true; } it3 = globalbmap.find(id|0xFFF00000); if (it3 != globalbmap.end()) { strAction = (it3->second).c_str(); found = true; } } } // translated found action if (found) return TranslateActionString(strAction.c_str(), action); return false; }
bool CButtonTranslator::TranslateJoystickString(WORD wWindow, const char* szDevice, int id, bool axis, WORD& action, CStdString& strAction, bool &fullrange) { bool found = false; map<string, JoystickMap>::iterator it; map<string, JoystickMap> *jmap; fullrange = false; if (axis) { jmap = &m_joystickAxisMap; } else { jmap = &m_joystickButtonMap; } it = jmap->find(szDevice); if (it==jmap->end()) return false; JoystickMap wmap = it->second; JoystickMap::iterator it2; map<int, string> windowbmap; map<int, string> globalbmap; map<int, string>::iterator it3; it2 = wmap.find(wWindow); // first try local window map if (it2!=wmap.end()) { windowbmap = it2->second; it3 = windowbmap.find(id); if (it3 != windowbmap.end()) { strAction = (it3->second).c_str(); found = true; } it3 = windowbmap.find(abs(id)|0xFFFF0000); if (it3 != windowbmap.end()) { strAction = (it3->second).c_str(); found = true; fullrange = true; } } // if not found, try global map if (!found) { it2 = wmap.find((WORD)-1); if (it2 != wmap.end()) { globalbmap = it2->second; it3 = globalbmap.find(id); if (it3 != globalbmap.end()) { strAction = (it3->second).c_str(); found = true; } it3 = globalbmap.find(abs(id)|0xFFFF0000); if (it3 != globalbmap.end()) { strAction = (it3->second).c_str(); found = true; fullrange = true; } } } // translated found action if (found) { return TranslateActionString(strAction.c_str(), action); } return false; }