| 832 | } |
| 833 | |
| 834 | void DEV9SettingsWidget::LoadAdapters() |
| 835 | { |
| 836 | if (m_adaptersLoaded) |
| 837 | return; |
| 838 | |
| 839 | QSignalBlocker sb(m_ui.ethDev); |
| 840 | |
| 841 | m_api_list.push_back(Pcsx2Config::DEV9Options::NetApi::Unset); |
| 842 | |
| 843 | for (const AdapterEntry& adapter : PCAPAdapter::GetAdapters()) |
| 844 | AddAdapter(adapter); |
| 845 | #ifdef _WIN32 |
| 846 | for (const AdapterEntry& adapter : TAPAdapter::GetAdapters()) |
| 847 | AddAdapter(adapter); |
| 848 | #endif |
| 849 | for (const AdapterEntry& adapter : SocketAdapter::GetAdapters()) |
| 850 | AddAdapter(adapter); |
| 851 | |
| 852 | std::sort(m_api_list.begin(), m_api_list.end()); |
| 853 | for (auto& list : m_adapter_list) |
| 854 | std::sort(list.begin(), list.end(), [](const AdapterEntry& a, AdapterEntry& b) { return a.name < b.name; }); |
| 855 | |
| 856 | for (const Pcsx2Config::DEV9Options::NetApi& na : m_api_list) |
| 857 | { |
| 858 | m_api_namelist.push_back(s_api_name[static_cast<int>(na)]); |
| 859 | m_api_valuelist.push_back(Pcsx2Config::DEV9Options::NetApiNames[static_cast<int>(na)]); |
| 860 | } |
| 861 | |
| 862 | m_api_namelist.push_back(nullptr); |
| 863 | m_api_valuelist.push_back(nullptr); |
| 864 | |
| 865 | //We replace the blank entry with one for global settings |
| 866 | if (dialog()->isPerGameSettings()) |
| 867 | { |
| 868 | const std::string valueAPI = Host::GetBaseStringSettingValue("DEV9/Eth", "EthApi", Pcsx2Config::DEV9Options::NetApiNames[static_cast<int>(Pcsx2Config::DEV9Options::NetApi::Unset)]); |
| 869 | for (int i = 0; Pcsx2Config::DEV9Options::NetApiNames[i] != nullptr; i++) |
| 870 | { |
| 871 | if (valueAPI == Pcsx2Config::DEV9Options::NetApiNames[i]) |
| 872 | { |
| 873 | m_global_api = static_cast<Pcsx2Config::DEV9Options::NetApi>(i); |
| 874 | break; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | std::vector<AdapterEntry> baseList = m_adapter_list[static_cast<u32>(m_global_api)]; |
| 879 | |
| 880 | std::string baseAdapter = " "; |
| 881 | const std::string valueGUID = Host::GetBaseStringSettingValue("DEV9/Eth", "EthDevice", ""); |
| 882 | for (size_t i = 0; i < baseList.size(); i++) |
| 883 | { |
| 884 | if (baseList[i].guid == valueGUID) |
| 885 | { |
| 886 | baseAdapter = baseList[i].name; |
| 887 | break; |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | m_adapter_list[static_cast<u32>(Pcsx2Config::DEV9Options::NetApi::Unset)][0].name = baseAdapter; |
nothing calls this directly
no test coverage detected