mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Random stuff (#9589)
* minor coding style adjustment * Qt: simplify osk dialog buttons * replace std::find_if with convenience functions * RSX: use sv in swizzle comparison idk, I'll remove this if it was intentional. * overlays/osk: rename enter to return This one confused me and make me look for a bug that caused the "enter" key to be disabled, while it was actually the return key (obviously xD).
This commit is contained in:
parent
838cbe1840
commit
52deff06ba
@ -1717,7 +1717,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
|
||||
{
|
||||
if (std::find(blist.begin(), blist.end(), to_add) == blist.end())
|
||||
{
|
||||
if(auto it = std::find(blist.begin(), blist.end(), ""); it != blist.end())
|
||||
if (auto it = std::find(blist.begin(), blist.end(), ""); it != blist.end())
|
||||
*it = to_add;
|
||||
else
|
||||
blist.push_back(to_add);
|
||||
|
@ -95,10 +95,10 @@ std::string CgBinaryDisasm::GetCondDisAsm()
|
||||
swizzle += f[src0.cond_swizzle_z];
|
||||
swizzle += f[src0.cond_swizzle_w];
|
||||
|
||||
if (swizzle == ".xxxx") swizzle = ".x";
|
||||
else if (swizzle == ".yyyy") swizzle = ".y";
|
||||
else if (swizzle == ".zzzz") swizzle = ".z";
|
||||
else if (swizzle == ".wwww") swizzle = ".w";
|
||||
if (swizzle == ".xxxx"sv) swizzle = ".x";
|
||||
else if (swizzle == ".yyyy"sv) swizzle = ".y";
|
||||
else if (swizzle == ".zzzz"sv) swizzle = ".z";
|
||||
else if (swizzle == ".wwww"sv) swizzle = ".w";
|
||||
|
||||
if (swizzle == ".xyzw"sv)
|
||||
{
|
||||
@ -129,7 +129,6 @@ std::string CgBinaryDisasm::GetCondDisAsm()
|
||||
{
|
||||
cond = "FL";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
cond = "TR";
|
||||
@ -212,10 +211,10 @@ template<typename T> std::string CgBinaryDisasm::GetSrcDisAsm(T src)
|
||||
swizzle += f[src.swizzle_z];
|
||||
swizzle += f[src.swizzle_w];
|
||||
|
||||
if (swizzle == ".xxxx") swizzle = ".x";
|
||||
else if (swizzle == ".yyyy") swizzle = ".y";
|
||||
else if (swizzle == ".zzzz") swizzle = ".z";
|
||||
else if (swizzle == ".wwww") swizzle = ".w";
|
||||
if (swizzle == ".xxxx"sv) swizzle = ".x";
|
||||
else if (swizzle == ".yyyy"sv) swizzle = ".y";
|
||||
else if (swizzle == ".zzzz"sv) swizzle = ".z";
|
||||
else if (swizzle == ".wwww"sv) swizzle = ".w";
|
||||
|
||||
if (swizzle != ".xyzw"sv)
|
||||
{
|
||||
@ -404,9 +403,8 @@ void CgBinaryDisasm::TaskFP()
|
||||
m_else_offsets.push_back(src1.else_offset << 2);
|
||||
m_end_offsets.push_back(src2.end_offset << 2);
|
||||
AddCodeAsm("($cond)");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RSX_FP_OPCODE_LOOP:
|
||||
{
|
||||
if (!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt)
|
||||
@ -418,9 +416,8 @@ void CgBinaryDisasm::TaskFP()
|
||||
m_loop_end_offsets.push_back(src2.end_offset << 2);
|
||||
AddCodeAsm(fmt::format("{ %u, %u, %u }", src1.end_counter, src1.init_counter, src1.increment));
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RSX_FP_OPCODE_REP:
|
||||
{
|
||||
if (!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt)
|
||||
@ -432,9 +429,8 @@ void CgBinaryDisasm::TaskFP()
|
||||
m_end_offsets.push_back(src2.end_offset << 2);
|
||||
m_arb_shader += "# RSX_FP_OPCODE_REP_2\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case RSX_FP_OPCODE_RET: AddCodeAsm("$cond"); break;
|
||||
|
||||
default:
|
||||
|
@ -39,14 +39,10 @@ namespace rsx
|
||||
if (m_panels.size() < 7)
|
||||
{
|
||||
// Don't add this panel if there already exists one with the same panel mode
|
||||
for (const auto& existing : m_panels)
|
||||
if (std::none_of(m_panels.begin(), m_panels.end(), [&panel](const osk_panel& existing) { return existing.osk_panel_mode == panel.osk_panel_mode; }))
|
||||
{
|
||||
if (existing.osk_panel_mode == panel.osk_panel_mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_panels.push_back(panel);
|
||||
}
|
||||
m_panels.push_back(panel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ namespace rsx
|
||||
{
|
||||
osk_panel_mode = panel_mode;
|
||||
|
||||
// TODO: Use proper translations for Space/Backspace/Enter etc. and make sure they fit in the grid.
|
||||
// TODO: Use proper translations for Space/Backspace/Return etc. and make sure they fit in the grid.
|
||||
switch (panel_mode)
|
||||
{
|
||||
case CELL_OSKDIALOG_PANELMODE_DEFAULT:
|
||||
@ -46,7 +46,7 @@ namespace rsx
|
||||
{
|
||||
space = U"Space";
|
||||
backspace = U"Backspace";
|
||||
enter = U"Enter";
|
||||
enter = U"Return";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace rsx
|
||||
protected:
|
||||
std::u32string space;
|
||||
std::u32string backspace;
|
||||
std::u32string enter;
|
||||
std::u32string enter; // Return key. Named 'enter' because 'return' is a reserved statement in cpp.
|
||||
};
|
||||
|
||||
struct osk_panel_latin : public osk_panel
|
||||
|
@ -656,12 +656,11 @@ int evdev_joystick_handler::add_device(const std::string& device, const std::sha
|
||||
name == device)
|
||||
{
|
||||
// It's a joystick. Now let's make sure we don't already have this one.
|
||||
auto it = std::find_if(bindings.begin(), bindings.end(), [&path](std::pair<std::shared_ptr<PadDevice>, std::shared_ptr<Pad>> binding)
|
||||
if (std::any_of(bindings.begin(), bindings.end(), [&path](std::pair<std::shared_ptr<PadDevice>, std::shared_ptr<Pad>> binding)
|
||||
{
|
||||
auto device = std::static_pointer_cast<EvdevDevice>(binding.first);
|
||||
const auto device = std::static_pointer_cast<EvdevDevice>(binding.first);
|
||||
return device && path == device->path;
|
||||
});
|
||||
if (it != bindings.end())
|
||||
}))
|
||||
{
|
||||
libevdev_free(dev);
|
||||
close(fd);
|
||||
@ -1017,7 +1016,7 @@ bool evdev_joystick_handler::check_button(const EvdevButton& b, const u32 code)
|
||||
|
||||
bool evdev_joystick_handler::check_buttons(const std::vector<EvdevButton>& b, const u32 code)
|
||||
{
|
||||
return std::find_if(b.begin(), b.end(), [this, code](const EvdevButton& b) { return check_button(b, code); }) != b.end();
|
||||
return std::any_of(b.begin(), b.end(), [this, code](const EvdevButton& b) { return check_button(b, code); });
|
||||
};
|
||||
|
||||
bool evdev_joystick_handler::get_is_left_trigger(u64 keyCode)
|
||||
|
@ -2,12 +2,12 @@
|
||||
#include "custom_dialog.h"
|
||||
#include "Emu/Cell/Modules/cellMsgDialog.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QTextEdit>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QPushButton>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
constexpr auto qstr = QString::fromStdString;
|
||||
@ -47,17 +47,10 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
|
||||
|
||||
// Text Input Counter
|
||||
const QString text = QString::fromStdU16String(std::u16string(init_text));
|
||||
QLabel* inputCount = new QLabel(QString("%1/%2").arg(text.length()).arg(charlimit));
|
||||
|
||||
// Ok Button
|
||||
QPushButton* button_ok = new QPushButton(tr("OK"), m_dialog);
|
||||
QLabel* input_count_label = new QLabel(QString("%1/%2").arg(text.length()).arg(charlimit));
|
||||
|
||||
// Button Layout
|
||||
QHBoxLayout* buttonsLayout = new QHBoxLayout;
|
||||
buttonsLayout->setAlignment(Qt::AlignCenter);
|
||||
buttonsLayout->addStretch();
|
||||
buttonsLayout->addWidget(button_ok);
|
||||
buttonsLayout->addStretch();
|
||||
QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
|
||||
// Input Layout
|
||||
QHBoxLayout* inputLayout = new QHBoxLayout;
|
||||
@ -79,7 +72,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
|
||||
|
||||
connect(input, &QLineEdit::textChanged, [=, this](const QString& text)
|
||||
{
|
||||
inputCount->setText(QString("%1/%2").arg(text.length()).arg(charlimit));
|
||||
input_count_label->setText(QString("%1/%2").arg(text.length()).arg(charlimit));
|
||||
SetOskText(text);
|
||||
on_osk_input_entered();
|
||||
});
|
||||
@ -143,7 +136,7 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
|
||||
|
||||
m_text_old = text;
|
||||
|
||||
inputCount->setText(QString("%1/%2").arg(text.length()).arg(charlimit));
|
||||
input_count_label->setText(QString("%1/%2").arg(text.length()).arg(charlimit));
|
||||
SetOskText(text);
|
||||
on_osk_input_entered();
|
||||
});
|
||||
@ -151,17 +144,17 @@ void osk_dialog_frame::Create(const std::string& title, const std::u16string& me
|
||||
inputLayout->addWidget(input);
|
||||
}
|
||||
|
||||
inputLayout->addWidget(inputCount);
|
||||
inputLayout->addWidget(input_count_label);
|
||||
|
||||
QFormLayout* layout = new QFormLayout(m_dialog);
|
||||
layout->setFormAlignment(Qt::AlignHCenter);
|
||||
layout->addRow(message_label);
|
||||
layout->addRow(inputLayout);
|
||||
layout->addRow(buttonsLayout);
|
||||
layout->addWidget(button_box);
|
||||
m_dialog->setLayout(layout);
|
||||
|
||||
// Events
|
||||
connect(button_ok, &QAbstractButton::clicked, m_dialog, &QDialog::accept);
|
||||
connect(button_box, &QDialogButtonBox::accepted, m_dialog, &QDialog::accept);
|
||||
|
||||
connect(m_dialog, &QDialog::accepted, [this]()
|
||||
{
|
||||
|
@ -258,51 +258,51 @@ pad_settings_dialog::~pad_settings_dialog()
|
||||
|
||||
void pad_settings_dialog::InitButtons()
|
||||
{
|
||||
m_padButtons = new QButtonGroup(this);
|
||||
m_pad_buttons = new QButtonGroup(this);
|
||||
m_palette = ui->b_left->palette(); // save normal palette
|
||||
|
||||
auto insertButton = [this](int id, QPushButton* button)
|
||||
const auto insert_button = [this](int id, QPushButton* button)
|
||||
{
|
||||
m_padButtons->addButton(button, id);
|
||||
m_pad_buttons->addButton(button, id);
|
||||
button->installEventFilter(this);
|
||||
};
|
||||
|
||||
insertButton(button_ids::id_pad_lstick_left, ui->b_lstick_left);
|
||||
insertButton(button_ids::id_pad_lstick_down, ui->b_lstick_down);
|
||||
insertButton(button_ids::id_pad_lstick_right, ui->b_lstick_right);
|
||||
insertButton(button_ids::id_pad_lstick_up, ui->b_lstick_up);
|
||||
insert_button(button_ids::id_pad_lstick_left, ui->b_lstick_left);
|
||||
insert_button(button_ids::id_pad_lstick_down, ui->b_lstick_down);
|
||||
insert_button(button_ids::id_pad_lstick_right, ui->b_lstick_right);
|
||||
insert_button(button_ids::id_pad_lstick_up, ui->b_lstick_up);
|
||||
|
||||
insertButton(button_ids::id_pad_left, ui->b_left);
|
||||
insertButton(button_ids::id_pad_down, ui->b_down);
|
||||
insertButton(button_ids::id_pad_right, ui->b_right);
|
||||
insertButton(button_ids::id_pad_up, ui->b_up);
|
||||
insert_button(button_ids::id_pad_left, ui->b_left);
|
||||
insert_button(button_ids::id_pad_down, ui->b_down);
|
||||
insert_button(button_ids::id_pad_right, ui->b_right);
|
||||
insert_button(button_ids::id_pad_up, ui->b_up);
|
||||
|
||||
insertButton(button_ids::id_pad_l1, ui->b_shift_l1);
|
||||
insertButton(button_ids::id_pad_l2, ui->b_shift_l2);
|
||||
insertButton(button_ids::id_pad_l3, ui->b_shift_l3);
|
||||
insert_button(button_ids::id_pad_l1, ui->b_shift_l1);
|
||||
insert_button(button_ids::id_pad_l2, ui->b_shift_l2);
|
||||
insert_button(button_ids::id_pad_l3, ui->b_shift_l3);
|
||||
|
||||
insertButton(button_ids::id_pad_start, ui->b_start);
|
||||
insertButton(button_ids::id_pad_select, ui->b_select);
|
||||
insertButton(button_ids::id_pad_ps, ui->b_ps);
|
||||
insert_button(button_ids::id_pad_start, ui->b_start);
|
||||
insert_button(button_ids::id_pad_select, ui->b_select);
|
||||
insert_button(button_ids::id_pad_ps, ui->b_ps);
|
||||
|
||||
insertButton(button_ids::id_pad_r1, ui->b_shift_r1);
|
||||
insertButton(button_ids::id_pad_r2, ui->b_shift_r2);
|
||||
insertButton(button_ids::id_pad_r3, ui->b_shift_r3);
|
||||
insert_button(button_ids::id_pad_r1, ui->b_shift_r1);
|
||||
insert_button(button_ids::id_pad_r2, ui->b_shift_r2);
|
||||
insert_button(button_ids::id_pad_r3, ui->b_shift_r3);
|
||||
|
||||
insertButton(button_ids::id_pad_square, ui->b_square);
|
||||
insertButton(button_ids::id_pad_cross, ui->b_cross);
|
||||
insertButton(button_ids::id_pad_circle, ui->b_circle);
|
||||
insertButton(button_ids::id_pad_triangle, ui->b_triangle);
|
||||
insert_button(button_ids::id_pad_square, ui->b_square);
|
||||
insert_button(button_ids::id_pad_cross, ui->b_cross);
|
||||
insert_button(button_ids::id_pad_circle, ui->b_circle);
|
||||
insert_button(button_ids::id_pad_triangle, ui->b_triangle);
|
||||
|
||||
insertButton(button_ids::id_pad_rstick_left, ui->b_rstick_left);
|
||||
insertButton(button_ids::id_pad_rstick_down, ui->b_rstick_down);
|
||||
insertButton(button_ids::id_pad_rstick_right, ui->b_rstick_right);
|
||||
insertButton(button_ids::id_pad_rstick_up, ui->b_rstick_up);
|
||||
insert_button(button_ids::id_pad_rstick_left, ui->b_rstick_left);
|
||||
insert_button(button_ids::id_pad_rstick_down, ui->b_rstick_down);
|
||||
insert_button(button_ids::id_pad_rstick_right, ui->b_rstick_right);
|
||||
insert_button(button_ids::id_pad_rstick_up, ui->b_rstick_up);
|
||||
|
||||
m_padButtons->addButton(ui->b_refresh, button_ids::id_refresh);
|
||||
m_padButtons->addButton(ui->b_addProfile, button_ids::id_add_profile);
|
||||
m_pad_buttons->addButton(ui->b_refresh, button_ids::id_refresh);
|
||||
m_pad_buttons->addButton(ui->b_addProfile, button_ids::id_add_profile);
|
||||
|
||||
connect(m_padButtons, &QButtonGroup::idClicked, this, &pad_settings_dialog::OnPadButtonClicked);
|
||||
connect(m_pad_buttons, &QButtonGroup::idClicked, this, &pad_settings_dialog::OnPadButtonClicked);
|
||||
|
||||
connect(&m_timer, &QTimer::timeout, [this]()
|
||||
{
|
||||
@ -311,7 +311,7 @@ void pad_settings_dialog::InitButtons()
|
||||
ReactivateButtons();
|
||||
return;
|
||||
}
|
||||
m_padButtons->button(m_button_id)->setText(tr("[ Waiting %1 ]").arg(m_seconds));
|
||||
m_pad_buttons->button(m_button_id)->setText(tr("[ Waiting %1 ]").arg(m_seconds));
|
||||
});
|
||||
|
||||
connect(ui->chb_vibration_large, &QCheckBox::clicked, [this](bool checked)
|
||||
@ -597,17 +597,17 @@ void pad_settings_dialog::ReactivateButtons()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_padButtons->button(m_button_id))
|
||||
if (m_pad_buttons->button(m_button_id))
|
||||
{
|
||||
m_padButtons->button(m_button_id)->setPalette(m_palette);
|
||||
m_padButtons->button(m_button_id)->releaseMouse();
|
||||
m_pad_buttons->button(m_button_id)->setPalette(m_palette);
|
||||
m_pad_buttons->button(m_button_id)->releaseMouse();
|
||||
}
|
||||
|
||||
m_button_id = button_ids::id_pad_begin;
|
||||
UpdateLabels();
|
||||
SwitchButtons(true);
|
||||
|
||||
for (auto but : m_padButtons->buttons())
|
||||
for (auto but : m_pad_buttons->buttons())
|
||||
{
|
||||
but->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
@ -1029,7 +1029,7 @@ void pad_settings_dialog::UpdateLabels(bool is_reset)
|
||||
}
|
||||
|
||||
// The button has to contain at least one character, because it would be square'ish otherwise
|
||||
m_padButtons->button(entry.first)->setText(entry.second.text.isEmpty() ? QStringLiteral("-") : entry.second.text);
|
||||
m_pad_buttons->button(entry.first)->setText(entry.second.text.isEmpty() ? QStringLiteral("-") : entry.second.text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1050,7 +1050,7 @@ void pad_settings_dialog::SwitchButtons(bool is_enabled)
|
||||
|
||||
for (int i = button_ids::id_pad_begin + 1; i < button_ids::id_pad_end; i++)
|
||||
{
|
||||
m_padButtons->button(i)->setEnabled(is_enabled);
|
||||
m_pad_buttons->button(i)->setEnabled(is_enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1078,7 +1078,7 @@ void pad_settings_dialog::OnPadButtonClicked(int id)
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto but : m_padButtons->buttons())
|
||||
for (auto but : m_pad_buttons->buttons())
|
||||
{
|
||||
but->setFocusPolicy(Qt::ClickFocus);
|
||||
}
|
||||
@ -1100,9 +1100,9 @@ void pad_settings_dialog::OnPadButtonClicked(int id)
|
||||
m_last_pos = QCursor::pos();
|
||||
|
||||
m_button_id = id;
|
||||
m_padButtons->button(m_button_id)->setText(tr("[ Waiting %1 ]").arg(MAX_SECONDS));
|
||||
m_padButtons->button(m_button_id)->setPalette(QPalette(Qt::blue));
|
||||
m_padButtons->button(m_button_id)->grabMouse();
|
||||
m_pad_buttons->button(m_button_id)->setText(tr("[ Waiting %1 ]").arg(MAX_SECONDS));
|
||||
m_pad_buttons->button(m_button_id)->setPalette(QPalette(Qt::blue));
|
||||
m_pad_buttons->button(m_button_id)->grabMouse();
|
||||
SwitchButtons(false); // disable all buttons, needed for using Space, Enter and other specific buttons
|
||||
m_timer.start(1000);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ private:
|
||||
bool m_enable_battery{ false };
|
||||
|
||||
// Button Mapping
|
||||
QButtonGroup* m_padButtons = nullptr;
|
||||
QButtonGroup* m_pad_buttons = nullptr;
|
||||
u32 m_button_id = id_pad_begin;
|
||||
std::map<int /*id*/, pad_button /*info*/> m_cfg_entries;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user