mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-18 17:34:52 +00:00
Add support to click touchpad using back button on non PS4/5 controllers (#1258)
* Working touchpad support Tested on PS5 controller plugged in via USB. * fix lint * Add support to click touchpad using back button on other controllers Takes the back button and allows the user to change the behavior of how it clicks the touchpad. The current options are left, right, center, and none. * add description text * make more generic so translations can be supported in combobox * fix lint * linter again * support back button to touchpad for spacebar as well * linter at it again
This commit is contained in:
parent
7389cf3e89
commit
ce53c41205
7 changed files with 136 additions and 17 deletions
|
@ -145,6 +145,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||
Input::Axis axis = Input::Axis::AxisMax;
|
||||
int axisvalue = 0;
|
||||
int ax = 0;
|
||||
std::string backButtonBehavior = Config::getBackButtonBehavior();
|
||||
switch (event->key.key) {
|
||||
case SDLK_UP:
|
||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP;
|
||||
|
@ -278,7 +279,15 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
|
|||
ax = Input::GetAxis(0, 0x80, axisvalue);
|
||||
break;
|
||||
case SDLK_SPACE:
|
||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
|
||||
if (backButtonBehavior != "none") {
|
||||
float x = backButtonBehavior == "left" ? 0.25f
|
||||
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
||||
// trigger a touchpad event so that the touchpad emulation for back button works
|
||||
controller->SetTouchpadState(0, true, x, 0.5f);
|
||||
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
|
||||
} else {
|
||||
button = 0;
|
||||
}
|
||||
break;
|
||||
case SDLK_F11:
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
|
@ -330,7 +339,20 @@ void WindowSDL::onGamepadEvent(const SDL_Event* event) {
|
|||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
button = sdlGamepadToOrbisButton(event->gbutton.button);
|
||||
if (button != 0) {
|
||||
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||
if (event->gbutton.button == SDL_GAMEPAD_BUTTON_BACK) {
|
||||
std::string backButtonBehavior = Config::getBackButtonBehavior();
|
||||
if (backButtonBehavior != "none") {
|
||||
float x = backButtonBehavior == "left"
|
||||
? 0.25f
|
||||
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
||||
// trigger a touchpad event so that the touchpad emulation for back button works
|
||||
controller->SetTouchpadState(0, true, x, 0.5f);
|
||||
controller->CheckButton(0, button,
|
||||
event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||
}
|
||||
} else {
|
||||
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||
}
|
||||
}
|
||||
if (SDL_GetCursor() != NULL) {
|
||||
SDL_HideCursor();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue