From 1f228c51ca2c510622f4204937f90c7f2bbc7bf6 Mon Sep 17 00:00:00 2001 From: german Date: Fri, 5 Mar 2021 19:21:04 -0600 Subject: Enable button toggle for keyboard in the modifier button --- src/yuzu/bootmanager.cpp | 8 ++++++-- src/yuzu/configuration/configure_input_player.cpp | 13 ++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/yuzu') diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1c61d419d..50938fb04 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -376,11 +376,15 @@ void GRenderWindow::closeEvent(QCloseEvent* event) { } void GRenderWindow::keyPressEvent(QKeyEvent* event) { - input_subsystem->GetKeyboard()->PressKey(event->key()); + if (!event->isAutoRepeat()) { + input_subsystem->GetKeyboard()->PressKey(event->key()); + } } void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { - input_subsystem->GetKeyboard()->ReleaseKey(event->key()); + if (!event->isAutoRepeat()) { + input_subsystem->GetKeyboard()->ReleaseKey(event->key()); + } } void GRenderWindow::mousePressEvent(QMouseEvent* event) { diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 21d0d3449..e297eeffd 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -104,7 +104,9 @@ QString ButtonToText(const Common::ParamPackage& param) { } if (param.Get("engine", "") == "keyboard") { - return GetKeyName(param.Get("code", 0)); + const QString button_str = GetKeyName(param.Get("code", 0)); + const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : ""); + return QObject::tr("%1%2").arg(toggle, button_str); } if (param.Get("engine", "") == "gcpad") { @@ -412,6 +414,15 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i analogs_param[analog_id].Set("modifier", ""); analog_map_modifier_button[analog_id]->setText(tr("[not set]")); }); + context_menu.addAction(tr("Toggle button"), [&] { + Common::ParamPackage modifier_param = + Common::ParamPackage{analogs_param[analog_id].Get("modifier", "")}; + const bool toggle_value = !modifier_param.Get("toggle", false); + modifier_param.Set("toggle", toggle_value); + analogs_param[analog_id].Set("modifier", modifier_param.Serialize()); + analog_map_modifier_button[analog_id]->setText( + ButtonToText(modifier_param)); + }); context_menu.exec( analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); }); -- cgit v1.2.3