Skip to content

Commit

Permalink
Android: Ignore key events with keycode 0 from gamepads.
Browse files Browse the repository at this point in the history
Trying a really narrow fix for problem with stadia pads converted to
bluetooth, reported by oldmario on Discord.
  • Loading branch information
hrydgard committed Dec 8, 2023
1 parent f8eb042 commit 902ee91
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 902ee91

Please sign in to comment.