summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-01-25 00:41:49 +0100
committerGitHub <noreply@github.com>2022-01-25 00:41:49 +0100
commit344236512770ad8c96b881064f2f6776da1b0451 (patch)
treead1a8a708ab7426f108989e064ec40a9916c4f73 /src
parentMerge pull request #7761 from v1993/patch-8 (diff)
parentyuzu: Add modifiers for keyboard (diff)
downloadyuzu-344236512770ad8c96b881064f2f6776da1b0451.tar
yuzu-344236512770ad8c96b881064f2f6776da1b0451.tar.gz
yuzu-344236512770ad8c96b881064f2f6776da1b0451.tar.bz2
yuzu-344236512770ad8c96b881064f2f6776da1b0451.tar.lz
yuzu-344236512770ad8c96b881064f2f6776da1b0451.tar.xz
yuzu-344236512770ad8c96b881064f2f6776da1b0451.tar.zst
yuzu-344236512770ad8c96b881064f2f6776da1b0451.zip
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index d2132b408..7029287a9 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -147,7 +147,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) {
// Retrieve the names from Qt
if (param.Get("engine", "") == "keyboard") {
const QString button_str = GetKeyName(param.Get("code", 0));
- return QObject::tr("%1%2").arg(toggle, button_str);
+ return QObject::tr("%1%2%3").arg(toggle, inverted, button_str);
}
if (common_button_name == Common::Input::ButtonNames::Invalid) {
@@ -341,7 +341,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
emulated_controller->SetButtonParam(button_id, {});
button_map[button_id]->setText(tr("[not set]"));
});
- if (param.Has("button") || param.Has("hat")) {
+ if (param.Has("code") || param.Has("button") || param.Has("hat")) {
context_menu.addAction(tr("Toggle button"), [&] {
const bool toggle_value = !param.Get("toggle", false);
param.Set("toggle", toggle_value);
@@ -349,8 +349,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
emulated_controller->SetButtonParam(button_id, param);
});
context_menu.addAction(tr("Invert button"), [&] {
- const bool toggle_value = !param.Get("inverted", false);
- param.Set("inverted", toggle_value);
+ const bool invert_value = !param.Get("inverted", false);
+ param.Set("inverted", invert_value);
button_map[button_id]->setText(ButtonToText(param));
emulated_controller->SetButtonParam(button_id, param);
});
@@ -510,28 +510,37 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested,
- [=, this](const QPoint& menu_location) {
- QMenu context_menu;
- Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
- context_menu.addAction(tr("Clear"), [&] {
- param.Set("modifier", "");
- analog_map_modifier_button[analog_id]->setText(tr("[not set]"));
- emulated_controller->SetStickParam(analog_id, param);
- });
- context_menu.addAction(tr("Toggle button"), [&] {
- Common::ParamPackage modifier_param =
- Common::ParamPackage{param.Get("modifier", "")};
- const bool toggle_value = !modifier_param.Get("toggle", false);
- modifier_param.Set("toggle", toggle_value);
- param.Set("modifier", modifier_param.Serialize());
- analog_map_modifier_button[analog_id]->setText(
- ButtonToText(modifier_param));
- emulated_controller->SetStickParam(analog_id, param);
- });
- context_menu.exec(
- analog_map_modifier_button[analog_id]->mapToGlobal(menu_location));
+ connect(
+ analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested,
+ [=, this](const QPoint& menu_location) {
+ QMenu context_menu;
+ Common::ParamPackage param = emulated_controller->GetStickParam(analog_id);
+ context_menu.addAction(tr("Clear"), [&] {
+ param.Set("modifier", "");
+ analog_map_modifier_button[analog_id]->setText(tr("[not set]"));
+ emulated_controller->SetStickParam(analog_id, param);
+ });
+ context_menu.addAction(tr("Toggle button"), [&] {
+ Common::ParamPackage modifier_param =
+ Common::ParamPackage{param.Get("modifier", "")};
+ const bool toggle_value = !modifier_param.Get("toggle", false);
+ modifier_param.Set("toggle", toggle_value);
+ param.Set("modifier", modifier_param.Serialize());
+ analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param));
+ emulated_controller->SetStickParam(analog_id, param);
});
+ context_menu.addAction(tr("Invert button"), [&] {
+ Common::ParamPackage modifier_param =
+ Common::ParamPackage{param.Get("modifier", "")};
+ const bool invert_value = !modifier_param.Get("inverted", false);
+ modifier_param.Set("inverted", invert_value);
+ param.Set("modifier", modifier_param.Serialize());
+ analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param));
+ emulated_controller->SetStickParam(analog_id, param);
+ });
+ context_menu.exec(
+ analog_map_modifier_button[analog_id]->mapToGlobal(menu_location));
+ });
connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged),
[=, this] {