mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 13:56:59 +01:00
controller: use Back as the touchpad click on pads without a touchpad (#1355)
* controller: use Back as the touchpad click on pads without a touchpad Gamepads without a touchpad (Switch, Xbox, 8BitDo, ...) cannot click it, so games that require the touchpad can't be played with them. The keyboard already emulates it (Backspace/Tab); gamepads had nothing. For SDL_GAMEPAD_BUTTON_BACK on a pad that reports no touchpads, report PAD_BUTTON_TOUCH_PAD plus a finger at the centre of the touchpad. Pads with a real touchpad are unchanged. Fixes #1298 * controller: establish touch before fallback click --------- Co-authored-by: nmzik <Nmzik@mail.ru>
This commit is contained in:
@@ -326,6 +326,19 @@ static void GameEventController([[maybe_unused]] const EventController& f) {
|
|||||||
const auto button = ControllerButtonToPadButton(f.button);
|
const auto button = ControllerButtonToPadButton(f.button);
|
||||||
if (button != 0) {
|
if (button != 0) {
|
||||||
Controller::SetButton(f.id, button, f.down);
|
Controller::SetButton(f.id, button, f.down);
|
||||||
|
} else if (f.button == SDL_GAMEPAD_BUTTON_BACK) {
|
||||||
|
// Pads without a touchpad (Switch, Xbox, ...) have no way to click it, which
|
||||||
|
// blocks games that require it. Use their Back/Select button as a centered click.
|
||||||
|
auto* pad = SDL_GetGamepadFromID(f.id);
|
||||||
|
if (pad != nullptr && SDL_GetNumGamepadTouchpads(pad) == 0) {
|
||||||
|
if (f.down) {
|
||||||
|
Controller::SetTouchPad(f.id, 0, true, 0.5f, 0.5f);
|
||||||
|
}
|
||||||
|
Controller::SetButton(f.id, Controller::PAD_BUTTON_TOUCH_PAD, f.down);
|
||||||
|
if (f.up) {
|
||||||
|
Controller::SetTouchPad(f.id, 0, false, 0.5f, 0.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user