From 91fa5bcf3bdaac476f6638cd3b9f89d4b5ae7a9a Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 3 Dec 2022 11:47:22 +0100 Subject: [PATCH] Handle only suppoted characters --- android/app/src/main/cpp/main.c | 4 ++-- .../src/main/java/com/drbeef/ioq3quest/MainActivity.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/cpp/main.c b/android/app/src/main/cpp/main.c index 6e6ebd0b..341cda96 100644 --- a/android/app/src/main/cpp/main.c +++ b/android/app/src/main/cpp/main.c @@ -38,9 +38,9 @@ JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeFocusChanged JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeKey(JNIEnv *env, jclass clazz, jint keycode, jint action) { - if ((action == 0) || (action == 1)) + if (action == 0) { - Com_QueueEvent( 0, SE_CHAR, keycode, action == 0, 0, NULL ); + Com_QueueEvent( 0, SE_CHAR, keycode, qtrue, 0, NULL ); } } diff --git a/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java b/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java index ea06321c..893bd5a9 100644 --- a/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java +++ b/android/app/src/main/java/com/drbeef/ioq3quest/MainActivity.java @@ -36,6 +36,7 @@ import static android.system.Os.setenv; public class MainActivity extends SDLActivity // implements KeyEvent.Callback { + private static final String SUPPORTED_ASCII = "qwertyuiop[]asdfghjkl;'\\ZXCVBNM<>?`1234567890-=~!@#$%^&*()_+"; private int permissionCount = 0; private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1; private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2; @@ -76,7 +77,10 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback @Override public boolean dispatchKeyEvent(KeyEvent event) { //ASCII characters directly passed into the engine - nativeKey(event.getKeyCode(), event.getAction()); + if (SUPPORTED_ASCII.indexOf(event.getUnicodeChar()) >= 0) { + nativeKey(event.getUnicodeChar(), event.getAction()); + return true; + } //special keys using SDL return super.dispatchKeyEvent(event); }