Qt: Work around QList<QPair> marshalling issue
This commit is contained in:
parent
6bfd862cb3
commit
6021e435ba
|
@ -269,11 +269,13 @@ void ControllerBindingWidget::onAutomaticBindingClicked()
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
bool added = false;
|
bool added = false;
|
||||||
|
|
||||||
for (const QPair<QString, QString>& dev : m_dialog->getDeviceList())
|
for (const auto& [identifier, device_name] : m_dialog->getDeviceList())
|
||||||
{
|
{
|
||||||
// we set it as data, because the device list could get invalidated while the menu is up
|
// we set it as data, because the device list could get invalidated while the menu is up
|
||||||
QAction* action = menu.addAction(QStringLiteral("%1 (%2)").arg(dev.first).arg(dev.second));
|
const QString qidentifier = QString::fromStdString(identifier);
|
||||||
action->setData(dev.first);
|
QAction* action =
|
||||||
|
menu.addAction(QStringLiteral("%1 (%2)").arg(qidentifier).arg(QString::fromStdString(device_name)));
|
||||||
|
action->setData(qidentifier);
|
||||||
connect(action, &QAction::triggered, this,
|
connect(action, &QAction::triggered, this,
|
||||||
[this, action]() { doDeviceAutomaticBinding(action->data().toString()); });
|
[this, action]() { doDeviceAutomaticBinding(action->data().toString()); });
|
||||||
added = true;
|
added = true;
|
||||||
|
|
|
@ -220,21 +220,21 @@ void ControllerSettingsWindow::onRestoreDefaultsClicked()
|
||||||
switchProfile({});
|
switchProfile({});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerSettingsWindow::onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices)
|
void ControllerSettingsWindow::onInputDevicesEnumerated(const std::vector<std::pair<std::string, std::string>>& devices)
|
||||||
{
|
{
|
||||||
m_device_list = devices;
|
m_device_list = devices;
|
||||||
for (const QPair<QString, QString>& device : devices)
|
for (const auto& [device_name, display_name] : m_device_list)
|
||||||
m_global_settings->addDeviceToList(device.first, device.second);
|
m_global_settings->addDeviceToList(QString::fromStdString(device_name), QString::fromStdString(display_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerSettingsWindow::onInputDeviceConnected(const QString& identifier, const QString& device_name)
|
void ControllerSettingsWindow::onInputDeviceConnected(const std::string& identifier, const std::string& device_name)
|
||||||
{
|
{
|
||||||
m_device_list.emplace_back(identifier, device_name);
|
m_device_list.emplace_back(identifier, device_name);
|
||||||
m_global_settings->addDeviceToList(identifier, device_name);
|
m_global_settings->addDeviceToList(QString::fromStdString(identifier), QString::fromStdString(device_name));
|
||||||
g_emu_thread->enumerateVibrationMotors();
|
g_emu_thread->enumerateVibrationMotors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllerSettingsWindow::onInputDeviceDisconnected(const QString& identifier)
|
void ControllerSettingsWindow::onInputDeviceDisconnected(const std::string& identifier)
|
||||||
{
|
{
|
||||||
for (auto iter = m_device_list.begin(); iter != m_device_list.end(); ++iter)
|
for (auto iter = m_device_list.begin(); iter != m_device_list.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
@ -245,7 +245,7 @@ void ControllerSettingsWindow::onInputDeviceDisconnected(const QString& identifi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_global_settings->removeDeviceFromList(identifier);
|
m_global_settings->removeDeviceFromList(QString::fromStdString(identifier));
|
||||||
g_emu_thread->enumerateVibrationMotors();
|
g_emu_thread->enumerateVibrationMotors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,8 +385,8 @@ void ControllerSettingsWindow::createWidgets()
|
||||||
m_ui.settingsContainer->addWidget(m_global_settings);
|
m_ui.settingsContainer->addWidget(m_global_settings);
|
||||||
connect(m_global_settings, &ControllerGlobalSettingsWidget::bindingSetupChanged, this,
|
connect(m_global_settings, &ControllerGlobalSettingsWidget::bindingSetupChanged, this,
|
||||||
&ControllerSettingsWindow::createWidgets);
|
&ControllerSettingsWindow::createWidgets);
|
||||||
for (const QPair<QString, QString>& dev : m_device_list)
|
for (const auto& [identifier, device_name] : m_device_list)
|
||||||
m_global_settings->addDeviceToList(dev.first, dev.second);
|
m_global_settings->addDeviceToList(QString::fromStdString(identifier), QString::fromStdString(device_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// load mtap settings
|
// load mtap settings
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class ControllerGlobalSettingsWidget;
|
class ControllerGlobalSettingsWidget;
|
||||||
class ControllerBindingWidget;
|
class ControllerBindingWidget;
|
||||||
|
@ -47,7 +49,7 @@ public:
|
||||||
|
|
||||||
ALWAYS_INLINE HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }
|
ALWAYS_INLINE HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; }
|
||||||
|
|
||||||
ALWAYS_INLINE const QList<QPair<QString, QString>>& getDeviceList() const { return m_device_list; }
|
ALWAYS_INLINE const std::vector<std::pair<std::string, std::string>>& getDeviceList() const { return m_device_list; }
|
||||||
ALWAYS_INLINE const QStringList& getVibrationMotors() const { return m_vibration_motors; }
|
ALWAYS_INLINE const QStringList& getVibrationMotors() const { return m_vibration_motors; }
|
||||||
|
|
||||||
ALWAYS_INLINE bool isEditingGlobalSettings() const { return m_profile_name.isEmpty(); }
|
ALWAYS_INLINE bool isEditingGlobalSettings() const { return m_profile_name.isEmpty(); }
|
||||||
|
@ -80,9 +82,9 @@ private Q_SLOTS:
|
||||||
void onDeleteProfileClicked();
|
void onDeleteProfileClicked();
|
||||||
void onRestoreDefaultsClicked();
|
void onRestoreDefaultsClicked();
|
||||||
|
|
||||||
void onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices);
|
void onInputDevicesEnumerated(const std::vector<std::pair<std::string, std::string>>& devices);
|
||||||
void onInputDeviceConnected(const QString& identifier, const QString& device_name);
|
void onInputDeviceConnected(const std::string& identifier, const std::string& device_name);
|
||||||
void onInputDeviceDisconnected(const QString& identifier);
|
void onInputDeviceDisconnected(const std::string& identifier);
|
||||||
void onVibrationMotorsEnumerated(const QList<InputBindingKey>& motors);
|
void onVibrationMotorsEnumerated(const QList<InputBindingKey>& motors);
|
||||||
|
|
||||||
void createWidgets();
|
void createWidgets();
|
||||||
|
@ -99,7 +101,7 @@ private:
|
||||||
std::array<ControllerBindingWidget*, MAX_PORTS> m_port_bindings{};
|
std::array<ControllerBindingWidget*, MAX_PORTS> m_port_bindings{};
|
||||||
HotkeySettingsWidget* m_hotkey_settings = nullptr;
|
HotkeySettingsWidget* m_hotkey_settings = nullptr;
|
||||||
|
|
||||||
QList<QPair<QString, QString>> m_device_list;
|
std::vector<std::pair<std::string, std::string>> m_device_list;
|
||||||
QStringList m_vibration_motors;
|
QStringList m_vibration_motors;
|
||||||
|
|
||||||
QString m_profile_name;
|
QString m_profile_name;
|
||||||
|
|
|
@ -159,6 +159,9 @@ void QtHost::RegisterTypes()
|
||||||
qRegisterMetaType<const GameList::Entry*>();
|
qRegisterMetaType<const GameList::Entry*>();
|
||||||
qRegisterMetaType<GPURenderer>("GPURenderer");
|
qRegisterMetaType<GPURenderer>("GPURenderer");
|
||||||
qRegisterMetaType<InputBindingKey>("InputBindingKey");
|
qRegisterMetaType<InputBindingKey>("InputBindingKey");
|
||||||
|
qRegisterMetaType<std::string>("std::string");
|
||||||
|
qRegisterMetaType<std::vector<std::pair<std::string, std::string>>>(
|
||||||
|
"std::vector<std::pair<std::string, std::string>>");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtHost::InBatchMode()
|
bool QtHost::InBatchMode()
|
||||||
|
@ -1099,13 +1102,7 @@ void EmuThread::enumerateInputDevices()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::pair<std::string, std::string>> devs(InputManager::EnumerateDevices());
|
onInputDevicesEnumerated(InputManager::EnumerateDevices());
|
||||||
QList<QPair<QString, QString>> qdevs;
|
|
||||||
qdevs.reserve(devs.size());
|
|
||||||
for (const std::pair<std::string, std::string>& dev : devs)
|
|
||||||
qdevs.emplace_back(QString::fromStdString(dev.first), QString::fromStdString(dev.second));
|
|
||||||
|
|
||||||
onInputDevicesEnumerated(qdevs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuThread::enumerateVibrationMotors()
|
void EmuThread::enumerateVibrationMotors()
|
||||||
|
@ -1863,9 +1860,7 @@ void Host::AddFixedInputBindings(SettingsInterface& si)
|
||||||
|
|
||||||
void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name)
|
void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name)
|
||||||
{
|
{
|
||||||
emit g_emu_thread->onInputDeviceConnected(
|
emit g_emu_thread->onInputDeviceConnected(std::string(identifier), std::string(device_name));
|
||||||
identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()),
|
|
||||||
device_name.empty() ? QString() : QString::fromUtf8(device_name.data(), device_name.size()));
|
|
||||||
|
|
||||||
if (System::IsValid() || g_emu_thread->isRunningFullscreenUI())
|
if (System::IsValid() || g_emu_thread->isRunningFullscreenUI())
|
||||||
{
|
{
|
||||||
|
@ -1877,8 +1872,7 @@ void Host::OnInputDeviceConnected(std::string_view identifier, std::string_view
|
||||||
|
|
||||||
void Host::OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier)
|
void Host::OnInputDeviceDisconnected(InputBindingKey key, std::string_view identifier)
|
||||||
{
|
{
|
||||||
emit g_emu_thread->onInputDeviceDisconnected(
|
emit g_emu_thread->onInputDeviceDisconnected(std::string(identifier));
|
||||||
identifier.empty() ? QString() : QString::fromUtf8(identifier.data(), identifier.size()));
|
|
||||||
|
|
||||||
if (g_settings.pause_on_controller_disconnection && System::GetState() == System::State::Running &&
|
if (g_settings.pause_on_controller_disconnection && System::GetState() == System::State::Running &&
|
||||||
InputManager::HasAnyBindingsForSource(key))
|
InputManager::HasAnyBindingsForSource(key))
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -124,9 +125,9 @@ Q_SIGNALS:
|
||||||
void statusMessage(const QString& message);
|
void statusMessage(const QString& message);
|
||||||
void debuggerMessageReported(const QString& message);
|
void debuggerMessageReported(const QString& message);
|
||||||
void settingsResetToDefault(bool system, bool controller);
|
void settingsResetToDefault(bool system, bool controller);
|
||||||
void onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices);
|
void onInputDevicesEnumerated(const std::vector<std::pair<std::string, std::string>>& devices);
|
||||||
void onInputDeviceConnected(const QString& identifier, const QString& device_name);
|
void onInputDeviceConnected(const std::string& identifier, const std::string& device_name);
|
||||||
void onInputDeviceDisconnected(const QString& identifier);
|
void onInputDeviceDisconnected(const std::string& identifier);
|
||||||
void onVibrationMotorsEnumerated(const QList<InputBindingKey>& motors);
|
void onVibrationMotorsEnumerated(const QList<InputBindingKey>& motors);
|
||||||
void systemStarting();
|
void systemStarting();
|
||||||
void systemStarted();
|
void systemStarted();
|
||||||
|
|
|
@ -445,11 +445,13 @@ void SetupWizardDialog::openAutomaticMappingMenu(u32 port, QLabel* update_label)
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
bool added = false;
|
bool added = false;
|
||||||
|
|
||||||
for (const QPair<QString, QString>& dev : m_device_list)
|
for (const auto& [identifier, device_name] : m_device_list)
|
||||||
{
|
{
|
||||||
// we set it as data, because the device list could get invalidated while the menu is up
|
// we set it as data, because the device list could get invalidated while the menu is up
|
||||||
QAction* action = menu.addAction(QStringLiteral("%1 (%2)").arg(dev.first).arg(dev.second));
|
const QString qidentifier = QString::fromStdString(identifier);
|
||||||
action->setData(dev.first);
|
QAction* action =
|
||||||
|
menu.addAction(QStringLiteral("%1 (%2)").arg(qidentifier).arg(QString::fromStdString(device_name)));
|
||||||
|
action->setData(qidentifier);
|
||||||
connect(action, &QAction::triggered, this, [this, port, update_label, action]() {
|
connect(action, &QAction::triggered, this, [this, port, update_label, action]() {
|
||||||
doDeviceAutomaticBinding(port, update_label, action->data().toString());
|
doDeviceAutomaticBinding(port, update_label, action->data().toString());
|
||||||
});
|
});
|
||||||
|
@ -492,17 +494,17 @@ void SetupWizardDialog::doDeviceAutomaticBinding(u32 port, QLabel* update_label,
|
||||||
update_label->setText(device);
|
update_label->setText(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizardDialog::onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices)
|
void SetupWizardDialog::onInputDevicesEnumerated(const std::vector<std::pair<std::string, std::string>>& devices)
|
||||||
{
|
{
|
||||||
m_device_list = devices;
|
m_device_list = devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizardDialog::onInputDeviceConnected(const QString& identifier, const QString& device_name)
|
void SetupWizardDialog::onInputDeviceConnected(const std::string& identifier, const std::string& device_name)
|
||||||
{
|
{
|
||||||
m_device_list.emplace_back(identifier, device_name);
|
m_device_list.emplace_back(identifier, device_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizardDialog::onInputDeviceDisconnected(const QString& identifier)
|
void SetupWizardDialog::onInputDeviceDisconnected(const std::string& identifier)
|
||||||
{
|
{
|
||||||
for (auto iter = m_device_list.begin(); iter != m_device_list.end(); ++iter)
|
for (auto iter = m_device_list.begin(); iter != m_device_list.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>.
|
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>.
|
||||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -7,12 +7,15 @@
|
||||||
|
|
||||||
#include "ui_setupwizarddialog.h"
|
#include "ui_setupwizarddialog.h"
|
||||||
|
|
||||||
|
#include "core/bios.h"
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QVector>
|
#include <QtCore/QVector>
|
||||||
#include <QtWidgets/QDialog>
|
#include <QtWidgets/QDialog>
|
||||||
|
#include <string>
|
||||||
#include "core/bios.h"
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class SetupWizardDialog final : public QDialog
|
class SetupWizardDialog final : public QDialog
|
||||||
{
|
{
|
||||||
|
@ -42,9 +45,9 @@ private Q_SLOTS:
|
||||||
void refreshDirectoryList();
|
void refreshDirectoryList();
|
||||||
void resizeDirectoryListColumns();
|
void resizeDirectoryListColumns();
|
||||||
|
|
||||||
void onInputDevicesEnumerated(const QList<QPair<QString, QString>>& devices);
|
void onInputDevicesEnumerated(const std::vector<std::pair<std::string, std::string>>& devices);
|
||||||
void onInputDeviceConnected(const QString& identifier, const QString& device_name);
|
void onInputDeviceConnected(const std::string& identifier, const std::string& device_name);
|
||||||
void onInputDeviceDisconnected(const QString& identifier);
|
void onInputDeviceDisconnected(const std::string& identifier);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event);
|
||||||
|
@ -79,5 +82,5 @@ private:
|
||||||
|
|
||||||
std::array<QLabel*, Page_Count> m_page_labels;
|
std::array<QLabel*, Page_Count> m_page_labels;
|
||||||
|
|
||||||
QList<QPair<QString, QString>> m_device_list;
|
std::vector<std::pair<std::string, std::string>> m_device_list;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue