Skip to content

Commit c98ea06

Browse files
committed
Space bar As Back button
1 parent 2b73d25 commit c98ea06

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/sdl_window.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
145145
Input::Axis axis = Input::Axis::AxisMax;
146146
int axisvalue = 0;
147147
int ax = 0;
148+
std::string backButtonBehavior = Config::getBackButtonBehavior();
148149
switch (event->key.key) {
149150
case SDLK_UP:
150151
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_UP;
@@ -278,7 +279,15 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
278279
ax = Input::GetAxis(0, 0x80, axisvalue);
279280
break;
280281
case SDLK_SPACE:
281-
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
282+
if (backButtonBehavior != "none") {
283+
float x = backButtonBehavior == "left" ? 0.25f
284+
: (backButtonBehavior == "right" ? 0.75f : 0.5f);
285+
// trigger a touchpad event so that the touchpad emulation for back button works
286+
controller->SetTouchpadState(0, true, x, 0.5f);
287+
button = OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD;
288+
} else {
289+
button = 0;
290+
}
282291
break;
283292
case SDLK_F11:
284293
if (event->type == SDL_EVENT_KEY_DOWN) {

0 commit comments

Comments
 (0)