Describe the bug
PR #7429 added support for predictive back gestures. That is a special way of triggering the back key via a gesture on Android. In contrast to the previous implementation - and my expectation on how it would work - it does not fire a keyUp event.
From my understanding the solution would be to also fire a KEY_UP event in the OnBackInvokedCallback.onBackInvoked() implementation:
|
KeyEvent event = new KeyEvent(); |
|
event.timeStamp = System.nanoTime(); |
|
event.type = KeyEvent.KEY_DOWN; |
|
event.keyCode = Keys.BACK; |
|
event.keyChar = 0; |
|
keyEvents.add(event); |
Reproduction
The main difficulty may be to know if your device is even using predictive back gestures.
Here's a setup to create a test bed:
Gdx.input.setCatchKey(Input.Keys.BACK, true)
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyDown(int keycode) {
Gdx.app.debug("input", "keyDown: " + Input.Keys.toString(keycode));
return true;
}
@Override
public boolean keyUp(int keycode) {
Gdx.app.debug("input", "keyUp: " + Input.Keys.toString(keycode));
return true;
}
});
On my test device (only using gesture back button) it outputs:
[input] keyDown: Back
[input] keyDown: Back
[input] keyDown: Back
...
While I would expect it to output:
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
...
version
1.13.0+
Affected platforms
Describe the bug
PR #7429 added support for predictive back gestures. That is a special way of triggering the back key via a gesture on Android. In contrast to the previous implementation - and my expectation on how it would work - it does not fire a keyUp event.
From my understanding the solution would be to also fire a KEY_UP event in the OnBackInvokedCallback.onBackInvoked() implementation:
libgdx/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/DefaultAndroidInput.java
Lines 1420 to 1425 in 32eb91a
Reproduction
The main difficulty may be to know if your device is even using predictive back gestures.
Here's a setup to create a test bed:
On my test device (only using gesture back button) it outputs:
[input] keyDown: Back
[input] keyDown: Back
[input] keyDown: Back
...
While I would expect it to output:
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
[input] keyDown: Back
[input] keyUp: Back
...
version
1.13.0+
Affected platforms