Skip to content

Commit

Permalink
Manual DS4 mode: Allow Back/Select to trigger Touchpad click (LizardB…
Browse files Browse the repository at this point in the history
…yte#1772)

Co-authored-by: ReenigneArcher <[email protected]>
  • Loading branch information
ekchang and ReenigneArcher committed Oct 22, 2023
1 parent 5b052d7 commit 3212b03
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
17 changes: 17 additions & 0 deletions docs/source/about/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ namespace config {
std::chrono::duration<double> key_repeat_period;

std::string gamepad;
bool ds4_back_as_touchpad_click;

bool keyboard;
bool mouse;
Expand Down
5 changes: 4 additions & 1 deletion src/platform/windows/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
24 changes: 24 additions & 0 deletions src_assets/common/assets/web/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,29 @@ <h1 class="my-4">Configuration</h1>
</select>
<div class="form-text">Choose which type of gamepad to emulate on the host</div>
</div>
<div class="accordion" v-if="config.gamepad === 'ds4'">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapseOne">
Manual DS4 options
</button>
</h2>
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show"
aria-labelledby="panelsStayOpen-headingOne">
<div class="accordion-body">
<div>
<label for="ds4_back_as_touchpad_click" class="form-label">Map Back/Select to Touchpad Click</label>
<select id="ds4_back_as_touchpad_click" class="form-select" v-model="config.ds4_back_as_touchpad_click">
<option value="disabled">Disabled</option>
<option value="enabled">Enabled (default)</option>
</select>
<div class="form-text">When forcing DS4 emulation, map Back/Select to Touchpad Click</div>
</div>
</div>
</div>
</div>
</div>
<!--Ping Timeout-->
<div class="mb-3">
<label for="ping_timeout" class="form-label">Ping Timeout</label>
Expand Down Expand Up @@ -1136,6 +1159,7 @@ <h2 class="accordion-header">
"capture": "",
"controller": "enabled",
"install_steam_audio_drivers": "enabled",
"ds4_back_as_touchpad_click": "enabled",
"dwmflush": "enabled",
"encoder": "",
"fps": "[10,30,60,90,120]",
Expand Down

0 comments on commit 3212b03

Please sign in to comment.