support back button to touchpad for spacebar as well

This commit is contained in:
fireph 2024-10-07 19:19:57 -07:00
parent f0de2e83bc
commit 1da4d769a2
2 changed files with 12 additions and 2 deletions

View File

@ -102,7 +102,7 @@ PAD DOWN | DOWN |
PAD LEFT | LEFT | PAD LEFT | LEFT |
PAD RIGHT | RIGHT | PAD RIGHT | RIGHT |
OPTIONS | RETURN | OPTIONS | RETURN |
TOUCH PAD | SPACE | BACK BUTTON / TOUCH PAD | SPACE |
L1 | Q | L1 | Q |
R1 | U | R1 | U |
L2 | E | L2 | E |

View File

@ -145,6 +145,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
Input::Axis axis = Input::Axis::AxisMax; Input::Axis axis = Input::Axis::AxisMax;
int axisvalue = 0; int axisvalue = 0;
int ax = 0; int ax = 0;
std::string backButtonBehavior = Config::getBackButtonBehavior();
switch (event->key.key) { switch (event->key.key) {
case SDLK_UP: case SDLK_UP:
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP;
@ -278,7 +279,16 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
ax = Input::GetAxis(0, 0x80, axisvalue); ax = Input::GetAxis(0, 0x80, axisvalue);
break; break;
case SDLK_SPACE: case SDLK_SPACE:
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; button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
} else {
button = 0;
}
break; break;
case SDLK_F11: case SDLK_F11:
if (event->type == SDL_EVENT_KEY_DOWN) { if (event->type == SDL_EVENT_KEY_DOWN) {