From 822845e1bab46c5721f24d794bfd32b5280bc515 Mon Sep 17 00:00:00 2001 From: dgis Date: Mon, 7 Oct 2024 19:43:48 +0200 Subject: [PATCH] Update the readme.txt file and cleanup LCD update functions. --- ReadMe.txt | 1 + app/src/main/assets/ReadMe.txt | 6 ++++++ app/src/main/cpp/emu-jni.c | 16 ++++++---------- .../org/emulator/calculator/MainScreenView.java | 2 +- .../org/emulator/forty/eight/MainActivity.java | 9 ++++----- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index a75ac76..0ae589e 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -61,6 +61,7 @@ CHANGES Version 2.8 (2024-xx-xx) - Updated source code with Emu48 version 1.66+. +- Fix an USB serial issue with Android 13+ (fix #23). Version 2.7 (2024-06-14) diff --git a/app/src/main/assets/ReadMe.txt b/app/src/main/assets/ReadMe.txt index 71490fd..73256e9 100644 --- a/app/src/main/assets/ReadMe.txt +++ b/app/src/main/assets/ReadMe.txt @@ -58,6 +58,12 @@ LINKS CHANGES +Version 2.8 (2024-xx-xx) + +- Updated source code with Emu48 version 1.66+. +- Fix an USB serial issue with Android 13+ (fix #23). + + Version 2.7 (2024-06-14) - Updated source code with Emu48 version 1.65+. This new version improve the serial communication. diff --git a/app/src/main/cpp/emu-jni.c b/app/src/main/cpp/emu-jni.c index 4089002..cfad6b5 100644 --- a/app/src/main/cpp/emu-jni.c +++ b/app/src/main/cpp/emu-jni.c @@ -88,16 +88,14 @@ enum CALLBACK_TYPE { }; // https://stackoverflow.com/questions/9630134/jni-how-to-callback-from-c-or-c-to-java -int mainViewCallback(int type, int param1, int param2, const TCHAR * param3, const TCHAR * param4) { +int mainViewCallback(int type, int param1, int param2/*, const TCHAR * param3, const TCHAR * param4*/) { if (mainActivity) { JNIEnv *jniEnv = getJNIEnvironment(); if(jniEnv) { jclass mainActivityClass = (*jniEnv)->GetObjectClass(jniEnv, mainActivity); if(mainActivityClass) { - jmethodID midStr = (*jniEnv)->GetMethodID(jniEnv, mainActivityClass, "updateCallback", "(IIILjava/lang/String;Ljava/lang/String;)I"); - jstring utfParam3 = (*jniEnv)->NewStringUTF(jniEnv, param3); - jstring utfParam4 = (*jniEnv)->NewStringUTF(jniEnv, param4); - int result = (*jniEnv)->CallIntMethod(jniEnv, mainActivity, midStr, type, param1, param2, utfParam3, utfParam4); + jmethodID midStr = (*jniEnv)->GetMethodID(jniEnv, mainActivityClass, "updateCallback", "(III)I"); + int result = (*jniEnv)->CallIntMethod(jniEnv, mainActivity, midStr, type, param1, param2); (*jniEnv)->DeleteLocalRef(jniEnv, mainActivityClass); //if(needDetach) ret = (*java_machine)->DetachCurrentThread(java_machine); return result; @@ -113,18 +111,16 @@ void mainViewUpdateCallback() { // int param2 = ((mainViewRectangleToUpdate.right & 0xFFFF) << 16) | (mainViewRectangleToUpdate.bottom & 0xFFFF); // mainViewCallback(CALLBACK_TYPE_INVALIDATE, // param1, -// param2, -// NULL, NULL); +// param2); // SetRectEmpty(&mainViewRectangleToUpdate); // } else mainViewCallback(CALLBACK_TYPE_INVALIDATE, 0, - 0, - NULL, NULL); + 0); } void mainViewResizeCallback(int x, int y) { - mainViewCallback(CALLBACK_TYPE_WINDOW_RESIZE, x, y, NULL, NULL); + mainViewCallback(CALLBACK_TYPE_WINDOW_RESIZE, x, y); JNIEnv * jniEnv; int ret = (*java_machine)->GetEnv(java_machine, (void **) &jniEnv, JNI_VERSION_1_6); diff --git a/app/src/main/java/org/emulator/calculator/MainScreenView.java b/app/src/main/java/org/emulator/calculator/MainScreenView.java index 0e2804e..6802b8e 100644 --- a/app/src/main/java/org/emulator/calculator/MainScreenView.java +++ b/app/src/main/java/org/emulator/calculator/MainScreenView.java @@ -483,7 +483,7 @@ public class MainScreenView extends PanAndScaleView { canvas.drawLines(pointsBuffer, paintLCD); } - public void updateCallback(int type, int param1, int param2, String param3, String param4) { + public void updateCallback(int type, int param1, int param2) { try { switch (type) { case NativeLib.CALLBACK_TYPE_INVALIDATE: diff --git a/app/src/main/java/org/emulator/forty/eight/MainActivity.java b/app/src/main/java/org/emulator/forty/eight/MainActivity.java index d190de5..ca96ba6 100644 --- a/app/src/main/java/org/emulator/forty/eight/MainActivity.java +++ b/app/src/main/java/org/emulator/forty/eight/MainActivity.java @@ -1783,12 +1783,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On // Method used from JNI! @SuppressWarnings("UnusedDeclaration") - public int updateCallback(int type, int param1, int param2, String param3, String param4) { - - mainScreenView.updateCallback(type, param1, param2, param3, param4); - return -1; - } + public int updateCallback(int type, int param1, int param2) { + mainScreenView.updateCallback(type, param1, param2); + return -1; + } final int GENERIC_READ = 1; final int GENERIC_WRITE = 2;