[Android] Call emulation started

This commit is contained in:
zilmar 2017-04-28 08:36:10 +10:00
parent 67f2a445ae
commit 03f7e4ac94
3 changed files with 30 additions and 3 deletions

View File

@ -156,6 +156,16 @@ void JavaBridge::EmulationStopped(void)
}
}
void JavaBridge::EmulationStarted(void)
{
JNIEnv *env = Android_JNI_GetEnv();
if (g_Activity != NULL && env != NULL)
{
jmethodID midEmulationStarted = env->GetStaticMethodID(m_NotifierClass, "EmulationStarted", "(Landroid/app/Activity;)V");
env->CallStaticVoidMethod(m_NotifierClass, midEmulationStarted, g_Activity);
}
}
void JavaBridge::RecentRomsUpdated(void)
{
JNIEnv *env = Android_JNI_GetEnv();

View File

@ -9,7 +9,7 @@ class JavaBridge :
public RenderWindow
{
public:
JavaBridge (JavaVM* vm);
JavaBridge(JavaVM* vm);
//Render window functions
void GfxThreadInit();
@ -18,7 +18,7 @@ public:
//Rom List
void RomListReset(void);
void RomListAddItem(const char * FullFileName, const char * FileName, const char * GoodName, uint32_t TextColor );
void RomListAddItem(const char * FullFileName, const char * FileName, const char * GoodName, uint32_t TextColor);
void RomListLoaded(void);
void RecentRomsUpdated(void);
@ -26,6 +26,7 @@ public:
void DisplayError(const char * Message);
void DisplayMessage(const char * Message, int DisplayTime);
void DisplayMessage2(const char * Message);
void EmulationStarted(void);
void EmulationStopped(void);
private:

View File

@ -231,6 +231,7 @@ void GameCpuRunning(void * /*NotUsed*/)
WriteTrace(TraceUserInterface, TraceDebug, "Start");
bool Running = g_Settings->LoadBool(GameRunning_CPU_Running);
WriteTrace(TraceUserInterface, TraceDebug, Running ? "Game Started" : "Game Stopped");
JNIEnv *env = Android_JNI_GetEnv();
if (Running)
{
stdstr FileLoc = g_Settings->LoadStringVal(Game_File);
@ -243,10 +244,25 @@ void GameCpuRunning(void * /*NotUsed*/)
int RunCount = UISettingsLoadDword(Game_RunCount);
WriteTrace(TraceUserInterface, TraceDebug, "Setting Run Count to %d", RunCount + 1);
UISettingsSaveDword(Game_RunCount, RunCount + 1);
if (env != NULL)
{
if (g_JavaBridge)
{
WriteTrace(TraceUserInterface, TraceDebug, "Notify java emulation stopped");
g_JavaBridge->EmulationStarted();
}
else
{
WriteTrace(TraceUserInterface, TraceError, "No Java bridge");
}
}
else
{
WriteTrace(TraceUserInterface, TraceError, "Failed to get java environment");
}
}
else
{
JNIEnv *env = Android_JNI_GetEnv();
if (env != NULL)
{
if (g_JavaBridge)