void MappingDlg::save() { m_active = false; if (m_change) { if (MessageBox(m_hDlg,I18N.MBOX_Save, I18N.APP_TITLE, MB_YESNO) != IDYES) { m_change = false; } } Mappings newmap; while (ListView_GetNextItem(m_hList, -1, LVNI_ALL) != -1) { LVITEM item = { 0 }; item.mask = LVIF_PARAM; if (!ListView_GetItem(m_hList, &item)) break; if (item.lParam != NULL) { if (m_change) newmap.push_back(*(Mapping*)item.lParam); delete (Mapping*)item.lParam; } if (!ListView_DeleteItem(m_hList, 0)) break; } ListView_DeleteAllItems(m_hList); if (m_change) { g_settings.Mappingdata.swap(newmap); g_settings.Save(); PostMessage(m_hWnd, WM_CHANGE_SETTING, 0, 0); } }
void update(const std::bitset<256>& button_state) { for(typename Mappings::iterator i = m_mappings.begin(); i != m_mappings.end(); ++i) { if (i->m_combo->match(button_state)) { // check if a superset matches bool superset_matches = false; for(std::vector<ButtonCombinationPtr>::iterator j = i->m_supersets.begin(); j != i->m_supersets.end(); ++j) { if ((*j)->match(button_state)) { superset_matches = true; break; } } if (superset_matches) { i->m_state = false; } else { i->m_state = true; } } else { i->m_state = false; } } }
void add(const ButtonCombination& combo, const C& data) { Mapping mapping; mapping.m_combo.reset(new ButtonCombination(combo)); mapping.m_state = false; mapping.m_data = data; m_mappings.push_back(mapping); }
void init(const ControllerMessageDescriptor& desc) { // init all bindings and clear obsolete superset mappings for(typename Mappings::iterator it = m_mappings.begin(); it != m_mappings.end(); ++it) { it->m_combo->init(desc); it->m_supersets.clear(); } // BROKEN: need to filter out duplicate bindings // regenerate superset mappings for(typename Mappings::iterator it = m_mappings.begin(); it != m_mappings.end(); ++it) { // find which already bound combinations the new one is a // superset of and add it to the list for(typename Mappings::iterator j = m_mappings.begin(); j != m_mappings.end(); ++j) { if (&*it != &*j) { if (it->m_combo->is_subset_of(*j->m_combo)) { it->m_supersets.push_back(j->m_combo); } } } } }
iterator end() { return m_mappings.end(); }
iterator begin() { return m_mappings.begin(); }