From 819c62e21e2b530a539bfeb51e28fb79245c6de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 10 Mar 2020 01:03:10 +0100 Subject: [PATCH] Android: Fix upside-down joystick navigation (due to an old sin). (Android's joystick Y axis is upside down, and we should have corrected it on the Java side instead of in all our mappings everywhere). --- ext/native/ui/root.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/native/ui/root.cpp b/ext/native/ui/root.cpp index b379511d6b..86b121f9c6 100644 --- a/ext/native/ui/root.cpp +++ b/ext/native/ui/root.cpp @@ -1,6 +1,7 @@ #include #include +#include "ppsspp_config.h" #include "base/timeutil.h" #include "ui/root.h" #include "ui/viewgroup.h" @@ -297,8 +298,14 @@ bool AxisEvent(const AxisInput &axis, ViewGroup *root) { dir = DIR_NEG; else if (axis.value > THRESHOLD) dir = DIR_POS; - // TODO: What do we do with devices that are reversed... ? + // We stupidly interpret the joystick Y axis backwards on Android instead of reversing + // it early (see keymaps...). Too late to fix without invalidating a lot of config files, so we + // reverse it here too. +#if PPSSPP_PLATFORM(ANDROID) + GenerateKeyFromAxis(y_state, dir, NKCODE_DPAD_UP, NKCODE_DPAD_DOWN); +#else GenerateKeyFromAxis(y_state, dir, NKCODE_DPAD_DOWN, NKCODE_DPAD_UP); +#endif y_state = dir; } break;