mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
Qt/input: add checkbox for emulated stick values
This commit is contained in:
parent
2f2a03b37b
commit
ad0f12c742
6 changed files with 98 additions and 31 deletions
|
@ -1007,7 +1007,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
|
||||||
});
|
});
|
||||||
connect(pad_configure, &QAction::triggered, [=, this]()
|
connect(pad_configure, &QAction::triggered, [=, this]()
|
||||||
{
|
{
|
||||||
pad_settings_dialog dlg(this, ¤t_game);
|
pad_settings_dialog dlg(m_gui_settings, this, ¤t_game);
|
||||||
|
|
||||||
if (dlg.exec() == QDialog::Accepted && !gameinfo->hasCustomPadConfig)
|
if (dlg.exec() == QDialog::Accepted && !gameinfo->hasCustomPadConfig)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,6 +112,7 @@ namespace gui
|
||||||
const QString notes = "Notes";
|
const QString notes = "Notes";
|
||||||
const QString titles = "Titles";
|
const QString titles = "Titles";
|
||||||
const QString localization = "Localization";
|
const QString localization = "Localization";
|
||||||
|
const QString pad_settings = "PadSettings";
|
||||||
|
|
||||||
const QColor gl_icon_color = QColor(240, 240, 240, 255);
|
const QColor gl_icon_color = QColor(240, 240, 240, 255);
|
||||||
|
|
||||||
|
@ -226,6 +227,8 @@ namespace gui
|
||||||
const gui_save um_active_user = gui_save(users, "active_user", "00000001");
|
const gui_save um_active_user = gui_save(users, "active_user", "00000001");
|
||||||
|
|
||||||
const gui_save loc_language = gui_save(localization, "language", "en");
|
const gui_save loc_language = gui_save(localization, "language", "en");
|
||||||
|
|
||||||
|
const gui_save pads_show_emulated = gui_save(pad_settings, "show_emulated_values", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Class for GUI settings..
|
/** Class for GUI settings..
|
||||||
|
|
|
@ -1530,7 +1530,7 @@ void main_window::CreateConnects()
|
||||||
|
|
||||||
auto open_pad_settings = [this]
|
auto open_pad_settings = [this]
|
||||||
{
|
{
|
||||||
pad_settings_dialog dlg(this);
|
pad_settings_dialog dlg(m_gui_settings, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "pad_led_settings_dialog.h"
|
#include "pad_led_settings_dialog.h"
|
||||||
#include "ui_pad_settings_dialog.h"
|
#include "ui_pad_settings_dialog.h"
|
||||||
#include "tooltips.h"
|
#include "tooltips.h"
|
||||||
|
#include "gui_settings.h"
|
||||||
|
|
||||||
#include "Emu/System.h"
|
#include "Emu/System.h"
|
||||||
#include "Emu/Io/Null/NullPadHandler.h"
|
#include "Emu/Io/Null/NullPadHandler.h"
|
||||||
|
@ -55,8 +56,8 @@ inline bool CreateConfigFile(const QString& dir, const QString& name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pad_settings_dialog::pad_settings_dialog(QWidget *parent, const GameInfo *game)
|
pad_settings_dialog::pad_settings_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget *parent, const GameInfo *game)
|
||||||
: QDialog(parent), ui(new Ui::pad_settings_dialog)
|
: QDialog(parent), ui(new Ui::pad_settings_dialog), m_gui_settings(gui_settings)
|
||||||
{
|
{
|
||||||
pad::set_enabled(false);
|
pad::set_enabled(false);
|
||||||
|
|
||||||
|
@ -204,6 +205,15 @@ pad_settings_dialog::pad_settings_dialog(QWidget *parent, const GameInfo *game)
|
||||||
|
|
||||||
connect(ui->chooseClass, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &pad_settings_dialog::HandleDeviceClassChange);
|
connect(ui->chooseClass, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &pad_settings_dialog::HandleDeviceClassChange);
|
||||||
|
|
||||||
|
ui->chb_show_emulated_values->setChecked(m_gui_settings->GetValue(gui::pads_show_emulated).toBool());
|
||||||
|
|
||||||
|
connect(ui->chb_show_emulated_values, &QCheckBox::clicked, [this](bool checked)
|
||||||
|
{
|
||||||
|
m_gui_settings->SetValue(gui::pads_show_emulated, checked);
|
||||||
|
RepaintPreviewLabel(ui->preview_stick_left, ui->slider_stick_left->value(), ui->slider_stick_left->size().width(), m_lx, m_ly, m_handler_cfg.lpadsquircling, m_handler_cfg.lstickmultiplier / 100.0);
|
||||||
|
RepaintPreviewLabel(ui->preview_stick_right, ui->slider_stick_right->value(), ui->slider_stick_right->size().width(), m_rx, m_ry, m_handler_cfg.rpadsquircling, m_handler_cfg.rstickmultiplier / 100.0);
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize configurable buttons
|
// Initialize configurable buttons
|
||||||
InitButtons();
|
InitButtons();
|
||||||
|
|
||||||
|
@ -624,6 +634,25 @@ void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int deadzone, int desir
|
||||||
const qreal stick_x = std::clamp(outer_circle_radius * x * multiplier / deadzone_max, -outer_circle_radius, outer_circle_radius);
|
const qreal stick_x = std::clamp(outer_circle_radius * x * multiplier / deadzone_max, -outer_circle_radius, outer_circle_radius);
|
||||||
const qreal stick_y = std::clamp(outer_circle_radius * -y * multiplier / deadzone_max, -outer_circle_radius, outer_circle_radius);
|
const qreal stick_y = std::clamp(outer_circle_radius * -y * multiplier / deadzone_max, -outer_circle_radius, outer_circle_radius);
|
||||||
|
|
||||||
|
const bool show_emulated_values = ui->chb_show_emulated_values->isChecked();
|
||||||
|
|
||||||
|
qreal ingame_x;
|
||||||
|
qreal ingame_y;
|
||||||
|
|
||||||
|
// Set up the canvas for our work of art
|
||||||
|
QPixmap pixmap(scaled_width, scaled_width);
|
||||||
|
pixmap.setDevicePixelRatio(device_pixel_ratio);
|
||||||
|
pixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
|
// Configure the painter and set its origin
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
painter.setRenderHint(QPainter::TextAntialiasing, true);
|
||||||
|
painter.translate(origin, origin);
|
||||||
|
painter.setBrush(QBrush(Qt::white));
|
||||||
|
|
||||||
|
if (show_emulated_values)
|
||||||
|
{
|
||||||
u16 real_x = 0;
|
u16 real_x = 0;
|
||||||
u16 real_y = 0;
|
u16 real_y = 0;
|
||||||
|
|
||||||
|
@ -638,26 +667,15 @@ void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int deadzone, int desir
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr qreal real_max = 126;
|
constexpr qreal real_max = 126;
|
||||||
const qreal ingame_x = std::clamp(outer_circle_radius * (static_cast<qreal>(real_x) - real_max) / real_max, -outer_circle_radius, outer_circle_radius);
|
ingame_x = std::clamp(outer_circle_radius * (static_cast<qreal>(real_x) - real_max) / real_max, -outer_circle_radius, outer_circle_radius);
|
||||||
const qreal ingame_y = std::clamp(outer_circle_radius * -(static_cast<qreal>(real_y) - real_max) / real_max, -outer_circle_radius, outer_circle_radius);
|
ingame_y = std::clamp(outer_circle_radius * -(static_cast<qreal>(real_y) - real_max) / real_max, -outer_circle_radius, outer_circle_radius);
|
||||||
|
|
||||||
// Set up the canvas for our work of art
|
|
||||||
QPixmap pixmap(scaled_width, scaled_width);
|
|
||||||
pixmap.setDevicePixelRatio(device_pixel_ratio);
|
|
||||||
pixmap.fill(Qt::transparent);
|
|
||||||
|
|
||||||
// Configure the painter and set its origin
|
|
||||||
QPainter painter(&pixmap);
|
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
|
||||||
painter.setRenderHint(QPainter::TextAntialiasing, true);
|
|
||||||
painter.translate(origin, origin);
|
|
||||||
painter.setBrush(QBrush(Qt::white));
|
|
||||||
|
|
||||||
// Draw a black outer squircle that roughly represents the DS3's max values
|
// Draw a black outer squircle that roughly represents the DS3's max values
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRoundedRect(QRectF(-outer_circle_radius, -outer_circle_radius, outer_circle_diameter, outer_circle_diameter), 5, 5, Qt::SizeMode::RelativeSize);
|
path.addRoundedRect(QRectF(-outer_circle_radius, -outer_circle_radius, outer_circle_diameter, outer_circle_diameter), 5, 5, Qt::SizeMode::RelativeSize);
|
||||||
painter.setPen(QPen(Qt::black, 1.0));
|
painter.setPen(QPen(Qt::black, 1.0));
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a black outer circle that represents the maximum for the deadzone
|
// Draw a black outer circle that represents the maximum for the deadzone
|
||||||
painter.setPen(QPen(Qt::black, 1.0));
|
painter.setPen(QPen(Qt::black, 1.0));
|
||||||
|
@ -669,11 +687,14 @@ void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int deadzone, int desir
|
||||||
|
|
||||||
// Draw a blue dot that represents the current stick orientation
|
// Draw a blue dot that represents the current stick orientation
|
||||||
painter.setPen(QPen(Qt::blue, 2.0));
|
painter.setPen(QPen(Qt::blue, 2.0));
|
||||||
painter.drawEllipse(QRectF(stick_x - 1.0, stick_y - 1.0, 1.0, 1.0));
|
painter.drawEllipse(QRectF(stick_x - 0.5, stick_y - 0.5, 1.0, 1.0));
|
||||||
|
|
||||||
|
if (show_emulated_values)
|
||||||
|
{
|
||||||
// Draw a red dot that represents the current ingame stick orientation
|
// Draw a red dot that represents the current ingame stick orientation
|
||||||
painter.setPen(QPen(Qt::red, 2.0));
|
painter.setPen(QPen(Qt::red, 2.0));
|
||||||
painter.drawEllipse(QRectF(ingame_x - 1.0, ingame_y - 1.0, 1.0, 1.0));
|
painter.drawEllipse(QRectF(ingame_x - 0.5, ingame_y - 0.5, 1.0, 1.0));
|
||||||
|
}
|
||||||
|
|
||||||
l->setPixmap(pixmap);
|
l->setPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "Emu/Io/pad_config.h"
|
#include "Emu/Io/pad_config.h"
|
||||||
#include "Emu/GameInfo.h"
|
#include "Emu/GameInfo.h"
|
||||||
|
|
||||||
|
class gui_settings;
|
||||||
class PadHandlerBase;
|
class PadHandlerBase;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
|
@ -87,7 +88,7 @@ class pad_settings_dialog : public QDialog
|
||||||
const QString Disconnected_suffix = tr(" (disconnected)");
|
const QString Disconnected_suffix = tr(" (disconnected)");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit pad_settings_dialog(QWidget *parent = nullptr, const GameInfo *game = nullptr);
|
explicit pad_settings_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget *parent = nullptr, const GameInfo *game = nullptr);
|
||||||
~pad_settings_dialog();
|
~pad_settings_dialog();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
@ -105,6 +106,7 @@ private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
Ui::pad_settings_dialog *ui;
|
Ui::pad_settings_dialog *ui;
|
||||||
std::string m_title_id;
|
std::string m_title_id;
|
||||||
|
std::shared_ptr<gui_settings> m_gui_settings;
|
||||||
|
|
||||||
// Capabilities
|
// Capabilities
|
||||||
bool m_enable_buttons{ false };
|
bool m_enable_buttons{ false };
|
||||||
|
|
|
@ -736,13 +736,13 @@
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>9</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>9</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="chb_vibration_large">
|
<widget class="QCheckBox" name="chb_vibration_large">
|
||||||
|
@ -774,6 +774,47 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_stick_preview">
|
||||||
|
<property name="title">
|
||||||
|
<string>Stick Preview</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="gb_stick_preview_layout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chb_show_emulated_values">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show Emulated Values</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="pad_page_spacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="mouse_page">
|
<widget class="QWidget" name="mouse_page">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue