mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-12 00:14:39 +01:00
Refactor Wiimote configuration: Move types to a new header and update includes
This commit is contained in:
parent
8c7a277c9e
commit
2af6fe0524
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "util/types.hpp"
|
||||
#include "Utilities/Thread.h"
|
||||
#include "wiimote_types.h"
|
||||
#include "Utilities/mutex.h"
|
||||
#include <hidapi.h>
|
||||
#include <vector>
|
||||
|
|
@ -12,49 +13,6 @@
|
|||
#include <chrono>
|
||||
#include <array>
|
||||
|
||||
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;
|
||||
|
|
|
|||
45
rpcs3/Input/wiimote_types.h
Normal file
45
rpcs3/Input/wiimote_types.h
Normal file
|
|
@ -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;
|
||||
};
|
||||
|
|
@ -2043,6 +2043,7 @@
|
|||
<ClInclude Include="rpcs3qt\trophy_notification_helper.h" />
|
||||
<ClInclude Include="rpcs3qt\user_account.h" />
|
||||
<ClInclude Include="Input\wiimote_handler.h" />
|
||||
<ClInclude Include="Input\wiimote_types.h" />
|
||||
<ClInclude Include="Input\xinput_pad_handler.h" />
|
||||
<ClInclude Include="util\console.h" />
|
||||
<ClInclude Include="\rpcs3qt\*.h" />
|
||||
|
|
|
|||
|
|
@ -1298,6 +1298,9 @@
|
|||
<ClInclude Include="Input\wiimote_handler.h">
|
||||
<Filter>Io</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Input\wiimote_types.h">
|
||||
<Filter>Io</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Input\xinput_pad_handler.h">
|
||||
<Filter>Io\XInput</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
|||
|
|
@ -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<QCheckBox*>( "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<QCheckBox*>( "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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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::wiimote_settings_dialog> ui;
|
||||
std::vector<QComboBox*> m_boxes;
|
||||
|
||||
void update_list();
|
||||
void update_state();
|
||||
void populate_mappings();
|
||||
|
|
|
|||
Loading…
Reference in a new issue