Skip to content

Commit

Permalink
Android: When filtering bogus key events, return true so no further p…
Browse files Browse the repository at this point in the history
…rocessing happens.

Bugfix for 902ee91
  • Loading branch information
hrydgard committed Dec 8, 2023
1 parent c6db963 commit 29b934a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions android/jni/app-android.cpp
Expand Up @@ -1195,9 +1195,12 @@ 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) {
// 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;
if (!renderer_inited) {
return false; // could probably return true here too..
}
if (key == 0 && deviceId >= DEVICE_ID_PAD_0 && deviceId <= DEVICE_ID_PAD_9) {
// Ignore keycode 0 from pads. Stadia controllers seem to produce them when pressing L2/R2 for some reason, confusing things.
return true; // need to eat the key so it doesn't go through legacy path
}

KeyInput keyInput;
Expand All @@ -1211,9 +1214,12 @@ 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) {
// 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;
if (!renderer_inited) {
return false; // could probably return true here too..
}
if (key == 0 && deviceId >= DEVICE_ID_PAD_0 && deviceId <= DEVICE_ID_PAD_9) {
// Ignore keycode 0 from pads. Stadia controllers seem to produce them when pressing L2/R2 for some reason, confusing things.
return true; // need to eat the key so it doesn't go through legacy path
}

KeyInput keyInput;
Expand Down

0 comments on commit 29b934a

Please sign in to comment.