diff --git a/app/jni/prboom/jni_doom.c b/app/jni/prboom/jni_doom.c index bb79389..622bbc7 100644 --- a/app/jni/prboom/jni_doom.c +++ b/app/jni/prboom/jni_doom.c @@ -275,6 +275,19 @@ JNIEXPORT jint JNICALL Java_doom_util_Natives_gameState demoplayback ? 1 : 0; } + +JNIEXPORT jint JNICALL Java_doom_util_Natives_isMapShowing + (JNIEnv * env, jclass cls) +{ + return (int) automapmode; +} + +JNIEXPORT jint JNICALL Java_doom_util_Natives_isMenuShowing + (JNIEnv * env, jclass cls) +{ + return menuactive ? 1 : 0; +} + /** * Get java array length */ diff --git a/app/src/main/java/doom/util/DoomTools.java b/app/src/main/java/doom/util/DoomTools.java index 6ca2e58..7a10774 100644 --- a/app/src/main/java/doom/util/DoomTools.java +++ b/app/src/main/java/doom/util/DoomTools.java @@ -97,16 +97,34 @@ public class DoomTools { switch (key) { case KeyEvent.KEYCODE_DPAD_LEFT: - return KEY_A; + if(Natives.isMapShowing() == 0 || Natives.isMenuShowing() != 0) + return KEY_A; + else + return 0xac; case KeyEvent.KEYCODE_DPAD_RIGHT: - return KEY_D; + if(Natives.isMapShowing() == 0 || Natives.isMenuShowing() != 0) + return KEY_D; + else + return 0xae; case KeyEvent.KEYCODE_DPAD_UP: - return KEY_W; + if(Natives.isMapShowing() == 0 || Natives.isMenuShowing() != 0) + return KEY_W; + else + return 0xad; case KeyEvent.KEYCODE_DPAD_DOWN: - return KEY_S; + if(Natives.isMapShowing() == 0 || Natives.isMenuShowing() != 0) + return KEY_S; + else + return 0xaf; + + case KeyEvent.KEYCODE_BUTTON_THUMBR: + return 0x69; + + case KeyEvent.KEYCODE_BUTTON_THUMBL: + return 0x6f; // Left case 84: // SYM diff --git a/app/src/main/java/doom/util/Natives.java b/app/src/main/java/doom/util/Natives.java index 8c0cf97..edf15f7 100644 --- a/app/src/main/java/doom/util/Natives.java +++ b/app/src/main/java/doom/util/Natives.java @@ -70,8 +70,10 @@ public class Natives */ public static native int motionEvent(int b, int x, int y); - //Returns whether menu or map is showing + //Little game state getters public static native int gameState(); + public static native int isMapShowing(); + public static native int isMenuShowing(); /*********************************************************** * C - Callbacks