yuzu/configuration: Make function naming consistent
This commit is contained in:
parent
cae913d3d5
commit
ba6eb5285d
25 changed files with 248 additions and 243 deletions
|
@ -23,7 +23,7 @@ const std::array<std::string, ConfigureInput::ANALOG_SUB_BUTTONS_NUM>
|
|||
"modifier",
|
||||
}};
|
||||
|
||||
static QString getKeyName(int key_code) {
|
||||
static QString GetKeyName(int key_code) {
|
||||
switch (key_code) {
|
||||
case Qt::Key_Shift:
|
||||
return QObject::tr("Shift");
|
||||
|
@ -53,7 +53,7 @@ static QString ButtonToText(const Common::ParamPackage& param) {
|
|||
if (!param.Has("engine")) {
|
||||
return QObject::tr("[not set]");
|
||||
} else if (param.Get("engine", "") == "keyboard") {
|
||||
return getKeyName(param.Get("code", 0));
|
||||
return GetKeyName(param.Get("code", 0));
|
||||
} else if (param.Get("engine", "") == "sdl") {
|
||||
if (param.Has("hat")) {
|
||||
return QString(QObject::tr("Hat %1 %2"))
|
||||
|
@ -137,12 +137,12 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
continue;
|
||||
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(button_map[button_id], &QPushButton::released, [=]() {
|
||||
handleClick(button_map[button_id],
|
||||
HandleClick(button_map[button_id],
|
||||
[=](const Common::ParamPackage& params) {
|
||||
buttons_param[button_id] = params;
|
||||
// If the user closes the dialog, the changes are reverted in
|
||||
// `GMainWindow::OnConfigure()`
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
},
|
||||
InputCommon::Polling::DeviceType::Button);
|
||||
|
@ -153,14 +153,14 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
context_menu.addAction(tr("Clear"), [&] {
|
||||
buttons_param[button_id].Clear();
|
||||
button_map[button_id]->setText(tr("[not set]"));
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
});
|
||||
context_menu.addAction(tr("Restore Default"), [&] {
|
||||
buttons_param[button_id] = Common::ParamPackage{
|
||||
InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
|
||||
button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
});
|
||||
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
|
||||
|
@ -174,11 +174,11 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(
|
||||
Qt::CustomContextMenu);
|
||||
connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() {
|
||||
handleClick(analog_map_buttons[analog_id][sub_button_id],
|
||||
HandleClick(analog_map_buttons[analog_id][sub_button_id],
|
||||
[=](const Common::ParamPackage& params) {
|
||||
SetAnalogButton(params, analogs_param[analog_id],
|
||||
analog_sub_buttons[sub_button_id]);
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
},
|
||||
InputCommon::Polling::DeviceType::Button);
|
||||
|
@ -189,7 +189,7 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
context_menu.addAction(tr("Clear"), [&] {
|
||||
analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
|
||||
analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
});
|
||||
context_menu.addAction(tr("Restore Default"), [&] {
|
||||
|
@ -199,7 +199,7 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
analog_sub_buttons[sub_button_id]);
|
||||
analog_map_buttons[analog_id][sub_button_id]->setText(AnalogToText(
|
||||
analogs_param[analog_id], analog_sub_buttons[sub_button_id]));
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
});
|
||||
context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
|
||||
|
@ -210,10 +210,10 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
QMessageBox::information(this, tr("Information"),
|
||||
tr("After pressing OK, first move your joystick horizontally, "
|
||||
"and then vertically."));
|
||||
handleClick(analog_map_stick[analog_id],
|
||||
HandleClick(analog_map_stick[analog_id],
|
||||
[=](const Common::ParamPackage& params) {
|
||||
analogs_param[analog_id] = params;
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
},
|
||||
InputCommon::Polling::DeviceType::Analog);
|
||||
|
@ -228,34 +228,34 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
ui->buttonDelete->setEnabled(ui->profile->count() > 1);
|
||||
|
||||
connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); });
|
||||
connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); });
|
||||
connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { RestoreDefaults(); });
|
||||
connect(ui->buttonNew, &QPushButton::released, [this] { NewProfile(); });
|
||||
connect(ui->buttonDelete, &QPushButton::released, [this] { DeleteProfile(); });
|
||||
connect(ui->buttonRename, &QPushButton::released, [this] { RenameProfile(); });
|
||||
|
||||
connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
[this](int i) {
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(Settings::values.current_input_profile_index);
|
||||
Settings::LoadProfile(i);
|
||||
loadConfiguration();
|
||||
LoadConfiguration();
|
||||
});
|
||||
|
||||
timeout_timer->setSingleShot(true);
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });
|
||||
connect(timeout_timer.get(), &QTimer::timeout, [this]() { SetPollingResult({}, true); });
|
||||
|
||||
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
||||
Common::ParamPackage params;
|
||||
for (auto& poller : device_pollers) {
|
||||
params = poller->GetNextInput();
|
||||
if (params.Has("engine")) {
|
||||
setPollingResult(params, false);
|
||||
SetPollingResult(params, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this->loadConfiguration();
|
||||
LoadConfiguration();
|
||||
|
||||
// TODO(wwylele): enable this when we actually emulate it
|
||||
ui->buttonHome->setEnabled(false);
|
||||
|
@ -263,7 +263,7 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||
|
||||
ConfigureInput::~ConfigureInput() = default;
|
||||
|
||||
void ConfigureInput::applyConfiguration() {
|
||||
void ConfigureInput::ApplyConfiguration() {
|
||||
std::transform(buttons_param.begin(), buttons_param.end(),
|
||||
Settings::values.current_input_profile.buttons.begin(),
|
||||
[](const Common::ParamPackage& param) { return param.Serialize(); });
|
||||
|
@ -300,17 +300,17 @@ QList<QKeySequence> ConfigureInput::GetUsedKeyboardKeys() {
|
|||
return list;
|
||||
}
|
||||
|
||||
void ConfigureInput::loadConfiguration() {
|
||||
void ConfigureInput::LoadConfiguration() {
|
||||
std::transform(Settings::values.current_input_profile.buttons.begin(),
|
||||
Settings::values.current_input_profile.buttons.end(), buttons_param.begin(),
|
||||
[](const std::string& str) { return Common::ParamPackage(str); });
|
||||
std::transform(Settings::values.current_input_profile.analogs.begin(),
|
||||
Settings::values.current_input_profile.analogs.end(), analogs_param.begin(),
|
||||
[](const std::string& str) { return Common::ParamPackage(str); });
|
||||
updateButtonLabels();
|
||||
UpdateButtonLabels();
|
||||
}
|
||||
|
||||
void ConfigureInput::restoreDefaults() {
|
||||
void ConfigureInput::RestoreDefaults() {
|
||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
||||
buttons_param[button_id] = Common::ParamPackage{
|
||||
InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
|
||||
|
@ -323,7 +323,7 @@ void ConfigureInput::restoreDefaults() {
|
|||
SetAnalogButton(params, analogs_param[analog_id], analog_sub_buttons[sub_button_id]);
|
||||
}
|
||||
}
|
||||
updateButtonLabels();
|
||||
UpdateButtonLabels();
|
||||
}
|
||||
|
||||
void ConfigureInput::ClearAll() {
|
||||
|
@ -338,10 +338,10 @@ void ConfigureInput::ClearAll() {
|
|||
analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
|
||||
}
|
||||
}
|
||||
updateButtonLabels();
|
||||
UpdateButtonLabels();
|
||||
}
|
||||
|
||||
void ConfigureInput::updateButtonLabels() {
|
||||
void ConfigureInput::UpdateButtonLabels() {
|
||||
for (int button = 0; button < Settings::NativeButton::NumButtons; button++) {
|
||||
if (button_map[button])
|
||||
button_map[button]->setText(ButtonToText(buttons_param[button]));
|
||||
|
@ -360,7 +360,7 @@ void ConfigureInput::updateButtonLabels() {
|
|||
EmitInputKeysChanged();
|
||||
}
|
||||
|
||||
void ConfigureInput::handleClick(QPushButton* button,
|
||||
void ConfigureInput::HandleClick(QPushButton* button,
|
||||
std::function<void(const Common::ParamPackage&)> new_input_setter,
|
||||
InputCommon::Polling::DeviceType type) {
|
||||
previous_key_code = QKeySequence(button->text())[0];
|
||||
|
@ -384,7 +384,7 @@ void ConfigureInput::handleClick(QPushButton* button,
|
|||
poll_timer->start(200); // Check for new inputs every 200ms
|
||||
}
|
||||
|
||||
void ConfigureInput::setPollingResult(const Common::ParamPackage& params, bool abort) {
|
||||
void ConfigureInput::SetPollingResult(const Common::ParamPackage& params, bool abort) {
|
||||
releaseKeyboard();
|
||||
releaseMouse();
|
||||
timeout_timer->stop();
|
||||
|
@ -397,7 +397,7 @@ void ConfigureInput::setPollingResult(const Common::ParamPackage& params, bool a
|
|||
(*input_setter)(params);
|
||||
}
|
||||
|
||||
updateButtonLabels();
|
||||
UpdateButtonLabels();
|
||||
input_setter.reset();
|
||||
}
|
||||
|
||||
|
@ -410,12 +410,12 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event) {
|
|||
// Check if key is already bound
|
||||
if (hotkey_list.contains(QKeySequence(event->key())) ||
|
||||
GetUsedKeyboardKeys().contains(QKeySequence(event->key()))) {
|
||||
setPollingResult({}, true);
|
||||
SetPollingResult({}, true);
|
||||
QMessageBox::critical(this, tr("Error!"),
|
||||
tr("You're using a key that's already bound."));
|
||||
return;
|
||||
}
|
||||
setPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->key())},
|
||||
SetPollingResult(Common::ParamPackage{InputCommon::GenerateKeyboardParam(event->key())},
|
||||
false);
|
||||
} else {
|
||||
// Escape key wasn't pressed and we don't want any keyboard keys, so don't stop
|
||||
|
@ -423,11 +423,11 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
setPollingResult({}, true);
|
||||
SetPollingResult({}, true);
|
||||
previous_key_code = 0;
|
||||
}
|
||||
|
||||
void ConfigureInput::retranslateUi() {
|
||||
void ConfigureInput::RetranslateUI() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
|
@ -442,12 +442,12 @@ void ConfigureInput::NewProfile() {
|
|||
return;
|
||||
}
|
||||
|
||||
applyConfiguration();
|
||||
ApplyConfiguration();
|
||||
Settings::SaveProfile(ui->profile->currentIndex());
|
||||
Settings::CreateProfile(name.toStdString());
|
||||
ui->profile->addItem(name);
|
||||
ui->profile->setCurrentIndex(Settings::values.current_input_profile_index);
|
||||
loadConfiguration();
|
||||
LoadConfiguration();
|
||||
ui->buttonDelete->setEnabled(ui->profile->count() > 1);
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ void ConfigureInput::DeleteProfile() {
|
|||
ui->profile->removeItem(index);
|
||||
ui->profile->setCurrentIndex(0);
|
||||
Settings::DeleteProfile(index);
|
||||
loadConfiguration();
|
||||
LoadConfiguration();
|
||||
ui->buttonDelete->setEnabled(ui->profile->count() > 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue