From ae3d50f71f6feee0e5a2c17fe1cb565c255b7b51 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 17 Dec 2022 16:11:49 +0100 Subject: [PATCH] Port yuzu-emu/yuzu#2968: configure_input: Fix input handling for ZL and ZR from controllers with analog triggers (#4984) Co-authored-by: Frederic L. --- src/citra_qt/configuration/configure_input.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp index be89eee76..6c40b9ebf 100644 --- a/src/citra_qt/configuration/configure_input.cpp +++ b/src/citra_qt/configuration/configure_input.cpp @@ -195,8 +195,21 @@ ConfigureInput::ConfigureInput(QWidget* parent) connect(button_map[button_id], &QPushButton::clicked, [this, button_id]() { HandleClick( button_map[button_id], - [this, button_id](const Common::ParamPackage& params) { - buttons_param[button_id] = params; + [this, button_id](Common::ParamPackage params) { + // Workaround for ZL & ZR for analog triggers like on XBOX controllors. + // Analog triggers (from controllers like the XBOX controller) would not + // work due to a different range of their signals (from 0 to 255 on + // analog triggers instead of -32768 to 32768 on analog joysticks). The + // SDL driver misinterprets analog triggers as analog joysticks. + // TODO: reinterpret the signal range for analog triggers to map the + // values correctly. This is required for the correct emulation of the + // analog triggers of the GameCube controller. + if (button_id == Settings::NativeButton::ZL || + button_id == Settings::NativeButton::ZR) { + params.Set("direction", "+"); + params.Set("threshold", "0.5"); + } + buttons_param[button_id] = std::move(params); // If the user closes the dialog, the changes are reverted in // `GMainWindow::OnConfigure()` ApplyConfiguration();