mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 17:11:23 +00:00
Qt/input: add checkbox for emulated stick values
This commit is contained in:
parent
2f2a03b37b
commit
ad0f12c742
@ -1007,7 +1007,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
|
||||
});
|
||||
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)
|
||||
{
|
||||
|
@ -112,6 +112,7 @@ namespace gui
|
||||
const QString notes = "Notes";
|
||||
const QString titles = "Titles";
|
||||
const QString localization = "Localization";
|
||||
const QString pad_settings = "PadSettings";
|
||||
|
||||
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 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..
|
||||
|
@ -1530,7 +1530,7 @@ void main_window::CreateConnects()
|
||||
|
||||
auto open_pad_settings = [this]
|
||||
{
|
||||
pad_settings_dialog dlg(this);
|
||||
pad_settings_dialog dlg(m_gui_settings, this);
|
||||
dlg.exec();
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "pad_led_settings_dialog.h"
|
||||
#include "ui_pad_settings_dialog.h"
|
||||
#include "tooltips.h"
|
||||
#include "gui_settings.h"
|
||||
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/Io/Null/NullPadHandler.h"
|
||||
@ -55,8 +56,8 @@ inline bool CreateConfigFile(const QString& dir, const QString& name)
|
||||
return true;
|
||||
}
|
||||
|
||||
pad_settings_dialog::pad_settings_dialog(QWidget *parent, const GameInfo *game)
|
||||
: QDialog(parent), ui(new Ui::pad_settings_dialog)
|
||||
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), m_gui_settings(gui_settings)
|
||||
{
|
||||
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);
|
||||
|
||||
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
|
||||
InitButtons();
|
||||
|
||||
@ -624,22 +634,10 @@ 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_y = std::clamp(outer_circle_radius * -y * multiplier / deadzone_max, -outer_circle_radius, outer_circle_radius);
|
||||
|
||||
u16 real_x = 0;
|
||||
u16 real_y = 0;
|
||||
const bool show_emulated_values = ui->chb_show_emulated_values->isChecked();
|
||||
|
||||
if (m_handler)
|
||||
{
|
||||
const int m_in = multiplier * 100.0;
|
||||
const u16 normal_x = m_handler->NormalizeStickInput(static_cast<u16>(std::abs(x)), deadzone, m_in, true);
|
||||
const u16 normal_y = m_handler->NormalizeStickInput(static_cast<u16>(std::abs(y)), deadzone, m_in, true);
|
||||
const s32 x_in = x >= 0 ? normal_x : 0 - normal_x;
|
||||
const s32 y_in = y >= 0 ? normal_y : 0 - normal_y;
|
||||
m_handler->convert_stick_values(real_x, real_y, x_in, y_in, deadzone, squircle);
|
||||
}
|
||||
|
||||
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);
|
||||
const qreal ingame_y = std::clamp(outer_circle_radius * -(static_cast<qreal>(real_y) - real_max) / real_max, -outer_circle_radius, outer_circle_radius);
|
||||
qreal ingame_x;
|
||||
qreal ingame_y;
|
||||
|
||||
// Set up the canvas for our work of art
|
||||
QPixmap pixmap(scaled_width, scaled_width);
|
||||
@ -653,11 +651,31 @@ void pad_settings_dialog::RepaintPreviewLabel(QLabel* l, int deadzone, int desir
|
||||
painter.translate(origin, origin);
|
||||
painter.setBrush(QBrush(Qt::white));
|
||||
|
||||
// Draw a black outer squircle that roughly represents the DS3's max values
|
||||
QPainterPath path;
|
||||
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.drawPath(path);
|
||||
if (show_emulated_values)
|
||||
{
|
||||
u16 real_x = 0;
|
||||
u16 real_y = 0;
|
||||
|
||||
if (m_handler)
|
||||
{
|
||||
const int m_in = multiplier * 100.0;
|
||||
const u16 normal_x = m_handler->NormalizeStickInput(static_cast<u16>(std::abs(x)), deadzone, m_in, true);
|
||||
const u16 normal_y = m_handler->NormalizeStickInput(static_cast<u16>(std::abs(y)), deadzone, m_in, true);
|
||||
const s32 x_in = x >= 0 ? normal_x : 0 - normal_x;
|
||||
const s32 y_in = y >= 0 ? normal_y : 0 - normal_y;
|
||||
m_handler->convert_stick_values(real_x, real_y, x_in, y_in, deadzone, squircle);
|
||||
}
|
||||
|
||||
constexpr qreal real_max = 126;
|
||||
ingame_x = std::clamp(outer_circle_radius * (static_cast<qreal>(real_x) - 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);
|
||||
|
||||
// Draw a black outer squircle that roughly represents the DS3's max values
|
||||
QPainterPath path;
|
||||
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.drawPath(path);
|
||||
}
|
||||
|
||||
// Draw a black outer circle that represents the maximum for the deadzone
|
||||
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
|
||||
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));
|
||||
|
||||
// Draw a red dot that represents the current ingame stick orientation
|
||||
painter.setPen(QPen(Qt::red, 2.0));
|
||||
painter.drawEllipse(QRectF(ingame_x - 1.0, ingame_y - 1.0, 1.0, 1.0));
|
||||
if (show_emulated_values)
|
||||
{
|
||||
// Draw a red dot that represents the current ingame stick orientation
|
||||
painter.setPen(QPen(Qt::red, 2.0));
|
||||
painter.drawEllipse(QRectF(ingame_x - 0.5, ingame_y - 0.5, 1.0, 1.0));
|
||||
}
|
||||
|
||||
l->setPixmap(pixmap);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Emu/Io/pad_config.h"
|
||||
#include "Emu/GameInfo.h"
|
||||
|
||||
class gui_settings;
|
||||
class PadHandlerBase;
|
||||
|
||||
namespace Ui
|
||||
@ -87,7 +88,7 @@ class pad_settings_dialog : public QDialog
|
||||
const QString Disconnected_suffix = tr(" (disconnected)");
|
||||
|
||||
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();
|
||||
|
||||
public Q_SLOTS:
|
||||
@ -105,6 +106,7 @@ private Q_SLOTS:
|
||||
private:
|
||||
Ui::pad_settings_dialog *ui;
|
||||
std::string m_title_id;
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
|
||||
// Capabilities
|
||||
bool m_enable_buttons{ false };
|
||||
|
@ -736,13 +736,13 @@
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chb_vibration_large">
|
||||
@ -774,6 +774,47 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<widget class="QWidget" name="mouse_page">
|
||||
|
Loading…
Reference in New Issue
Block a user