Handle only suppoted characters

This commit is contained in:
Lubos 2022-12-03 11:47:22 +01:00
parent 8bb0124fe6
commit 91fa5bcf3b
2 changed files with 7 additions and 3 deletions

View file

@ -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) 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 );
} }
} }

View file

@ -36,6 +36,7 @@ import static android.system.Os.setenv;
public class MainActivity extends SDLActivity // implements KeyEvent.Callback public class MainActivity extends SDLActivity // implements KeyEvent.Callback
{ {
private static final String SUPPORTED_ASCII = "qwertyuiop[]asdfghjkl;'\\<zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:\"|>ZXCVBNM<>?`1234567890-=~!@#$%^&*()_+";
private int permissionCount = 0; private int permissionCount = 0;
private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1; private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1;
private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2; private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
@ -76,7 +77,10 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) { public boolean dispatchKeyEvent(KeyEvent event) {
//ASCII characters directly passed into the engine //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 //special keys using SDL
return super.dispatchKeyEvent(event); return super.dispatchKeyEvent(event);
} }