diff --git a/Celestia/src/main/cpp/CelestiaAppCore.cpp b/Celestia/src/main/cpp/CelestiaAppCore.cpp index 6966b2de..3e4c95dc 100644 --- a/Celestia/src/main/cpp/CelestiaAppCore.cpp +++ b/Celestia/src/main/cpp/CelestiaAppCore.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -392,6 +393,16 @@ Java_space_celestia_celestia_AppCore_c_1chdir(JNIEnv *env, jclass clazz, env->ReleaseStringUTFChars(path, c_str); } +extern "C" +JNIEXPORT void JNICALL +Java_space_celestia_celestia_AppCore_c_1log(JNIEnv *env, jclass clazz, + jstring string) { + const char *c_str = env->GetStringUTFChars(string, nullptr); + celestia::util::GetLogger()->warn(c_str); + env->ReleaseStringUTFChars(string, c_str); +} + + static int convert_modifier_to_celestia_modifier(jint buttons, jint modifiers) { // TODO: other modifier diff --git a/Celestia/src/main/java/space/celestia/celestia/AppCore.java b/Celestia/src/main/java/space/celestia/celestia/AppCore.java index 9d38709f..bd00f35a 100644 --- a/Celestia/src/main/java/space/celestia/celestia/AppCore.java +++ b/Celestia/src/main/java/space/celestia/celestia/AppCore.java @@ -241,6 +241,10 @@ public Simulation getSimulation() { return simulation; } + public static void log(@NonNull String string) { + c_log(string); + } + public @NonNull String getRenderInfo() { return c_getRenderInfo(pointer); } @@ -294,6 +298,8 @@ public Simulation getSimulation() { private static native boolean c_initGL(); private static native void c_chdir(String path); + private static native void c_log(String string); + private static native List c_getDestinations(long ptr); // Locale diff --git a/app/src/main/java/space/celestia/mobilecelestia/celestia/CelestiaInteraction.kt b/app/src/main/java/space/celestia/mobilecelestia/celestia/CelestiaInteraction.kt index 9c6750b0..70a96c4c 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/celestia/CelestiaInteraction.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/celestia/CelestiaInteraction.kt @@ -642,7 +642,8 @@ class CelestiaInteraction(context: Context, private val appCore: AppCore, privat private fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { metaState = MetaKeyKeyListener.handleKeyDown(metaState, keyCode, event) - var input = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(metaState)) + val originalInput = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(metaState)) + var input = originalInput metaState = MetaKeyKeyListener.adjustMetaAfterKeypress(metaState) if (!canAcceptKeyEvents()) return false @@ -680,7 +681,9 @@ class CelestiaInteraction(context: Context, private val appCore: AppCore, privat } } + val logString = "Key Code: ${keyCode} Input: ${input}, ${originalInput} Unicode Char: ${event.unicodeChar} Unicode Char without MetaState: ${event.getUnicodeChar(0)} Event MetaState: ${event.metaState} Overall MetaState: ${event.metaState}\n" executor.execute { + AppCore.log(logString) appCore.keyDown(input, keyCode, event.keyModifier()) } return true