From 3212b036a1822c7225673c7c1eb742998700a03f Mon Sep 17 00:00:00 2001 From: Erick C Date: Sun, 22 Oct 2023 15:03:33 -0400 Subject: [PATCH] Manual DS4 mode: Allow Back/Select to trigger Touchpad click (#1772) Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- docs/source/about/advanced_usage.rst | 17 +++++++++++++++++ src/config.cpp | 2 ++ src/config.h | 1 + src/platform/windows/input.cpp | 5 ++++- src_assets/common/assets/web/config.html | 24 ++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/docs/source/about/advanced_usage.rst b/docs/source/about/advanced_usage.rst index e9bba6781f1..c9d9ebae3b4 100644 --- a/docs/source/about/advanced_usage.rst +++ b/docs/source/about/advanced_usage.rst @@ -152,6 +152,23 @@ gamepad .. code-block:: text gamepad = auto + +ds4_back_as_touchpad_click +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +**Description** + .. Hint:: Only applies when gamepad is set to ds4 manually. Unused in other gamepad modes. + + Allow Select/Back inputs to also trigger DS4 touchpad click. Useful for clients looking to emulate touchpad click + on Xinput devices. + +**Default** + ``enabled`` + +**Example** + .. code-block:: text + + ds4_back_as_touchpad_click = enabled back_button_timeout ^^^^^^^^^^^^^^^^^^^ diff --git a/src/config.cpp b/src/config.cpp index 726f67f8ca7..d5932d62cfe 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -418,6 +418,7 @@ namespace config { platf::supported_gamepads().front().data(), platf::supported_gamepads().front().size(), }, // Default gamepad + true, // back as touchpad click enabled (manual DS4 only) true, // keyboard enabled true, // mouse enabled @@ -1041,6 +1042,7 @@ namespace config { } string_restricted_f(vars, "gamepad"s, input.gamepad, platf::supported_gamepads()); + bool_f(vars, "ds4_back_as_touchpad_click", input.ds4_back_as_touchpad_click); bool_f(vars, "mouse", input.mouse); bool_f(vars, "keyboard", input.keyboard); diff --git a/src/config.h b/src/config.h index 090e6b6864d..749a8556d11 100644 --- a/src/config.h +++ b/src/config.h @@ -112,6 +112,7 @@ namespace config { std::chrono::duration key_repeat_period; std::string gamepad; + bool ds4_back_as_touchpad_click; bool keyboard; bool mouse; diff --git a/src/platform/windows/input.cpp b/src/platform/windows/input.cpp index ca9cfba7b93..29dd758acc1 100644 --- a/src/platform/windows/input.cpp +++ b/src/platform/windows/input.cpp @@ -1174,7 +1174,7 @@ namespace platf { BOOST_LOG(info) << "Gamepad " << id.globalIndex << " will be Xbox 360 controller (manual selection)"sv; selectedGamepadType = Xbox360Wired; } - else if (config::input.gamepad == "ps4"sv || config::input.gamepad == "ds4"sv) { + else if (config::input.gamepad == "ds4"sv) { BOOST_LOG(info) << "Gamepad " << id.globalIndex << " will be DualShock 4 controller (manual selection)"sv; selectedGamepadType = DualShock4Wired; } @@ -1334,6 +1334,9 @@ namespace platf { // Allow either PS4/PS5 clickpad button or Xbox Series X share button to activate DS4 clickpad if (gamepad_state.buttonFlags & (TOUCHPAD_BUTTON | MISC_BUTTON)) buttons |= DS4_SPECIAL_BUTTON_TOUCHPAD; + // Manual DS4 emulation: check if BACK button should also trigger DS4 touchpad click + if (config::input.gamepad == "ds4"sv && config::input.ds4_back_as_touchpad_click && (gamepad_state.buttonFlags & BACK)) buttons |= DS4_SPECIAL_BUTTON_TOUCHPAD; + return (DS4_SPECIAL_BUTTONS) buttons; } diff --git a/src_assets/common/assets/web/config.html b/src_assets/common/assets/web/config.html index 6f9e89de027..6e2b61b760c 100644 --- a/src_assets/common/assets/web/config.html +++ b/src_assets/common/assets/web/config.html @@ -105,6 +105,29 @@

Configuration

Choose which type of gamepad to emulate on the host
+
+
+

+ +

+
+
+
+ + +
When forcing DS4 emulation, map Back/Select to Touchpad Click
+
+
+
+
+
@@ -1136,6 +1159,7 @@

"capture": "", "controller": "enabled", "install_steam_audio_drivers": "enabled", + "ds4_back_as_touchpad_click": "enabled", "dwmflush": "enabled", "encoder": "", "fps": "[10,30,60,90,120]",