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. <freddyfunk@users.noreply.github.com>
This commit is contained in:
Tobias 2022-12-17 16:11:49 +01:00 committed by GitHub
parent ccb50e7f2c
commit ae3d50f71f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,8 +195,21 @@ ConfigureInput::ConfigureInput(QWidget* parent)
connect(button_map[button_id], &QPushButton::clicked, [this, button_id]() { connect(button_map[button_id], &QPushButton::clicked, [this, button_id]() {
HandleClick( HandleClick(
button_map[button_id], button_map[button_id],
[this, button_id](const Common::ParamPackage& params) { [this, button_id](Common::ParamPackage params) {
buttons_param[button_id] = 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 // If the user closes the dialog, the changes are reverted in
// `GMainWindow::OnConfigure()` // `GMainWindow::OnConfigure()`
ApplyConfiguration(); ApplyConfiguration();