Skip to content

Commit f302998

Browse files
authored
android: Gamepad input onKeyDown (#7101)
Nvidia shield button inputs (A/B/X/Y) were not working correctly due to the IME check incorrectly consuming the event and preventing super.onKeyDown()/Up() from being called. If the KeyEvent is a gamepad button, they should just directly call super.onKeyDown()/Up(). Bug: 399492613
1 parent 17c3993 commit f302998

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cobalt/android/apk/app/src/main/java/dev/cobalt/coat/CobaltActivity.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,19 @@ protected boolean dispatchKeyEventToIme(int keyCode, int action) {
275275

276276
@Override
277277
public boolean onKeyDown(int keyCode, KeyEvent event) {
278+
// If input is a from a gamepad button, it shouldn't be dispatched to IME which incorrectly
279+
// consumes the event as a VKEY_UNKNOWN
280+
if (KeyEvent.isGamepadButton(keyCode)) {
281+
return super.onKeyDown(keyCode, event);
282+
}
278283
return dispatchKeyEventToIme(keyCode, KeyEvent.ACTION_DOWN) || super.onKeyDown(keyCode, event);
279284
}
280285

281286
@Override
282287
public boolean onKeyUp(int keyCode, KeyEvent event) {
288+
if (KeyEvent.isGamepadButton(keyCode)) {
289+
return super.onKeyUp(keyCode, event);
290+
}
283291
return dispatchKeyEventToIme(keyCode, KeyEvent.ACTION_UP) || super.onKeyUp(keyCode, event);
284292
}
285293

0 commit comments

Comments
 (0)