From 902ee91a02cc5c49db93b11a08bff996c91a7c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 8 Dec 2023 22:49:47 +0100 Subject: [PATCH] Android: Ignore key events with keycode 0 from gamepads. Trying a really narrow fix for problem with stadia pads converted to bluetooth, reported by oldmario on Discord. --- android/jni/app-android.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 20d2f6fe7021..2c4244034b20 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1195,8 +1195,11 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch } extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyDown(JNIEnv *, jclass, jint deviceId, jint key, jboolean isRepeat) { - if (!renderer_inited) + // Ignore keycode 0 from pads. Stadia controllers seem to produce them when pressing L2/R2 for some reason, confusing things. + if (!renderer_inited || (key == 0 && deviceId >= DEVICE_ID_PAD_0 && deviceId <= DEVICE_ID_PAD_9)) { return false; + } + KeyInput keyInput; keyInput.deviceId = (InputDeviceID)deviceId; keyInput.keyCode = (InputKeyCode)key; @@ -1208,8 +1211,11 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyDown(JNIEnv *, jclass, j } extern "C" jboolean Java_org_ppsspp_ppsspp_NativeApp_keyUp(JNIEnv *, jclass, jint deviceId, jint key) { - if (!renderer_inited) + // Ignore keycode 0 from pads. Stadia controllers seem to produce them when pressing L2/R2 for some reason, confusing things. + if (!renderer_inited || (key == 0 && deviceId >= DEVICE_ID_PAD_0 && deviceId <= DEVICE_ID_PAD_9)) { return false; + } + KeyInput keyInput; keyInput.deviceId = (InputDeviceID)deviceId; keyInput.keyCode = (InputKeyCode)key;