Ejemplo n.º 1
0
static void frontend_android_deinit(void *data)
{
   struct android_app *android_app = (struct android_app*)data;

   if (!android_app)
      return;

   RARCH_LOG("Deinitializing RetroArch ...\n");
   android_app->activityState = APP_CMD_DEAD;

   JNIEnv *env = jni_thread_getenv();
   if (env && android_app->onRetroArchExit)
      CALL_VOID_METHOD(env, android_app->activity->clazz, android_app->onRetroArchExit);

   if (android_app->inputQueue)
   {
      RARCH_LOG("Detaching Android input queue looper ...\n");
      AInputQueue_detachLooper(android_app->inputQueue);
   }
}
Ejemplo n.º 2
0
static void process_pending_intent(void *data)
{
   RARCH_LOG("process_pending_intent.\n");
   JNIEnv *env;
   struct android_app* android_app = (struct android_app*)data;
   jstring jstr = NULL;
   bool startgame = false;

   if (!android_app)
      return;

   env = jni_thread_getenv();
   if (!env)
      return;

   // ROM
   jstr = (*env)->CallObjectMethod(env, android_app->activity->clazz, android_app->getPendingIntentFullPath);
   JNI_EXCEPTION(env);
   RARCH_LOG("Checking arguments passed from intent ...\n");
   if (android_app->getPendingIntentFullPath && jstr)
   {
      const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
      strlcpy(g_extern.fullpath, argv, sizeof(g_extern.fullpath));
      (*env)->ReleaseStringUTFChars(env, jstr, argv);

      startgame = true;
      RARCH_LOG("ROM Filename: [%s].\n", g_extern.fullpath);
   }

   // Config file
   jstr = (*env)->CallObjectMethod(env, android_app->activity->clazz, android_app->getPendingIntentConfigPath);
   JNI_EXCEPTION(env);
   if (android_app->getPendingIntentConfigPath && jstr)
   {
      const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
      strlcpy(default_paths.config_path, argv, sizeof(default_paths.config_path));
      (*env)->ReleaseStringUTFChars(env, jstr, argv);

      RARCH_LOG("Config file: [%s].\n", g_extern.config_path);
   }

   // Current IME
   jstr = (*env)->CallObjectMethod(env, android_app->activity->clazz, android_app->getPendingIntentIME);
   JNI_EXCEPTION(env);
   if (android_app->getPendingIntentIME && jstr)
   {
      const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
      strlcpy(android_app->current_ime, argv, sizeof(android_app->current_ime));
      (*env)->ReleaseStringUTFChars(env, jstr, argv);

      RARCH_LOG("Current IME: [%s].\n", android_app->current_ime);
   }

   //LIBRETRO
   jstr = (*env)->CallObjectMethod(env, android_app->activity->clazz, android_app->getPendingIntentLibretroPath);
   JNI_EXCEPTION(env);
   if (android_app->getPendingIntentLibretroPath && jstr)
   {
      const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
      strlcpy(default_paths.core_path, argv, sizeof(default_paths.core_path));
      (*env)->ReleaseStringUTFChars(env, jstr, argv);
   }

   RARCH_LOG("Libretro path: [%s].\n", default_paths.core_path);

   if (startgame)
   {
      RARCH_LOG("Starting new game %s ...\n", g_extern.fullpath);
      g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_PREINIT);
      g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
      load_menu_game_new_core();
   }

   CALL_VOID_METHOD(env, android_app->activity->clazz, android_app->clearPendingIntent);
}