[Android] Get Display Error to display message box
This commit is contained in:
parent
a6fada0fcd
commit
e0647a88c0
|
@ -5,18 +5,10 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{593B00E6-1987-415D-A62C-26533FC3E95C}</ProjectGuid>
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#include <Project64-core/TraceModulesProject64.h>
|
||||
#include <Common/Trace.h>
|
||||
#include "JavaBridge.h"
|
||||
#include "jniBridge.h"
|
||||
|
||||
|
@ -30,6 +32,7 @@ JavaBridge::JavaBridge(JavaVM* vm) :
|
|||
|
||||
void JavaBridge::GfxThreadInit()
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
if (g_GLThread != NULL && env != NULL)
|
||||
{
|
||||
|
@ -38,18 +41,22 @@ void JavaBridge::GfxThreadInit()
|
|||
env->CallVoidMethod(g_GLThread, midThreadStarting);
|
||||
env->DeleteLocalRef(GLThreadClass);
|
||||
}
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
void JavaBridge::GfxThreadDone()
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
if (g_GLThread != NULL && env != NULL)
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "calling java GLThread::ThreadExiting");
|
||||
jclass GLThreadClass = env->GetObjectClass(g_GLThread);
|
||||
jmethodID midThreadExiting = env->GetMethodID(GLThreadClass, "ThreadExiting", "()V");
|
||||
env->CallVoidMethod(g_GLThread, midThreadExiting);
|
||||
env->DeleteLocalRef(GLThreadClass);
|
||||
}
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
void JavaBridge::SwapWindow()
|
||||
|
@ -103,6 +110,18 @@ void JavaBridge::RomListLoaded(void)
|
|||
}
|
||||
}
|
||||
|
||||
void JavaBridge::DisplayError(const char * Message)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
if (env)
|
||||
{
|
||||
jstring j_Message = env->NewStringUTF(Message);
|
||||
jmethodID midDisplayError = env->GetStaticMethodID(m_NotifierClass, "DisplayError", "(Landroid/app/Activity;Ljava/lang/String;)V");
|
||||
env->CallStaticVoidMethod(m_NotifierClass, midDisplayError,g_Activity,j_Message);
|
||||
env->DeleteLocalRef(j_Message);
|
||||
}
|
||||
}
|
||||
|
||||
void JavaBridge::DisplayMessage(const char * Message)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
|
@ -115,4 +134,14 @@ void JavaBridge::DisplayMessage(const char * Message)
|
|||
}
|
||||
}
|
||||
|
||||
void JavaBridge::EmulationStopped(void)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
if (g_Activity != NULL && env != NULL)
|
||||
{
|
||||
jmethodID midEmulationStopped = env->GetStaticMethodID(m_NotifierClass, "EmulationStopped", "(Landroid/app/Activity;)V");
|
||||
env->CallStaticVoidMethod(m_NotifierClass, midEmulationStopped, g_Activity);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -22,7 +22,9 @@ public:
|
|||
void RomListLoaded(void);
|
||||
|
||||
//Notification
|
||||
void DisplayError(const char * Message);
|
||||
void DisplayMessage(const char * Message);
|
||||
void EmulationStopped(void);
|
||||
|
||||
private:
|
||||
JavaBridge(void); // Disable default constructor
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <Common/Trace.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/Settings/SettingsClass.h>
|
||||
#include <Project64-core/N64System/N64Class.h>
|
||||
#include "NotificationClass.h"
|
||||
#include "JavaBridge.h"
|
||||
#if defined(ANDROID)
|
||||
|
@ -35,16 +36,37 @@ CNotificationImp::~CNotificationImp()
|
|||
{
|
||||
}
|
||||
|
||||
void CNotificationImp::DisplayError(const char * /*Message*/) const
|
||||
void CNotificationImp::DisplayError(const char * Message) const
|
||||
{
|
||||
#ifdef ANDROID
|
||||
g_JavaBridge->DisplayError(Message);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CNotificationImp::DisplayError(LanguageStringID /*StringID*/) const
|
||||
void CNotificationImp::DisplayError(LanguageStringID StringID) const
|
||||
{
|
||||
if (g_Lang)
|
||||
{
|
||||
DisplayError(g_Lang->GetString(StringID).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CNotificationImp::FatalError(LanguageStringID /*StringID*/) const
|
||||
void CNotificationImp::FatalError(LanguageStringID StringID) const
|
||||
{
|
||||
if (g_Lang)
|
||||
{
|
||||
FatalError(g_Lang->GetString(StringID).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CNotificationImp::FatalError(const char * Message) const
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceError, Message);
|
||||
DisplayError(Message);
|
||||
if (g_BaseSystem)
|
||||
{
|
||||
g_BaseSystem->CloseCpu();
|
||||
}
|
||||
}
|
||||
|
||||
void CNotificationImp::DisplayMessage(int DisplayTime, LanguageStringID StringID) const
|
||||
|
@ -52,11 +74,6 @@ void CNotificationImp::DisplayMessage(int DisplayTime, LanguageStringID StringID
|
|||
DisplayMessage(DisplayTime, g_Lang->GetString(StringID).c_str());
|
||||
}
|
||||
|
||||
void CNotificationImp::FatalError(const char * Message) const
|
||||
{
|
||||
DisplayMessage(0,Message);
|
||||
}
|
||||
|
||||
//User Feedback
|
||||
void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) const
|
||||
{
|
||||
|
@ -83,6 +100,10 @@ void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) con
|
|||
}*/
|
||||
|
||||
g_JavaBridge->DisplayMessage(Message);
|
||||
#else
|
||||
// ignore warning usage
|
||||
DisplayTime = DisplayTime;
|
||||
Message = Message;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -100,26 +121,11 @@ void CNotificationImp::BreakPoint(const char * FileName, int32_t LineNumber)
|
|||
{
|
||||
if (g_Settings->LoadBool(Debugger_Enabled))
|
||||
{
|
||||
DisplayError(stdstr_f("Break point found at\n%s\n%d", FileName, LineNumber).c_str());
|
||||
#ifndef _WIN32
|
||||
__builtin_trap();
|
||||
#endif
|
||||
#ifdef tofix
|
||||
if (g_BaseSystem)
|
||||
{
|
||||
g_BaseSystem->CloseCpu();
|
||||
}
|
||||
#endif
|
||||
FatalError(stdstr_f("Break point found at\n%s\nLine: %d", FileName, LineNumber).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayError("Fatal Error: Stopping emulation");
|
||||
#ifdef tofix
|
||||
if (g_BaseSystem)
|
||||
{
|
||||
g_BaseSystem->CloseCpu();
|
||||
}
|
||||
#endif
|
||||
FatalError("Fatal Error: Emulation stopped");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,9 +84,51 @@ EXPORT jint CALL JNI_OnLoad(JavaVM* vm, void* reserved)
|
|||
__android_log_print(ANDROID_LOG_ERROR, "jniBridge", "Error initializing pthread key");
|
||||
}
|
||||
Android_JNI_SetupThread();
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
void GameCpuRunning(void * /*NotUsed*/)
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
||||
bool Running = g_Settings->LoadBool(GameRunning_CPU_Running);
|
||||
WriteTrace(TraceUserInterface, TraceDebug, Running ? "Game Started" : "Game Stopped");
|
||||
if (!Running)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
if (env != NULL)
|
||||
{
|
||||
if (g_JavaBridge)
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Notify java emulation stopped");
|
||||
g_JavaBridge->EmulationStopped();
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceError, "No Java bridge");
|
||||
}
|
||||
|
||||
// call in to java that emulation done
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "clean up global activity");
|
||||
env->DeleteGlobalRef(g_Activity);
|
||||
g_Activity = NULL;
|
||||
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "clean up global gl thread");
|
||||
if (g_JavaBridge)
|
||||
{
|
||||
g_JavaBridge->GfxThreadDone();
|
||||
}
|
||||
env->DeleteGlobalRef(g_GLThread);
|
||||
g_GLThread = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteTrace(TraceUserInterface, TraceError, "Failed to get java environment");
|
||||
}
|
||||
}
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
EXPORT jboolean CALL Java_emu_project64_jni_NativeExports_appInit(JNIEnv* env, jclass cls, jstring BaseDir)
|
||||
{
|
||||
if (g_Logger == NULL)
|
||||
|
@ -123,6 +165,7 @@ EXPORT jboolean CALL Java_emu_project64_jni_NativeExports_appInit(JNIEnv* env, j
|
|||
JniBridegSettings = new CJniBridegSettings();
|
||||
|
||||
RegisterUISettings();
|
||||
g_Settings->RegisterChangeCB(GameRunning_CPU_Running, NULL, (CSettings::SettingChangedFunc)GameCpuRunning);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -191,10 +234,8 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_LoadRomList(JNIEnv* env, j
|
|||
WriteTrace(TraceUserInterface, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
EXPORT void CALL Java_emu_project64_jni_NativeExports_LoadGame(JNIEnv* env, jclass cls, jstring FileLoc, jobject activity, jobject GLThread)
|
||||
EXPORT void CALL Java_emu_project64_jni_NativeExports_LoadGame(JNIEnv* env, jclass cls, jstring FileLoc)
|
||||
{
|
||||
g_Activity = env->NewGlobalRef(activity);
|
||||
g_GLThread = env->NewGlobalRef(GLThread);
|
||||
const char *fileLoc = env->GetStringUTFChars(FileLoc, 0);
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "FileLoc: %s",fileLoc);
|
||||
g_Settings->SaveBool(Setting_AutoStart,false);
|
||||
|
@ -203,8 +244,10 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_LoadGame(JNIEnv* env, jcla
|
|||
WriteTrace(TraceUserInterface, TraceDebug, "Image loaded");
|
||||
}
|
||||
|
||||
EXPORT void CALL Java_emu_project64_jni_NativeExports_StartGame(JNIEnv* env, jclass cls)
|
||||
EXPORT void CALL Java_emu_project64_jni_NativeExports_StartGame(JNIEnv* env, jclass cls, jobject activity, jobject GLThread)
|
||||
{
|
||||
g_Activity = env->NewGlobalRef(activity);
|
||||
g_GLThread = env->NewGlobalRef(GLThread);
|
||||
g_BaseSystem->StartEmulation(true);
|
||||
}
|
||||
|
||||
|
@ -299,10 +342,6 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_CloseSystem(JNIEnv* env, j
|
|||
{
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Start");
|
||||
CN64System::CloseSystem();
|
||||
env->DeleteGlobalRef(g_Activity);
|
||||
g_Activity = NULL;
|
||||
env->DeleteGlobalRef(g_GLThread);
|
||||
g_GLThread = NULL;
|
||||
WriteTrace(TraceUserInterface, TraceDebug, "Done");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D233025A-231F-4A43-92B6-E87193C60ACC}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
|
|
@ -5,18 +5,10 @@
|
|||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{1133A1CC-A9E5-4026-B20D-6A2987130D4E}</ProjectGuid>
|
||||
|
|
|
@ -1,23 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B685BB34-D700-4FCC-8503-9B6AA1A0C95D}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
|
Loading…
Reference in New Issue