diff --git a/rpcs3/Emu/Io/wiimote_config.h b/rpcs3/Emu/Io/wiimote_config.h index 53737fe93f..dcf75ae94c 100644 --- a/rpcs3/Emu/Io/wiimote_config.h +++ b/rpcs3/Emu/Io/wiimote_config.h @@ -1,7 +1,7 @@ #pragma once #include "Utilities/Config.h" -#include "Input/wiimote_handler.h" +#include "Input/wiimote_types.h" struct cfg_wiimote : cfg::node { diff --git a/rpcs3/Input/wiimote_handler.h b/rpcs3/Input/wiimote_handler.h index d9d415aa9d..f8e4e65f23 100644 --- a/rpcs3/Input/wiimote_handler.h +++ b/rpcs3/Input/wiimote_handler.h @@ -2,6 +2,7 @@ #include "util/types.hpp" #include "Utilities/Thread.h" +#include "wiimote_types.h" #include "Utilities/mutex.h" #include #include @@ -12,49 +13,6 @@ #include #include -static constexpr usz MAX_WIIMOTES = 4; -static constexpr usz MAX_WIIMOTE_IR_POINTS = 4; - -struct wiimote_ir_point -{ - u16 x = 1023; - u16 y = 1023; - u8 size = 0; -}; - -enum class wiimote_button : u16 -{ - None = 0, - Left = 0x0001, - Right = 0x0002, - Down = 0x0004, - Up = 0x0008, - Plus = 0x0010, - Two = 0x0100, - One = 0x0200, - B = 0x0400, - A = 0x0800, - Minus = 0x1000, - Home = 0x8000 -}; - -struct wiimote_guncon_mapping -{ - wiimote_button trigger = wiimote_button::B; - wiimote_button a1 = wiimote_button::A; - wiimote_button a2 = wiimote_button::Minus; - wiimote_button a3 = wiimote_button::Left; - wiimote_button b1 = wiimote_button::One; - wiimote_button b2 = wiimote_button::Two; - wiimote_button b3 = wiimote_button::Home; - wiimote_button c1 = wiimote_button::Plus; - wiimote_button c2 = wiimote_button::Right; - - // Secondary mappings (optional, e.g. D-Pad acting as buttons) - wiimote_button b1_alt = wiimote_button::Up; - wiimote_button b2_alt = wiimote_button::Down; -}; - struct wiimote_state { u16 buttons = 0; diff --git a/rpcs3/Input/wiimote_types.h b/rpcs3/Input/wiimote_types.h new file mode 100644 index 0000000000..b59d03b671 --- /dev/null +++ b/rpcs3/Input/wiimote_types.h @@ -0,0 +1,45 @@ +#pragma once + +#include "util/types.hpp" + +static constexpr usz MAX_WIIMOTES = 4; +static constexpr usz MAX_WIIMOTE_IR_POINTS = 4; + +struct wiimote_ir_point +{ + u16 x = 1023; + u16 y = 1023; + u8 size = 0; +}; + +enum class wiimote_button : u16 +{ + None = 0, + Left = 0x0001, + Right = 0x0002, + Down = 0x0004, + Up = 0x0008, + Plus = 0x0010, + Two = 0x0100, + One = 0x0200, + B = 0x0400, + A = 0x0800, + Minus = 0x1000, + Home = 0x8000 +}; + +struct wiimote_guncon_mapping +{ + wiimote_button trigger = wiimote_button::B; + wiimote_button a1 = wiimote_button::A; + wiimote_button a2 = wiimote_button::Minus; + wiimote_button a3 = wiimote_button::Left; + wiimote_button b1 = wiimote_button::One; + wiimote_button b2 = wiimote_button::Two; + wiimote_button b3 = wiimote_button::Home; + wiimote_button c1 = wiimote_button::Plus; + wiimote_button c2 = wiimote_button::Right; + + wiimote_button b1_alt = wiimote_button::Up; + wiimote_button b2_alt = wiimote_button::Down; +}; diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 9d7baffa3b..31523a04d6 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -2043,6 +2043,7 @@ + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index c908eff52b..d6cc0d4794 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -1298,6 +1298,9 @@ Io + + Io + Io\XInput diff --git a/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp b/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp index f354fc0150..09df8df3d8 100644 --- a/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/wiimote_settings_dialog.cpp @@ -19,15 +19,12 @@ wiimote_settings_dialog::wiimote_settings_dialog(QWidget* parent) ui->cb_b1, ui->cb_b2, ui->cb_b3, ui->cb_a3, ui->cb_c2 }; - if (auto* use_guncon = findChild( "useForGunCon")) + ui->useForGunCon->setChecked(get_wiimote_config().use_for_guncon.get()); + connect(ui->useForGunCon, &QCheckBox::toggled, this, [](bool checked) { - use_guncon->setChecked(get_wiimote_config().use_for_guncon.get()); - connect(use_guncon, &QCheckBox::toggled, this, [](bool checked) - { - get_wiimote_config().use_for_guncon.set(checked); - get_wiimote_config().save(); - }); - } + get_wiimote_config().use_for_guncon.set(checked); + get_wiimote_config().save(); + }); update_list(); connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &wiimote_settings_dialog::restore_defaults); @@ -41,8 +38,6 @@ wiimote_settings_dialog::wiimote_settings_dialog(QWidget* parent) populate_mappings(); } -wiimote_settings_dialog::~wiimote_settings_dialog() = default; - void wiimote_settings_dialog::populate_mappings() { auto* wm = wiimote_handler::get_instance(); @@ -102,8 +97,7 @@ void wiimote_settings_dialog::restore_defaults() wm->set_mapping(default_map); get_wiimote_config().use_for_guncon.set(true); - if (auto* use_guncon = findChild( "useForGunCon")) - use_guncon->setChecked(true); + ui->useForGunCon->setChecked(true); // Update UI for (auto* box : m_boxes) box->blockSignals(true); @@ -188,7 +182,7 @@ void wiimote_settings_dialog::update_state() const int w = ui->irVisual->width(); const int h = ui->irVisual->height(); QPixmap pixmap(w, h); - pixmap.fill(Qt::black); + pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing); diff --git a/rpcs3/rpcs3qt/wiimote_settings_dialog.h b/rpcs3/rpcs3qt/wiimote_settings_dialog.h index 1cd7c0df82..1d8ee7c6a1 100644 --- a/rpcs3/rpcs3qt/wiimote_settings_dialog.h +++ b/rpcs3/rpcs3qt/wiimote_settings_dialog.h @@ -8,11 +8,12 @@ class wiimote_settings_dialog : public QDialog Q_OBJECT public: explicit wiimote_settings_dialog(QWidget* parent = nullptr); - ~wiimote_settings_dialog(); + ~wiimote_settings_dialog() = default; private: std::unique_ptr ui; std::vector m_boxes; + void update_list(); void update_state(); void populate_mappings();