Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 77b6b97

Browse files
committed
Merge branch 'skmp/android-msgbox' into stable
2 parents 436c0b9 + 3308aec commit 77b6b97

File tree

5 files changed

+82
-7
lines changed

5 files changed

+82
-7
lines changed

libswirl/android/Android.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ static jobject g_activity;
643643
static jmethodID VJoyStartEditingMID;
644644
static jmethodID VJoyStopEditingMID;
645645
static jmethodID VJoyResetEditingMID;
646+
static jmethodID MsgboxMID;
646647

647648
JNIEXPORT void JNICALL Java_com_reicast_emulator_BaseGLActivity_register(JNIEnv *env, jobject obj, jobject activity)
648649
{
@@ -651,11 +652,13 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_BaseGLActivity_register(JNIEnv
651652
env->DeleteGlobalRef(g_activity);
652653
g_activity = NULL;
653654
}
655+
654656
if (activity != NULL) {
655657
g_activity = env->NewGlobalRef(activity);
656658
VJoyStartEditingMID = env->GetMethodID(env->GetObjectClass(activity), "VJoyStartEditing", "()V");
657659
VJoyStopEditingMID = env->GetMethodID(env->GetObjectClass(activity), "VJoyStopEditing", "(Z)V");
658660
VJoyResetEditingMID = env->GetMethodID(env->GetObjectClass(activity), "VJoyResetEditing", "()V");
661+
MsgboxMID = env->GetMethodID(env->GetObjectClass(activity), "Msgbox", "(Ljava/lang/String;I)I");
659662
}
660663
}
661664

@@ -694,4 +697,24 @@ bool os_gl_swap()
694697
void os_gl_term()
695698
{
696699
return egl_Term();
697-
}
700+
}
701+
702+
#if defined(_ANDROID)
703+
int msgboxf(const wchar* text, unsigned int type, ...) {
704+
va_list args;
705+
706+
wchar temp[2048];
707+
va_start(args, type);
708+
vsnprintf(temp, sizeof(temp), text, args);
709+
va_end(args);
710+
printf("msgbox(%d) %s\n", type, temp);
711+
712+
auto jstr = jvm_attacher.getEnv()->NewStringUTF(temp);
713+
714+
auto rv = jvm_attacher.getEnv()->CallIntMethod(g_activity, MsgboxMID, jstr, type);
715+
716+
jvm_attacher.getEnv()->DeleteLocalRef(jstr);
717+
718+
return rv;
719+
}
720+
#endif

libswirl/gui/gui.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ GUI* GUI::Create() {
10441044
return new ReicastUI_impl();
10451045
}
10461046

1047-
1047+
#if !defined(_ANDROID)
10481048
int msgboxf(const wchar* text, unsigned int type, ...) {
10491049
va_list args;
10501050

@@ -1057,4 +1057,5 @@ int msgboxf(const wchar* text, unsigned int type, ...) {
10571057
g_GUI->DisplayNotification(temp, 2000);
10581058

10591059
return 1;
1060-
}
1060+
}
1061+
#endif

libswirl/linux/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ extern "C" u8* generic_fault_handler ()
9191
}
9292
else
9393
{
94-
fault_printf("generic_fault_handler: not in handled SIGSEGV pc: %lx addr:%p\n", ctx.pc, (void*)trap_si_addr);
94+
fault_printf("generic_fault_handler: not in handled SIGSEGV pc: %lx addr:%p here %p\n", ctx.pc, (void*)trap_si_addr, (void*)generic_fault_handler);
9595
trap_handled = false;
9696
}
9797

reicast/android-studio/reicast/src/main/java/com/reicast/emulator/NativeGLActivity.java

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.reicast.emulator;
22

3+
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.DialogInterface;
36
import android.os.Bundle;
47
import android.os.Handler;
58
import android.os.Looper;
@@ -46,13 +49,13 @@ public boolean isSurfaceReady() {
4649
}
4750

4851
// Called from native code
49-
private void VJoyStartEditing() {
52+
public void VJoyStartEditing() {
5053
vjoy_d_cached = VJoy.readCustomVjoyValues(getApplicationContext());
5154
JNIdc.show_osd();
5255
((NativeGLView)mView).setEditVjoyMode(true);
5356
}
5457
// Called from native code
55-
private void VJoyResetEditing() {
58+
public void VJoyResetEditing() {
5659
VJoy.resetCustomVjoyValues(getApplicationContext());
5760
((NativeGLView)mView).readCustomVjoyValues();
5861
((NativeGLView)mView).resetEditMode();
@@ -68,9 +71,53 @@ public void run() {
6871
});
6972
}
7073
// Called from native code
71-
private void VJoyStopEditing(boolean canceled) {
74+
public void VJoyStopEditing(boolean canceled) {
7275
if (canceled)
7376
((NativeGLView)mView).restoreCustomVjoyValues(vjoy_d_cached);
7477
((NativeGLView)mView).setEditVjoyMode(false);
7578
}
79+
80+
class ReadyState { public boolean value = false; }
81+
82+
public int Msgbox(final String text, final int type) {
83+
84+
final ReadyState ready = new ReadyState();
85+
86+
final Activity activity = this;
87+
88+
new Handler(Looper.getMainLooper()).post(new Runnable() {
89+
@Override
90+
public void run() {
91+
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
92+
93+
String msg = text;
94+
95+
if ((type & 0x10) != 0) { /* MBX_ICONERROR */
96+
msg += "\n" + R.string.msgbox_please_report;
97+
}
98+
99+
builder.setMessage(msg).setPositiveButton(R.string.msgbox_okay, new DialogInterface.OnClickListener() {
100+
public void onClick(DialogInterface dialog, int id) {
101+
synchronized (ready) {
102+
ready.value = true;
103+
ready.notify();
104+
}
105+
}
106+
});
107+
builder.create().show();
108+
}
109+
});
110+
111+
try
112+
{
113+
synchronized (ready) {
114+
while (!ready.value)
115+
ready.wait();
116+
}
117+
} catch(InterruptedException is) {
118+
119+
}
120+
121+
return 1;
122+
}
76123
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<resources>
2+
<string name="msgbox_please_report">Please send a screenshot of this to the Reicast Team</string>
3+
<string name="msgbox_okay">Okay</string>
4+
</resources>

0 commit comments

Comments
 (0)