void CButtonTranslator::MapAction(uint32_t buttonCode, const char *szAction, buttonMap &map) { int action = ACTION_NONE; if (!TranslateActionString(szAction, action) || !buttonCode) return; // no valid action, or an invalid buttoncode // have a valid action, and a valid button - map it. // check to see if we've already got this (button,action) pair defined buttonMap::iterator it = map.find(buttonCode); if (it == map.end() || (*it).second.id != action || (*it).second.strID != szAction) { // NOTE: This multimap is only being used as a normal map at this point (no support // for multiple actions per key) if (it != map.end()) map.erase(it); CButtonAction button; button.id = action; button.strID = szAction; map.insert(pair<uint32_t, CButtonAction>(buttonCode, button)); } }
void CButtonTranslator::MapAction(WORD wButtonCode, const char *szAction, buttonMap &map) { WORD wAction = ACTION_NONE; if (!TranslateActionString(szAction, wAction) || !wButtonCode) return; // no valid action, or an invalid buttoncode // have a valid action, and a valid button - map it. // check to see if we've already got this (button,action) pair defined buttonMap::iterator it = map.find(wButtonCode); if (it == map.end() || (*it).second.wID != wAction) { //char szTmp[128]; //sprintf(szTmp," action:%i button:%i\n", wAction,wButtonCode); //OutputDebugString(szTmp); CButtonAction button; button.wID = wAction; button.strID = szAction; map.insert(pair<WORD, CButtonAction>(wButtonCode, button)); } }