From a6c59ad75d54c277ec623509bf28f0980d4f9917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julian=20Gro=C3=9F?= <julian.g@posteo.de>
Date: Sun, 9 Jul 2023 15:06:31 +0200
Subject: [PATCH] Fix Valve Index Controller trackpad regression

---
 .../controllers/{index.json => openvr_alternative.json}   | 0
 plugins/openvr/src/ViveControllerManager.cpp              | 8 ++++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
 rename interface/resources/controllers/{index.json => openvr_alternative.json} (100%)

diff --git a/interface/resources/controllers/index.json b/interface/resources/controllers/openvr_alternative.json
similarity index 100%
rename from interface/resources/controllers/index.json
rename to interface/resources/controllers/openvr_alternative.json
diff --git a/plugins/openvr/src/ViveControllerManager.cpp b/plugins/openvr/src/ViveControllerManager.cpp
index ec1b6bc671..75582c677e 100644
--- a/plugins/openvr/src/ViveControllerManager.cpp
+++ b/plugins/openvr/src/ViveControllerManager.cpp
@@ -2070,10 +2070,14 @@ controller::Input::NamedVector ViveControllerManager::InputDevice::getAvailableI
 QString ViveControllerManager::InputDevice::getDefaultMappingConfig() const {
     QString name(getOpenVrDeviceName().c_str());
     QString MAPPING_JSON;
-    if (name.contains(QString("HTC")) || name.contains(QString("Vive"))) {
+    // Workaround for having to press the thumbstick to be able to move.
+    // On HTC Vive wands we want to need to press the touchpad to move.
+    // On Valve Index controllers the thumbsticks don't need to be pressed, but the touchpad does. Valve seems to have already thought of this.
+    if (name.contains(QString("HTC")) || name.contains(QString("Vive")) || name.contains(QString("Valve"))) {
         MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/vive.json";
+    // Other HMDs need a different mapping to not need the thumbstick to be pressed.
     } else {
-        MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/index.json";
+        MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/openvr_alternative.json";
     }
     return MAPPING_JSON;
 }