From de406d2728015d332e594d27060190d85d893811 Mon Sep 17 00:00:00 2001
From: Kyle Kienapfel <Docteh@users.noreply.github.com>
Date: Fri, 21 Oct 2022 04:11:32 -0700
Subject: [PATCH] Draft: trying to tweak ZL/ZR triggering

This is related to Issue 9096
---
 src/input_common/drivers/sdl_driver.cpp         |  4 ++++
 .../configuration/configure_input_player.cpp    | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index b72e4b3975..1bf107c125 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -579,6 +579,9 @@ Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, const
     params.Set("guid", guid.RawString());
     params.Set("axis", axis);
     params.Set("threshold", "0.5");
+    LOG_INFO(Frontend, "This didn't work");
+    params.Set("range", "2");
+    params.Set("offset", "-1.000000");
     params.Set("invert", value < 0 ? "-" : "+");
     return params;
 }
@@ -615,6 +618,7 @@ Common::ParamPackage SDLDriver::BuildMotionParam(int port, const Common::UUID& g
 
 Common::ParamPackage SDLDriver::BuildParamPackageForBinding(
     int port, const Common::UUID& guid, const SDL_GameControllerButtonBind& binding) const {
+    LOG_INFO(Frontend, "I thought this would get called when I bind the axis");
     switch (binding.bindType) {
     case SDL_CONTROLLER_BINDTYPE_NONE:
         break;
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 9e5a40fe74..e0ceb7b6ad 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -345,6 +345,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
         }
 
         connect(button, &QPushButton::clicked, [=, this] {
+            LOG_INFO(Frontend, "Wheee");
             HandleClick(
                 button, button_id,
                 [=, this](const Common::ParamPackage& params) {
@@ -405,6 +406,20 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
                             button_map[button_id]->setText(ButtonToText(param));
                             emulated_controller->SetButtonParam(button_id, param);
                         });
+                        context_menu.addAction(tr("Toggle Offset"), [&] {
+                            int offset = param.Get("offset", 0);
+                            if (offset == 0) {
+                                LOG_INFO(Frontend, "Boosting offset/range");
+                                param.Set("offset", -1.0f);
+                                param.Set("range", 2);
+                            } else {
+                                LOG_INFO(Frontend, "Unboosting offset/range");
+                                param.Set("offset", 0);
+                                param.Set("range", 1);
+                            }
+                            button_map[button_id]->setText(ButtonToText(param));
+                            emulated_controller->SetButtonParam(button_id, param);
+                        });
                     }
                     context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
                 });
@@ -455,6 +470,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i
             emulated_controller->GetButtonParam(Settings::NativeButton::ZL);
         if (param.Has("threshold")) {
             const auto slider_value = ui->sliderZLThreshold->value();
+            ui->sliderZLThreshold->setToolTip(QString::number(ui->sliderZLThreshold->value()));
             param.Set("threshold", slider_value / 100.0f);
             emulated_controller->SetButtonParam(Settings::NativeButton::ZL, param);
         }
@@ -1412,6 +1428,7 @@ void ConfigureInputPlayer::HandleClick(
     QWidget::grabKeyboard();
 
     if (type == InputCommon::Polling::InputType::Button) {
+        LOG_INFO(Frontend, "Wheee");
         ui->controllerFrame->BeginMappingButton(button_id);
     } else if (type == InputCommon::Polling::InputType::Stick) {
         ui->controllerFrame->BeginMappingAnalog(button_id);