Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Android: Improve msgbox, printf cdi workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed Aug 20, 2018
1 parent 1274fe6 commit a15c345
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
9 changes: 7 additions & 2 deletions core/imgread/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ Disc* OpenDisc(const wchar* fn)

if (cdi_parse == drivers[i]) {
const wchar warn_str[] = "Warning: CDI Image Loaded!\n Many CDI images are known to be defective, GDI or CHD format is preferred. Please only file bug reports when using images known to be good (GDI or CHD).";
msgboxf(warn_str,MBX_ICONASTERISK);// if (OS_DlgYes!=os_Dialog(OS_DialogYesNo, cdiWarn_S)) rv=0;
#ifdef _ANDROID
printf(warn_str);
#else
msgboxf(warn_str, MBX_ICONASTERISK);// if (OS_DlgYes!=os_Dialog(OS_DialogYesNo, cdiWarn_S)) rv=0;
#endif
break;
}
}

Expand Down Expand Up @@ -440,4 +445,4 @@ DiscType GuessDiscType(bool m1, bool m2, bool da)
return CdRom_Extra;
else
return CdRom;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -652,19 +652,20 @@ int WriteBuffer(short[] samples, int wait)
void showMessage(final String msg) {
handler.post(new Runnable() {
public void run() {
Log.d(context.getApplicationContext().getPackageName(), msg);
Log.d(context.getPackageName(), msg);
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}
});
}

void coreMessage(byte[] msg) {
public int coreMessage(byte[] msg) {
try {
showMessage(new String(msg, "UTF-8"));
}
catch (UnsupportedEncodingException e) {
showMessage("coreMessage: Failed to display error");
}
return 1;
}

void Die() {
Expand Down
29 changes: 12 additions & 17 deletions shell/android-studio/reicast/src/main/jni/src/Android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,30 +336,25 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_run(JNIEnv *env,jobje

jsamples=env->NewShortArray(SAMPLE_COUNT*2);
writemid=env->GetMethodID(env->GetObjectClass(emu),"WriteBuffer","([SI)I");
coreMessageMid=env->GetMethodID(env->GetObjectClass(emu),"coreMessage","([B)V");
coreMessageMid=env->GetMethodID(env->GetObjectClass(emu),"coreMessage","([B)I");
dieMid=env->GetMethodID(env->GetObjectClass(emu),"Die","()V");
// msgboxf("HELLO!", MBX_OK);


dc_run();
}

int msgboxf(const wchar* Text,unsigned int Type,...)
{
wchar S[2048];
va_list Args;

va_start(Args,Type);
vsnprintf(S, 2048,Text,Args);
va_end(Args);
puts(S);
int msgboxf(const wchar* text,unsigned int type,...) {
va_list args;

int byteCount = strlen(S);
jbyteArray bytes = jenv->NewByteArray(byteCount);
jenv->SetByteArrayRegion(bytes, 0, byteCount, (jbyte*)S);
wchar temp[2048];
va_start(args, type);
vsprintf(temp, text, args);
va_end(args);

jenv->CallVoidMethod(emu,coreMessageMid,bytes);
int byteCount = strlen(temp);
jbyteArray bytes = jenv->NewByteArray(byteCount);
jenv->SetByteArrayRegion(bytes, 0, byteCount, (jbyte *) temp);

return (MBX_OK);
return jenv->CallIntMethod(emu, coreMessageMid, bytes);
}

JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupMic(JNIEnv *env,jobject obj,jobject sip)
Expand Down

0 comments on commit a15c345

Please sign in to comment.