From 4f84b0135608676edc9969a653eaae07dce37e98 Mon Sep 17 00:00:00 2001 From: Gregor Parzefall Date: Sun, 17 Mar 2024 14:40:50 +0100 Subject: [PATCH] Touchscreen: Fix virtual joystick sometimes going backwards This fixes a regression introduced by 34286d77c7ee65be480a372233c5ab7c4b81d9db / #14075. --- src/client/inputhandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp index 7b2e70b54..5c91898bc 100644 --- a/src/client/inputhandler.cpp +++ b/src/client/inputhandler.cpp @@ -237,7 +237,9 @@ float RealInputHandler::getMovementDirection() if (x != 0 || z != 0) /* If there is a keyboard event, it takes priority */ return std::atan2(x, z); - else if (g_touchscreengui && g_touchscreengui->getMovementDirection()) + // `getMovementDirection() == 0` means forward, so we cannot use + // `getMovementDirection()` as a condition. + else if (g_touchscreengui && g_touchscreengui->getMovementSpeed()) return g_touchscreengui->getMovementDirection(); return joystick.getMovementDirection(); }