void Hotkeys::OnKeyListItemChange(NMLISTVIEW *lv) { if (lv->uChanged & LVIF_STATE) { if (lv->uNewState & LVIS_SELECTED) { int index = lv->iItem; #if ENABLE_3RVX_LOG != 0 HotkeyInfo *current = &_keyInfo[index]; CLOG(L"Selecting key combination %d:", index); QCLOG(L"%s", current->ToString().c_str()); #endif LoadSelection(index); } } }
std::unordered_map<int, HotkeyInfo> Settings::Hotkeys() { std::unordered_map<int, HotkeyInfo> keyMappings; if (_root == NULL) { return keyMappings; } tinyxml2::XMLElement *hotkeys = _root->FirstChildElement("hotkeys"); if (hotkeys == NULL) { return keyMappings; } tinyxml2::XMLElement *hotkey = hotkeys->FirstChildElement("hotkey"); for (; hotkey != NULL; hotkey = hotkey->NextSiblingElement()) { const char *actionStr = hotkey->Attribute("action"); if (actionStr == NULL) { CLOG(L"No action provided for hotkey; skipping"); continue; } int action = -1; std::wstring wActionStr = StringUtils::Widen(actionStr); for (unsigned int i = 0; i < HotkeyInfo::ActionNames.size(); ++i) { const wchar_t *currentAction = HotkeyInfo::ActionNames[i].c_str(); if (_wcsicmp(wActionStr.c_str(), currentAction) == 0) { action = i; break; } } if (action == -1) { CLOG(L"Hotkey action '%s' not recognized; skipping", wActionStr.c_str()); continue; } int combination = -1; hotkey->QueryIntAttribute("combination", &combination); if (combination == -1) { CLOG(L"No key combination provided for hotkey; skipping"); continue; } HotkeyInfo hki; hki.action = action; hki.keyCombination = combination; /* Does this hotkey action have any arguments? */ tinyxml2::XMLElement *arg = hotkey->FirstChildElement("arg"); for (; arg != NULL; arg = arg->NextSiblingElement()) { const char *argStr = arg->GetText(); hki.args.push_back(StringUtils::Widen(argStr)); } /* Do a validity check on the finished HKI object */ if (hki.Valid() == false) { continue; } /* Whew, we made it! */ CLOG(L"%s", hki.ToString().c_str()); keyMappings[combination] = hki; } return keyMappings; }