diff --git a/rpcs3/Emu/Io/pad_config.h b/rpcs3/Emu/Io/pad_config.h index 614b394237..bdde9fb219 100644 --- a/rpcs3/Emu/Io/pad_config.h +++ b/rpcs3/Emu/Io/pad_config.h @@ -1,6 +1,6 @@ #pragma once -#include "pad_config_types.h" +#include "pad_types.h" #include "Utilities/Config.h" @@ -97,7 +97,7 @@ struct cfg_pad final : cfg::node cfg::uint<0, 100> analog_lerp_factor{ this, "Analog Button Lerp Factor", 100 }; cfg::uint<0, 100> trigger_lerp_factor{ this, "Trigger Lerp Factor", 100 }; - cfg::uint<0, 5> device_class_type{ this, "Device Class Type", 0 }; + cfg::uint device_class_type{ this, "Device Class Type", 0 }; cfg::uint<0, 65535> vendor_id{ this, "Vendor ID", 0 }; cfg::uint<0, 65535> product_id{ this, "Product ID", 0 }; }; diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.cpp b/rpcs3/rpcs3qt/pad_settings_dialog.cpp index 88545214b1..9aa5afe430 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/pad_settings_dialog.cpp @@ -174,14 +174,18 @@ pad_settings_dialog::pad_settings_dialog(std::shared_ptr gui_setti // Refresh Button connect(ui->b_refresh, &QPushButton::clicked, this, &pad_settings_dialog::RefreshHandlers); - ui->chooseClass->addItem(tr("Standard (Pad)")); // CELL_PAD_PCLASS_TYPE_STANDARD = 0x00, - ui->chooseClass->addItem(tr("Guitar")); // CELL_PAD_PCLASS_TYPE_GUITAR = 0x01, - ui->chooseClass->addItem(tr("Drum")); // CELL_PAD_PCLASS_TYPE_DRUM = 0x02, - ui->chooseClass->addItem(tr("DJ")); // CELL_PAD_PCLASS_TYPE_DJ = 0x03, - ui->chooseClass->addItem(tr("Dance Mat")); // CELL_PAD_PCLASS_TYPE_DANCEMAT = 0x04, - ui->chooseClass->addItem(tr("Navigation")); // CELL_PAD_PCLASS_TYPE_NAVIGATION = 0x05, + ui->chooseClass->addItem(tr("Standard (Pad)"), u32{CELL_PAD_PCLASS_TYPE_STANDARD}); + ui->chooseClass->addItem(tr("Guitar"), u32{CELL_PAD_PCLASS_TYPE_GUITAR}); + ui->chooseClass->addItem(tr("Drum"), u32{CELL_PAD_PCLASS_TYPE_DRUM}); + ui->chooseClass->addItem(tr("DJ"), u32{CELL_PAD_PCLASS_TYPE_DJ}); + ui->chooseClass->addItem(tr("Dance Mat"), u32{CELL_PAD_PCLASS_TYPE_DANCEMAT}); + ui->chooseClass->addItem(tr("Navigation"), u32{CELL_PAD_PCLASS_TYPE_NAVIGATION}); - connect(ui->chooseClass, QOverload::of(&QComboBox::currentIndexChanged), this, &pad_settings_dialog::HandleDeviceClassChange); + connect(ui->chooseClass, QOverload::of(&QComboBox::currentIndexChanged), this, [this](int index) + { + if (index < 0) return; + HandleDeviceClassChange(ui->chooseClass->currentData().toUInt()); + }); ui->chb_show_emulated_values->setChecked(m_gui_settings->GetValue(gui::pads_show_emulated).toBool()); @@ -1075,10 +1079,11 @@ void pad_settings_dialog::UpdateLabels(bool is_reset) const cfg_pad& cfg = GetPlayerConfig(); // Update device class - ui->chooseClass->setCurrentIndex(cfg.device_class_type); + const int index = ui->chooseClass->findData(cfg.device_class_type.get()); + ui->chooseClass->setCurrentIndex(index); // Trigger the change manually in case that the class dropdown didn't fire an event - HandleDeviceClassChange(ui->chooseClass->currentIndex()); + HandleDeviceClassChange(cfg.device_class_type); const auto products = input::get_products_by_class(cfg.device_class_type); @@ -1608,16 +1613,11 @@ void pad_settings_dialog::ChangeDevice(int index) } } -void pad_settings_dialog::HandleDeviceClassChange(int index) const +void pad_settings_dialog::HandleDeviceClassChange(u32 class_id) const { - if (index < 0) - { - return; - } - ui->chooseProduct->clear(); - for (const input::product_info& product : input::get_products_by_class(index)) + for (const input::product_info& product : input::get_products_by_class(class_id)) { switch (product.type) { @@ -1833,7 +1833,7 @@ void pad_settings_dialog::ApplyCurrentPlayerConfig(int new_player_id) cfg.r_stick_lerp_factor.set(ui->right_stick_lerp->value() * 100); } - cfg.device_class_type.set(ui->chooseClass->currentIndex()); + cfg.device_class_type.set(ui->chooseClass->currentData().toUInt()); const auto info = input::get_product_info(static_cast(ui->chooseProduct->currentData().toInt())); diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.h b/rpcs3/rpcs3qt/pad_settings_dialog.h index 5d92b83285..0be65555a1 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.h +++ b/rpcs3/rpcs3qt/pad_settings_dialog.h @@ -99,7 +99,7 @@ private Q_SLOTS: void ChangeHandler(); void ChangeProfile(const QString& profile); void ChangeDevice(int index); - void HandleDeviceClassChange(int index) const; + void HandleDeviceClassChange(u32 class_id) const; void AddProfile(); /** Update the current player config with the GUI values. */ void ApplyCurrentPlayerConfig(int new_player_id);