mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 18:35:22 +00:00
(Android) show message on ROM load failure/crash
This commit is contained in:
parent
ed743c92a8
commit
41a302de43
@ -59,11 +59,13 @@ public class RetroArch extends Activity implements
|
|||||||
AdapterView.OnItemClickListener {
|
AdapterView.OnItemClickListener {
|
||||||
private IconAdapter<ModuleWrapper> adapter;
|
private IconAdapter<ModuleWrapper> adapter;
|
||||||
static private final int ACTIVITY_LOAD_ROM = 0;
|
static private final int ACTIVITY_LOAD_ROM = 0;
|
||||||
|
static private final int ACTIVITY_NATIVE_ACTIVITY = 1;
|
||||||
static private String libretro_path;
|
static private String libretro_path;
|
||||||
static private Double report_refreshrate;
|
static private Double report_refreshrate;
|
||||||
static private final String TAG = "RetroArch-Phoenix";
|
static private final String TAG = "RetroArch-Phoenix";
|
||||||
private ConfigFile config;
|
private ConfigFile config;
|
||||||
private ConfigFile core_config;
|
private ConfigFile core_config;
|
||||||
|
private String return_file;
|
||||||
|
|
||||||
private final double getDisplayRefreshRate() {
|
private final double getDisplayRefreshRate() {
|
||||||
// Android is *very* likely to screw this up.
|
// Android is *very* likely to screw this up.
|
||||||
@ -282,6 +284,12 @@ public class RetroArch extends Activity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getCacheDir() != null && getCacheDir().getAbsolutePath() != null) {
|
||||||
|
return_file = getCacheDir().getAbsolutePath() + File.pathSeparator + ".return";
|
||||||
|
} else {
|
||||||
|
return_file = getDefaultConfigPath() + ".ret";
|
||||||
|
}
|
||||||
|
|
||||||
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
@ -352,7 +360,7 @@ public class RetroArch extends Activity implements
|
|||||||
else if (getCacheDir() != null && getCacheDir().getAbsolutePath() != null)
|
else if (getCacheDir() != null && getCacheDir().getAbsolutePath() != null)
|
||||||
return getCacheDir().getAbsolutePath() + File.separator + "retroarch.cfg";
|
return getCacheDir().getAbsolutePath() + File.separator + "retroarch.cfg";
|
||||||
else // emergency fallback, all else failed
|
else // emergency fallback, all else failed
|
||||||
return "/mnt/sd/retroarch.cfg";
|
return "/mnt/sdcard/retroarch.cfg";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConfigFile() {
|
private void updateConfigFile() {
|
||||||
@ -456,6 +464,7 @@ public class RetroArch extends Activity implements
|
|||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case ACTIVITY_LOAD_ROM:
|
case ACTIVITY_LOAD_ROM:
|
||||||
if (data.getStringExtra("PATH") != null) {
|
if (data.getStringExtra("PATH") != null) {
|
||||||
|
new File(return_file).delete();
|
||||||
Toast.makeText(this,
|
Toast.makeText(this,
|
||||||
"Loading: [" + data.getStringExtra("PATH") + "]...",
|
"Loading: [" + data.getStringExtra("PATH") + "]...",
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
@ -463,10 +472,30 @@ public class RetroArch extends Activity implements
|
|||||||
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
||||||
myIntent.putExtra("LIBRETRO", libretro_path);
|
myIntent.putExtra("LIBRETRO", libretro_path);
|
||||||
myIntent.putExtra("CONFIGFILE", getDefaultConfigPath());
|
myIntent.putExtra("CONFIGFILE", getDefaultConfigPath());
|
||||||
|
myIntent.putExtra("RETURN", return_file);
|
||||||
myIntent.putExtra("IME", current_ime);
|
myIntent.putExtra("IME", current_ime);
|
||||||
startActivity(myIntent);
|
startActivityForResult(myIntent, ACTIVITY_NATIVE_ACTIVITY);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ACTIVITY_NATIVE_ACTIVITY:
|
||||||
|
Log.i(TAG, "native return");
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this).setNeutralButton("OK", null);
|
||||||
|
try {
|
||||||
|
DataInputStream cacheStream = new DataInputStream(new FileInputStream(return_file));
|
||||||
|
int value = cacheStream.readInt();
|
||||||
|
cacheStream.close();
|
||||||
|
Log.i(TAG, "native return value");
|
||||||
|
Log.i(TAG, "native return value:" + value);
|
||||||
|
if (value != 0) {
|
||||||
|
builder.setTitle("Error").setMessage("RetroArch Could not load the chosen ROM").show();
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
builder.setTitle("Crash").setMessage("RetroArch Crashed").show();
|
||||||
|
} catch (IOException e) {
|
||||||
|
builder.setTitle("Error").setMessage("RetroArch Could not load the chosen ROM").show();
|
||||||
|
}
|
||||||
|
new File(return_file).delete();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <byteswap.h>
|
||||||
|
|
||||||
#include "frontend_android.h"
|
#include "frontend_android.h"
|
||||||
#include "../android/native/jni/jni_macros.h"
|
#include "../android/native/jni/jni_macros.h"
|
||||||
@ -280,6 +281,12 @@ static bool android_app_start_main(struct android_app *android_app, int *init_re
|
|||||||
strlcpy(out_args.in, "IME", sizeof(out_args.in));
|
strlcpy(out_args.in, "IME", sizeof(out_args.in));
|
||||||
jni_get(&in_params, &out_args);
|
jni_get(&in_params, &out_args);
|
||||||
|
|
||||||
|
// Return value file
|
||||||
|
out_args.out = android_app->return_file;
|
||||||
|
out_args.out_sizeof = sizeof(android_app->return_file);
|
||||||
|
strlcpy(out_args.in, "RETURN", sizeof(out_args.in));
|
||||||
|
jni_get(&in_params, &out_args);
|
||||||
|
|
||||||
(*in_params.java_vm)->DetachCurrentThread(in_params.java_vm);
|
(*in_params.java_vm)->DetachCurrentThread(in_params.java_vm);
|
||||||
|
|
||||||
RARCH_LOG("Checking arguments passed ...\n");
|
RARCH_LOG("Checking arguments passed ...\n");
|
||||||
@ -287,6 +294,9 @@ static bool android_app_start_main(struct android_app *android_app, int *init_re
|
|||||||
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
|
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
|
||||||
RARCH_LOG("Config file: [%s].\n", config_file);
|
RARCH_LOG("Config file: [%s].\n", config_file);
|
||||||
RARCH_LOG("Current IME: [%s].\n", android_app->current_ime);
|
RARCH_LOG("Current IME: [%s].\n", android_app->current_ime);
|
||||||
|
RARCH_LOG("Return file: [%s].\n", android_app->return_file);
|
||||||
|
|
||||||
|
unlink(android_app->return_file);
|
||||||
|
|
||||||
struct rarch_main_wrap args = {0};
|
struct rarch_main_wrap args = {0};
|
||||||
|
|
||||||
@ -371,6 +381,19 @@ exit:
|
|||||||
#endif
|
#endif
|
||||||
rarch_main_clear_state();
|
rarch_main_clear_state();
|
||||||
|
|
||||||
|
int bs_return = bswap_32(init_ret);
|
||||||
|
FILE *return_file = fopen(android_app->return_file, "w");
|
||||||
|
if (return_file)
|
||||||
|
{
|
||||||
|
fwrite(&bs_return, 4, 1, return_file);
|
||||||
|
fclose(return_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// returning from the native activity too fast can make the Java frontend not reappear
|
||||||
|
// work around it only if we fail to load the ROM
|
||||||
|
if (init_ret != 0)
|
||||||
|
usleep(1000000);
|
||||||
|
|
||||||
RARCH_LOG("android_app_destroy!");
|
RARCH_LOG("android_app_destroy!");
|
||||||
if (android_app->inputQueue != NULL)
|
if (android_app->inputQueue != NULL)
|
||||||
AInputQueue_detachLooper(android_app->inputQueue);
|
AInputQueue_detachLooper(android_app->inputQueue);
|
||||||
|
@ -49,6 +49,7 @@ struct android_app
|
|||||||
AInputQueue* pendingInputQueue;
|
AInputQueue* pendingInputQueue;
|
||||||
ANativeWindow* pendingWindow;
|
ANativeWindow* pendingWindow;
|
||||||
char current_ime[PATH_MAX];
|
char current_ime[PATH_MAX];
|
||||||
|
char return_file[PATH_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user