| 482 | } |
| 483 | |
| 484 | void ControllerMacroEditWidget::updateBinds() |
| 485 | { |
| 486 | ControllerSettingsWindow* dialog = m_bwidget->getDialog(); |
| 487 | const Pad::ControllerInfo* cinfo = Pad::GetControllerInfo(m_bwidget->getControllerType()); |
| 488 | if (!cinfo) |
| 489 | return; |
| 490 | |
| 491 | std::vector<const InputBindingInfo*> new_binds; |
| 492 | for (u32 i = 0, bind_index = 0; i < static_cast<u32>(cinfo->bindings.size()); i++) |
| 493 | { |
| 494 | const InputBindingInfo& bi = cinfo->bindings[i]; |
| 495 | if (bi.bind_type == InputBindingInfo::Type::Motor) |
| 496 | continue; |
| 497 | |
| 498 | const QListWidgetItem* item = m_ui.bindList->item(static_cast<int>(bind_index)); |
| 499 | bind_index++; |
| 500 | |
| 501 | if (!item) |
| 502 | { |
| 503 | // shouldn't happen |
| 504 | continue; |
| 505 | } |
| 506 | |
| 507 | if (item->checkState() == Qt::Checked) |
| 508 | new_binds.push_back(&bi); |
| 509 | } |
| 510 | if (m_binds == new_binds) |
| 511 | return; |
| 512 | |
| 513 | m_binds = std::move(new_binds); |
| 514 | |
| 515 | std::string binds_string; |
| 516 | for (const InputBindingInfo* bi : m_binds) |
| 517 | { |
| 518 | if (!binds_string.empty()) |
| 519 | binds_string.append(" & "); |
| 520 | binds_string.append(bi->name); |
| 521 | } |
| 522 | |
| 523 | const std::string& section = m_bwidget->getConfigSection(); |
| 524 | const std::string key(fmt::format("Macro{}Binds", m_index + 1u)); |
| 525 | if (binds_string.empty()) |
| 526 | dialog->clearSettingValue(section.c_str(), key.c_str()); |
| 527 | else |
| 528 | dialog->setStringValue(section.c_str(), key.c_str(), binds_string.c_str()); |
| 529 | |
| 530 | m_parent->updateListItem(m_index); |
| 531 | } |
| 532 | |
| 533 | ////////////////////////////////////////////////////////////////////////// |
| 534 |
nothing calls this directly
no test coverage detected