Touchscreen: Fix virtual joystick sometimes going backwards

This fixes a regression introduced by 34286d77c7ee65be480a372233c5ab7c4b81d9db / #14075.
This commit is contained in:
Gregor Parzefall 2024-03-17 14:40:50 +01:00
parent c8b615acc9
commit 4f84b01356

@ -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();
}