mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
DolphinQt: Display more user-friendly names in the mapping window device list.
This commit is contained in:
parent
53ede795a2
commit
1888770256
@ -59,6 +59,22 @@
|
|||||||
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
||||||
#include "InputCommon/InputConfig.h"
|
#include "InputCommon/InputConfig.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
QString GetUserFriendlyDeviceName(const std::string& str)
|
||||||
|
{
|
||||||
|
ciface::Core::DeviceQualifier qualifier;
|
||||||
|
qualifier.FromString(str);
|
||||||
|
|
||||||
|
return QStringLiteral("%1 (%2) %3")
|
||||||
|
.arg(QString::fromStdString(qualifier.name))
|
||||||
|
.arg(qualifier.cid + 1)
|
||||||
|
.arg(QString::fromStdString(qualifier.source));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
MappingWindow::MappingWindow(QWidget* parent, Type type, int port_num)
|
MappingWindow::MappingWindow(QWidget* parent, Type type, int port_num)
|
||||||
: QDialog(parent), m_port(port_num)
|
: QDialog(parent), m_port(port_num)
|
||||||
{
|
{
|
||||||
@ -363,8 +379,9 @@ void MappingWindow::OnGlobalDevicesChanged()
|
|||||||
|
|
||||||
for (const auto& name : g_controller_interface.GetAllDeviceStrings())
|
for (const auto& name : g_controller_interface.GetAllDeviceStrings())
|
||||||
{
|
{
|
||||||
|
const auto display_name = GetUserFriendlyDeviceName(name);
|
||||||
const auto qname = QString::fromStdString(name);
|
const auto qname = QString::fromStdString(name);
|
||||||
m_devices_combo->addItem(qname, qname);
|
m_devices_combo->addItem(display_name, qname);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto default_device = m_controller->GetDefaultDevice().ToString();
|
const auto default_device = m_controller->GetDefaultDevice().ToString();
|
||||||
@ -372,7 +389,7 @@ void MappingWindow::OnGlobalDevicesChanged()
|
|||||||
if (!default_device.empty())
|
if (!default_device.empty())
|
||||||
{
|
{
|
||||||
const auto default_device_index =
|
const auto default_device_index =
|
||||||
m_devices_combo->findText(QString::fromStdString(default_device));
|
m_devices_combo->findData(QString::fromStdString(default_device));
|
||||||
|
|
||||||
if (default_device_index != -1)
|
if (default_device_index != -1)
|
||||||
{
|
{
|
||||||
@ -382,9 +399,10 @@ void MappingWindow::OnGlobalDevicesChanged()
|
|||||||
{
|
{
|
||||||
// Selected device is not currently attached.
|
// Selected device is not currently attached.
|
||||||
m_devices_combo->insertSeparator(m_devices_combo->count());
|
m_devices_combo->insertSeparator(m_devices_combo->count());
|
||||||
|
const auto display_name = GetUserFriendlyDeviceName(default_device);
|
||||||
const auto qname = QString::fromStdString(default_device);
|
const auto qname = QString::fromStdString(default_device);
|
||||||
m_devices_combo->addItem(QLatin1Char{'['} + tr("disconnected") + QStringLiteral("] ") + qname,
|
m_devices_combo->addItem(
|
||||||
qname);
|
QLatin1Char{'['} + tr("disconnected") + QStringLiteral("] ") + display_name, qname);
|
||||||
m_devices_combo->setCurrentIndex(m_devices_combo->count() - 1);
|
m_devices_combo->setCurrentIndex(m_devices_combo->count() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user