mirror of https://github.com/PCSX2/pcsx2.git
USB: Make GetDeviceTypes() return C strings
This commit is contained in:
parent
ec180e2771
commit
ff02d41992
|
@ -72,7 +72,7 @@ QIcon ControllerBindingWidget::getIcon() const
|
|||
void ControllerBindingWidget::populateControllerTypes()
|
||||
{
|
||||
for (const auto& [name, display_name] : PAD::GetControllerTypeNames())
|
||||
m_ui.controllerType->addItem(QString::fromStdString(display_name), QString::fromStdString(name));
|
||||
m_ui.controllerType->addItem(qApp->translate("Pad", display_name), QString::fromStdString(name));
|
||||
}
|
||||
|
||||
void ControllerBindingWidget::onTypeChanged()
|
||||
|
@ -902,7 +902,7 @@ QIcon USBDeviceWidget::getIcon() const
|
|||
void USBDeviceWidget::populateDeviceTypes()
|
||||
{
|
||||
for (const auto& [name, display_name] : USB::GetDeviceTypes())
|
||||
m_ui.deviceType->addItem(QString::fromStdString(display_name), QString::fromStdString(name));
|
||||
m_ui.deviceType->addItem(qApp->translate("USB", display_name), QString::fromUtf8(name));
|
||||
}
|
||||
|
||||
void USBDeviceWidget::populatePages()
|
||||
|
|
|
@ -3796,12 +3796,12 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
const PAD::ControllerInfo* ci = PAD::GetControllerInfo(type);
|
||||
if (MenuButton(ICON_FA_GAMEPAD " Controller Type", ci ? ci->display_name : "Unknown"))
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> raw_options(PAD::GetControllerTypeNames());
|
||||
const std::vector<std::pair<const char*, const char*>> raw_options = PAD::GetControllerTypeNames();
|
||||
ImGuiFullscreen::ChoiceDialogOptions options;
|
||||
options.reserve(raw_options.size());
|
||||
for (auto& it : raw_options)
|
||||
{
|
||||
options.emplace_back(std::move(it.second), type == it.first);
|
||||
options.emplace_back(it.second, type == it.first);
|
||||
}
|
||||
OpenChoiceDialog(fmt::format("Port {} Controller Type", global_slot + 1).c_str(), false, std::move(options),
|
||||
[game_settings = IsEditingGameSettings(bsi), section, raw_options = std::move(raw_options)](
|
||||
|
@ -3811,7 +3811,7 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
|
||||
auto lock = Host::GetSettingsLock();
|
||||
SettingsInterface* bsi = GetEditingSettingsInterface(game_settings);
|
||||
bsi->SetStringValue(section, "Type", raw_options[index].first.c_str());
|
||||
bsi->SetStringValue(section, "Type", raw_options[index].first);
|
||||
SetSettingsChanged(bsi);
|
||||
CloseChoiceDialog();
|
||||
});
|
||||
|
@ -3982,12 +3982,12 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
const std::string type(USB::GetConfigDevice(*bsi, port));
|
||||
if (MenuButton(ICON_FA_GAMEPAD " Device Type", USB::GetDeviceName(type)))
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> raw_options(USB::GetDeviceTypes());
|
||||
const std::vector<std::pair<const char*, const char*>> raw_options = USB::GetDeviceTypes();
|
||||
ImGuiFullscreen::ChoiceDialogOptions options;
|
||||
options.reserve(raw_options.size());
|
||||
for (auto& it : raw_options)
|
||||
{
|
||||
options.emplace_back(std::move(it.second), type == it.first);
|
||||
options.emplace_back(it.second, type == it.first);
|
||||
}
|
||||
OpenChoiceDialog(fmt::format("Port {} Device", port + 1).c_str(), false, std::move(options),
|
||||
[game_settings = IsEditingGameSettings(bsi), raw_options = std::move(raw_options), port](
|
||||
|
@ -3997,7 +3997,7 @@ void FullscreenUI::DrawControllerSettingsPage()
|
|||
|
||||
auto lock = Host::GetSettingsLock();
|
||||
SettingsInterface* bsi = GetEditingSettingsInterface(game_settings);
|
||||
USB::SetConfigDevice(*bsi, port, raw_options[static_cast<u32>(index)].first.c_str());
|
||||
USB::SetConfigDevice(*bsi, port, raw_options[static_cast<u32>(index)].first);
|
||||
SetSettingsChanged(bsi);
|
||||
CloseChoiceDialog();
|
||||
});
|
||||
|
|
|
@ -458,9 +458,9 @@ const PAD::ControllerInfo* PAD::GetControllerInfo(const std::string_view& name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> PAD::GetControllerTypeNames()
|
||||
std::vector<std::pair<const char*, const char*>> PAD::GetControllerTypeNames()
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> ret;
|
||||
std::vector<std::pair<const char*, const char*>> ret;
|
||||
for (const ControllerInfo& info : s_controller_info)
|
||||
ret.emplace_back(info.name, info.display_name);
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace PAD
|
|||
void Update();
|
||||
|
||||
/// Returns a list of controller type names. Pair of [name, display name].
|
||||
std::vector<std::pair<std::string, std::string>> GetControllerTypeNames();
|
||||
std::vector<std::pair<const char*, const char*>> GetControllerTypeNames();
|
||||
|
||||
/// Returns the list of binds for the specified controller type.
|
||||
std::vector<std::string> GetControllerBinds(const std::string_view& type);
|
||||
|
|
|
@ -553,10 +553,10 @@ const char* USB::DeviceTypeIndexToName(s32 device)
|
|||
return proxy ? proxy->TypeName() : "None";
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> USB::GetDeviceTypes()
|
||||
std::vector<std::pair<const char*, const char*>> USB::GetDeviceTypes()
|
||||
{
|
||||
RegisterDevice& rd = RegisterDevice::instance();
|
||||
std::vector<std::pair<std::string, std::string>> ret;
|
||||
std::vector<std::pair<const char*, const char*>> ret;
|
||||
ret.reserve(rd.Map().size() + 1);
|
||||
ret.emplace_back("None", "Not Connected");
|
||||
for (const auto& it : rd.Map())
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace USB
|
|||
s32 DeviceTypeNameToIndex(const std::string_view& device);
|
||||
const char* DeviceTypeIndexToName(s32 device);
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> GetDeviceTypes();
|
||||
std::vector<std::pair<const char*, const char*>> GetDeviceTypes();
|
||||
const char* GetDeviceName(const std::string_view& device);
|
||||
const char* GetDeviceSubtypeName(const std::string_view& device, u32 subtype);
|
||||
gsl::span<const char*> GetDeviceSubtypes(const std::string_view& device);
|
||||
|
|
Loading…
Reference in New Issue