Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #97

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

test #97

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Celestia/src/main/cpp/CelestiaAppCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <celutil/fsutils.h>
#include <celutil/gettext.h>
#include <celutil/localeutil.h>
#include <celutil/logger.h>
#include <celestia/url.h>
#include <unicode/uloc.h>
#include <fmt/format.h>
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Celestia/src/main/java/space/celestia/celestia/AppCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<Destination> c_getDestinations(long ptr);

// Locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down