2015-05-25 11:11:41 +00:00
|
|
|
// Copyright 2003 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2015-05-25 11:11:41 +00:00
|
|
|
// Refer to the license.txt file included.
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
#include <EGL/egl.h>
|
2018-09-25 01:07:56 +00:00
|
|
|
#include <UICommon/GameFile.h>
|
2016-06-24 08:43:46 +00:00
|
|
|
#include <android/log.h>
|
|
|
|
#include <android/native_window_jni.h>
|
2015-12-07 09:13:25 +00:00
|
|
|
#include <cinttypes>
|
2014-02-19 01:56:29 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <jni.h>
|
2015-12-07 04:15:51 +00:00
|
|
|
#include <memory>
|
2016-05-12 01:18:30 +00:00
|
|
|
#include <mutex>
|
2017-12-26 21:08:44 +00:00
|
|
|
#include <optional>
|
2017-05-18 23:33:44 +00:00
|
|
|
#include <string>
|
2016-05-12 09:17:17 +00:00
|
|
|
#include <thread>
|
2017-12-28 09:13:53 +00:00
|
|
|
#include <utility>
|
2015-12-07 09:13:25 +00:00
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
#include "Common/AndroidAnalytics.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Common/CPUDetect.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/CommonPaths.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-04-13 23:15:23 +00:00
|
|
|
#include "Common/Event.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2019-06-07 22:25:32 +00:00
|
|
|
#include "Common/IniFile.h"
|
2014-06-05 23:29:54 +00:00
|
|
|
#include "Common/Logging/LogManager.h"
|
2017-05-22 08:39:36 +00:00
|
|
|
#include "Common/MsgHandler.h"
|
2017-09-09 19:52:35 +00:00
|
|
|
#include "Common/Version.h"
|
2018-10-03 13:03:22 +00:00
|
|
|
#include "Common/WindowSystemInfo.h"
|
2015-12-07 09:13:25 +00:00
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
#include "Core/Analytics.h"
|
2017-05-27 13:43:40 +00:00
|
|
|
#include "Core/Boot/Boot.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Core/BootManager.h"
|
2018-02-16 18:47:52 +00:00
|
|
|
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
2018-01-21 00:31:53 +00:00
|
|
|
#include "Core/HW/DVD/DVDInterface.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "Core/HW/Wiimote.h"
|
2016-02-05 00:31:36 +00:00
|
|
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Core/Host.h"
|
2015-05-11 01:03:34 +00:00
|
|
|
#include "Core/PowerPC/JitInterface.h"
|
2017-04-15 14:23:48 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2015-05-11 01:03:34 +00:00
|
|
|
#include "Core/PowerPC/Profiler.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Core/State.h"
|
2013-04-15 01:39:56 +00:00
|
|
|
|
2016-07-06 18:33:05 +00:00
|
|
|
#include "DiscIO/Enums.h"
|
2015-12-07 09:13:25 +00:00
|
|
|
#include "DiscIO/Volume.h"
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2014-10-04 19:12:15 +00:00
|
|
|
#include "UICommon/UICommon.h"
|
|
|
|
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "VideoCommon/OnScreenDisplay.h"
|
2015-06-19 01:28:40 +00:00
|
|
|
#include "VideoCommon/RenderBase.h"
|
2014-02-19 01:56:29 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2019-01-22 12:45:02 +00:00
|
|
|
#include "../../Core/Common/WindowSystemInfo.h"
|
2018-06-01 07:36:29 +00:00
|
|
|
#include "jni/AndroidCommon/AndroidCommon.h"
|
|
|
|
#include "jni/AndroidCommon/IDCache.h"
|
|
|
|
#include "jni/ButtonManager.h"
|
2015-06-08 00:13:52 +00:00
|
|
|
|
2017-05-18 23:33:44 +00:00
|
|
|
namespace
|
|
|
|
{
|
2018-06-01 07:36:29 +00:00
|
|
|
static constexpr char DOLPHIN_TAG[] = "DolphinEmuNative";
|
2017-05-18 23:33:44 +00:00
|
|
|
|
2018-06-01 07:36:29 +00:00
|
|
|
ANativeWindow* s_surf;
|
2018-09-25 01:07:56 +00:00
|
|
|
IniFile s_ini;
|
2017-05-18 23:33:44 +00:00
|
|
|
|
|
|
|
// The Core only supports using a single Host thread.
|
|
|
|
// If multiple threads want to call host functions then they need to queue
|
|
|
|
// sequentially for access.
|
|
|
|
std::mutex s_host_identity_lock;
|
|
|
|
Common::Event s_update_main_frame_event;
|
|
|
|
bool s_have_wm_user_stop = false;
|
|
|
|
} // Anonymous namespace
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2019-01-29 01:00:13 +00:00
|
|
|
void UpdatePointer()
|
|
|
|
{
|
|
|
|
// Update touch pointer
|
2019-05-29 12:22:26 +00:00
|
|
|
JNIEnv* env = IDCache::GetEnvForThread();
|
2019-01-29 01:00:13 +00:00
|
|
|
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetUpdateTouchPointer());
|
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void Host_NotifyMapLoaded()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void Host_RefreshDSPDebuggerWindow()
|
|
|
|
{
|
|
|
|
}
|
2019-03-18 16:30:33 +00:00
|
|
|
bool Host_UIBlocksControllerState()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2018-05-28 17:03:29 +00:00
|
|
|
void Host_Message(HostMessageID id)
|
2013-02-26 19:49:00 +00:00
|
|
|
{
|
2018-05-28 17:03:29 +00:00
|
|
|
if (id == HostMessageID::WMUserJobDispatch)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-18 23:33:44 +00:00
|
|
|
s_update_main_frame_event.Set();
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2018-05-28 17:03:29 +00:00
|
|
|
else if (id == HostMessageID::WMUserStop)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
s_have_wm_user_stop = true;
|
|
|
|
if (Core::IsRunning())
|
|
|
|
Core::QueueHostJob(&Core::Stop);
|
|
|
|
}
|
2013-02-26 19:49:00 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
void Host_UpdateTitle(const std::string& title)
|
2013-07-27 20:09:18 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
__android_log_write(ANDROID_LOG_INFO, DOLPHIN_TAG, title.c_str());
|
2014-03-17 23:17:12 +00:00
|
|
|
}
|
2013-02-26 19:49:00 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void Host_UpdateDisasmDialog()
|
|
|
|
{
|
|
|
|
}
|
2013-02-26 19:49:00 +00:00
|
|
|
|
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
void Host_RequestRenderWindowSize(int width, int height)
|
|
|
|
{
|
2019-01-29 01:00:13 +00:00
|
|
|
std::thread jnicall(UpdatePointer);
|
|
|
|
jnicall.join();
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2014-07-16 13:53:33 +00:00
|
|
|
|
2017-07-12 07:11:29 +00:00
|
|
|
bool Host_UINeedsControllerState()
|
2014-07-16 14:24:40 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return true;
|
2014-07-16 14:24:40 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
bool Host_RendererHasFocus()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return true;
|
2013-02-26 19:49:00 +00:00
|
|
|
}
|
|
|
|
|
2015-01-04 16:09:56 +00:00
|
|
|
bool Host_RendererIsFullscreen()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return false;
|
2015-01-04 16:09:56 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 16:55:21 +00:00
|
|
|
void Host_YieldToUI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-25 15:35:24 +00:00
|
|
|
void Host_UpdateProgressDialog(const char* caption, int position, int total)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-14 02:31:31 +00:00
|
|
|
void Host_TitleChanged()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-17 03:45:37 +00:00
|
|
|
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType /*style*/)
|
2015-02-13 00:41:52 +00:00
|
|
|
{
|
2019-05-29 12:22:26 +00:00
|
|
|
JNIEnv* env = IDCache::GetEnvForThread();
|
2015-06-08 00:13:52 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// Execute the Java method.
|
2018-06-01 07:36:29 +00:00
|
|
|
jboolean result = env->CallStaticBooleanMethod(
|
|
|
|
IDCache::GetNativeLibraryClass(), IDCache::GetDisplayAlertMsg(), ToJString(env, caption),
|
|
|
|
ToJString(env, text), yes_no ? JNI_TRUE : JNI_FALSE);
|
2015-06-08 00:13:52 +00:00
|
|
|
|
2018-01-07 22:30:28 +00:00
|
|
|
return result != JNI_FALSE;
|
2015-02-13 00:41:52 +00:00
|
|
|
}
|
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
static void ReportSend(std::string endpoint, std::string report)
|
|
|
|
{
|
2019-05-29 12:22:26 +00:00
|
|
|
JNIEnv* env = IDCache::GetEnvForThread();
|
2018-08-19 21:38:29 +00:00
|
|
|
|
|
|
|
jbyteArray output_array = env->NewByteArray(report.size());
|
|
|
|
jbyte* output = env->GetByteArrayElements(output_array, nullptr);
|
|
|
|
memcpy(output, report.data(), report.size());
|
|
|
|
env->ReleaseByteArrayElements(output_array, output, 0);
|
|
|
|
env->CallStaticVoidMethod(IDCache::GetAnalyticsClass(), IDCache::GetSendAnalyticsReport(),
|
|
|
|
ToJString(env, endpoint), output_array);
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string GetAnalyticValue(std::string key)
|
|
|
|
{
|
2019-05-29 12:22:26 +00:00
|
|
|
JNIEnv* env = IDCache::GetEnvForThread();
|
2018-08-19 21:38:29 +00:00
|
|
|
|
|
|
|
jstring value = reinterpret_cast<jstring>(env->CallStaticObjectMethod(
|
|
|
|
IDCache::GetAnalyticsClass(), IDCache::GetAnalyticsValue(), ToJString(env, key)));
|
|
|
|
|
|
|
|
std::string stdvalue = GetJString(env, value);
|
|
|
|
|
|
|
|
return stdvalue;
|
|
|
|
}
|
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
#ifdef __cplusplus
|
2016-06-24 08:43:46 +00:00
|
|
|
extern "C" {
|
2013-02-26 19:49:00 +00:00
|
|
|
#endif
|
2014-03-14 21:20:44 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv* env,
|
|
|
|
jobject obj);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv* env,
|
|
|
|
jobject obj);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv* env,
|
|
|
|
jobject obj);
|
2017-12-25 12:57:31 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv* env,
|
|
|
|
jobject obj);
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
|
|
|
|
JNIEnv* env, jobject obj, jstring jDevice, jint Button, jint Action);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
|
|
|
|
JNIEnv* env, jobject obj, jstring jDevice, jint Axis, jfloat Value);
|
|
|
|
JNIEXPORT jstring JNICALL
|
|
|
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jobject obj);
|
2017-09-10 06:43:12 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env,
|
|
|
|
jobject obj);
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env,
|
|
|
|
jobject obj);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jint api);
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(
|
|
|
|
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(
|
|
|
|
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring jFile);
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv* env,
|
|
|
|
jobject obj,
|
2017-12-26 21:22:42 +00:00
|
|
|
jint slot,
|
|
|
|
jboolean wait);
|
2017-12-25 12:50:29 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveStateAs(JNIEnv* env,
|
|
|
|
jobject obj,
|
2017-12-26 21:22:42 +00:00
|
|
|
jstring path,
|
|
|
|
jboolean wait);
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jint slot);
|
2017-12-25 12:50:29 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadStateAs(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring path);
|
2017-09-09 09:27:24 +00:00
|
|
|
JNIEXPORT void JNICALL
|
2018-09-14 04:46:30 +00:00
|
|
|
Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_CreateUserDirectories(JNIEnv* env,
|
|
|
|
jobject obj);
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(
|
|
|
|
JNIEnv* env, jobject obj, jstring jDirectory);
|
|
|
|
JNIEXPORT jstring JNICALL
|
|
|
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv* env, jobject obj);
|
2017-06-05 00:29:56 +00:00
|
|
|
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
|
|
|
|
jobject obj);
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jboolean enable);
|
|
|
|
JNIEXPORT void JNICALL
|
|
|
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env, jobject obj);
|
2018-08-26 22:27:27 +00:00
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Z(
|
|
|
|
JNIEnv* env, jobject obj, jstring jFile, jboolean jfirstOpen);
|
2018-08-26 22:27:27 +00:00
|
|
|
|
2017-12-26 21:08:44 +00:00
|
|
|
JNIEXPORT void JNICALL
|
2017-12-28 09:13:53 +00:00
|
|
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2Z(
|
|
|
|
JNIEnv* env, jobject obj, jstring jFile, jstring jSavestate, jboolean jDeleteSavestate);
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChanged(JNIEnv* env,
|
|
|
|
jobject obj,
|
2017-05-18 23:33:44 +00:00
|
|
|
jobject surf);
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv* env,
|
|
|
|
jobject obj);
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
2017-02-05 12:39:58 +00:00
|
|
|
Core::SetState(Core::State::Running);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
2017-02-05 12:39:58 +00:00
|
|
|
Core::SetState(Core::State::Paused);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
|
|
|
Core::Stop();
|
2017-05-18 23:33:44 +00:00
|
|
|
s_update_main_frame_event.Set(); // Kick the waiting event
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2017-12-25 12:57:31 +00:00
|
|
|
|
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
|
|
|
return Core::IsRunning();
|
|
|
|
}
|
|
|
|
|
2018-01-21 00:31:53 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring jFile);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
|
|
|
|
JNIEnv* env, jobject obj, jstring jDevice, jint Button, jint Action)
|
|
|
|
{
|
|
|
|
return ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);
|
|
|
|
}
|
2017-12-25 12:57:31 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
|
|
|
|
JNIEnv* env, jobject obj, jstring jDevice, jint Axis, jfloat Value)
|
|
|
|
{
|
|
|
|
ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
|
|
|
|
jobject obj)
|
2013-06-23 03:54:28 +00:00
|
|
|
{
|
2018-06-01 07:36:29 +00:00
|
|
|
return ToJString(env, Common::scm_rev_str.c_str());
|
2013-06-23 03:54:28 +00:00
|
|
|
}
|
2013-11-15 20:17:47 +00:00
|
|
|
|
2017-09-10 06:43:12 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
2018-06-01 07:36:29 +00:00
|
|
|
return ToJString(env, Common::scm_rev_git_str.c_str());
|
2017-09-10 06:43:12 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env,
|
|
|
|
jobject obj)
|
2013-11-15 23:32:50 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
|
|
|
Core::SaveScreenShot();
|
2013-11-15 23:32:50 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jint api)
|
2014-02-11 06:16:21 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
eglBindAPI(api);
|
2014-02-11 06:16:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-16 18:47:52 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InitGameIni(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring jGameID)
|
|
|
|
{
|
|
|
|
// Initialize an empty INI file
|
|
|
|
IniFile ini;
|
|
|
|
std::string gameid = GetJString(env, jGameID);
|
|
|
|
|
|
|
|
__android_log_print(ANDROID_LOG_DEBUG, "InitGameIni", "Initializing base game config file");
|
|
|
|
ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + gameid + ".ini");
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserSetting(
|
|
|
|
JNIEnv* env, jobject obj, jstring jGameID, jstring jSection, jstring jKey)
|
|
|
|
{
|
|
|
|
IniFile ini;
|
|
|
|
std::string gameid = GetJString(env, jGameID);
|
|
|
|
std::string section = GetJString(env, jSection);
|
|
|
|
std::string key = GetJString(env, jKey);
|
|
|
|
|
|
|
|
ini = SConfig::GetInstance().LoadGameIni(gameid, 0);
|
|
|
|
std::string value;
|
|
|
|
|
|
|
|
ini.GetOrCreateSection(section)->Get(key, &value, "-1");
|
|
|
|
|
2018-06-01 07:36:29 +00:00
|
|
|
return ToJString(env, value.c_str());
|
2018-02-16 18:47:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 01:07:56 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadGameIniFile(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring jGameID)
|
|
|
|
{
|
|
|
|
std::string gameid = GetJString(env, jGameID);
|
|
|
|
s_ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + gameid + ".ini");
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveGameIniFile(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring jGameID)
|
|
|
|
{
|
|
|
|
std::string gameid = GetJString(env, jGameID);
|
|
|
|
s_ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + gameid + ".ini");
|
|
|
|
}
|
|
|
|
|
2018-02-16 18:47:52 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserSetting(
|
|
|
|
JNIEnv* env, jobject obj, jstring jGameID, jstring jSection, jstring jKey, jstring jValue)
|
|
|
|
{
|
|
|
|
std::string gameid = GetJString(env, jGameID);
|
|
|
|
std::string section = GetJString(env, jSection);
|
|
|
|
std::string key = GetJString(env, jKey);
|
|
|
|
std::string val = GetJString(env, jValue);
|
|
|
|
|
|
|
|
if (val != "-1")
|
|
|
|
{
|
2018-09-25 01:07:56 +00:00
|
|
|
s_ini.GetOrCreateSection(section)->Set(key, val);
|
2018-02-16 18:47:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-25 01:07:56 +00:00
|
|
|
s_ini.GetOrCreateSection(section)->Delete(key);
|
2018-02-16 18:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-26 22:27:27 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfileSetting(
|
|
|
|
JNIEnv* env, jobject obj, jstring jProfile, jstring jSection, jstring jKey, jstring jValue)
|
|
|
|
{
|
|
|
|
IniFile ini;
|
|
|
|
std::string profile = GetJString(env, jProfile);
|
|
|
|
std::string section = GetJString(env, jSection);
|
|
|
|
std::string key = GetJString(env, jKey);
|
|
|
|
std::string val = GetJString(env, jValue);
|
|
|
|
|
|
|
|
ini.Load(File::GetUserPath(D_CONFIG_IDX) + "Profiles/Wiimote/" + profile + ".ini");
|
|
|
|
|
|
|
|
if (val != "-1")
|
|
|
|
{
|
|
|
|
ini.GetOrCreateSection(section)->Set(key, val);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ini.GetOrCreateSection(section)->Delete(key);
|
|
|
|
}
|
|
|
|
|
2018-09-25 01:07:56 +00:00
|
|
|
ini.Save(File::GetUserPath(D_CONFIG_IDX) + "Profiles/Wiimote/" + profile + ".ini");
|
2018-08-26 22:27:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(
|
|
|
|
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
std::string file = GetJString(env, jFile);
|
|
|
|
std::string section = GetJString(env, jSection);
|
|
|
|
std::string key = GetJString(env, jKey);
|
|
|
|
std::string defaultValue = GetJString(env, jDefault);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
|
|
|
std::string value;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ini.GetOrCreateSection(section)->Get(key, &value, defaultValue);
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2018-06-01 07:36:29 +00:00
|
|
|
return ToJString(env, value.c_str());
|
2013-04-23 19:21:48 +00:00
|
|
|
}
|
2018-06-01 07:36:29 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(
|
|
|
|
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue)
|
2013-04-23 19:21:48 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
std::string file = GetJString(env, jFile);
|
|
|
|
std::string section = GetJString(env, jSection);
|
|
|
|
std::string key = GetJString(env, jKey);
|
|
|
|
std::string value = GetJString(env, jValue);
|
2013-06-18 12:09:20 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
2013-04-23 19:21:48 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ini.GetOrCreateSection(section)->Set(key, value);
|
|
|
|
ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
2013-04-23 19:21:48 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv* env,
|
|
|
|
jobject obj,
|
2017-12-26 21:22:42 +00:00
|
|
|
jint slot,
|
|
|
|
jboolean wait)
|
2013-08-29 22:47:50 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
2017-12-26 21:22:42 +00:00
|
|
|
State::Save(slot, wait);
|
2013-08-29 22:47:50 +00:00
|
|
|
}
|
|
|
|
|
2017-12-25 12:50:29 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveStateAs(JNIEnv* env,
|
|
|
|
jobject obj,
|
2017-12-26 21:22:42 +00:00
|
|
|
jstring path,
|
|
|
|
jboolean wait)
|
2017-12-25 12:50:29 +00:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
2017-12-26 21:22:42 +00:00
|
|
|
State::SaveAs(GetJString(env, path), wait);
|
2013-08-29 22:47:50 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jint slot)
|
2013-08-29 22:47:50 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
|
|
|
State::Load(slot);
|
2013-08-29 22:47:50 +00:00
|
|
|
}
|
|
|
|
|
2017-12-25 12:50:29 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadStateAs(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring path)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
|
|
|
State::LoadAs(GetJString(env, path));
|
|
|
|
}
|
|
|
|
|
2018-09-14 04:46:30 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_SetSysDirectory(
|
2017-09-09 09:27:24 +00:00
|
|
|
JNIEnv* env, jobject obj, jstring jPath)
|
|
|
|
{
|
|
|
|
const std::string path = GetJString(env, jPath);
|
|
|
|
File::SetSysDirectory(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL
|
2018-09-14 04:46:30 +00:00
|
|
|
Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_CreateUserDirectories(JNIEnv* env,
|
|
|
|
jobject obj)
|
2017-09-09 09:27:24 +00:00
|
|
|
{
|
|
|
|
UICommon::CreateDirectories();
|
2013-08-29 23:07:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(
|
|
|
|
JNIEnv* env, jobject obj, jstring jDirectory)
|
2015-02-25 09:23:42 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
2017-12-28 12:34:49 +00:00
|
|
|
UICommon::SetUserDirectory(GetJString(env, jDirectory));
|
2015-02-25 09:23:42 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv* env,
|
|
|
|
jobject obj)
|
2015-02-28 05:20:33 +00:00
|
|
|
{
|
2018-06-01 07:36:29 +00:00
|
|
|
return ToJString(env, File::GetUserPath(D_USER_IDX).c_str());
|
2015-02-28 05:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-04-15 14:23:48 +00:00
|
|
|
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
2018-06-15 12:11:18 +00:00
|
|
|
return static_cast<jint>(PowerPC::DefaultCPUCore());
|
2017-04-15 14:23:48 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jboolean enable)
|
2015-05-11 01:03:34 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
2017-02-05 12:39:58 +00:00
|
|
|
Core::SetState(Core::State::Paused);
|
2016-06-24 08:43:46 +00:00
|
|
|
JitInterface::ClearCache();
|
2018-08-27 15:15:24 +00:00
|
|
|
JitInterface::SetProfilingState(enable ? JitInterface::ProfilingState::Enabled :
|
|
|
|
JitInterface::ProfilingState::Disabled);
|
2017-02-05 12:39:58 +00:00
|
|
|
Core::SetState(Core::State::Running);
|
2015-05-11 01:03:34 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env,
|
|
|
|
jobject obj)
|
2015-05-11 01:03:34 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
|
|
|
std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt";
|
|
|
|
File::CreateFullPath(filename);
|
|
|
|
JitInterface::WriteProfileResults(filename);
|
2015-05-11 01:03:34 +00:00
|
|
|
}
|
|
|
|
|
2016-01-10 18:31:49 +00:00
|
|
|
// Surface Handling
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChanged(JNIEnv* env,
|
|
|
|
jobject obj,
|
2017-05-18 23:33:44 +00:00
|
|
|
jobject surf)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-18 23:33:44 +00:00
|
|
|
s_surf = ANativeWindow_fromSurface(env, surf);
|
|
|
|
if (s_surf == nullptr)
|
2016-06-24 08:43:46 +00:00
|
|
|
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "Error: Surface is null.");
|
|
|
|
|
2016-08-13 12:08:53 +00:00
|
|
|
if (g_renderer)
|
2017-05-18 23:33:44 +00:00
|
|
|
g_renderer->ChangeSurface(s_surf);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
2016-08-13 12:08:53 +00:00
|
|
|
if (g_renderer)
|
|
|
|
g_renderer->ChangeSurface(nullptr);
|
|
|
|
|
2017-05-18 23:33:44 +00:00
|
|
|
if (s_surf)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-18 23:33:44 +00:00
|
|
|
ANativeWindow_release(s_surf);
|
|
|
|
s_surf = nullptr;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-20 03:49:04 +00:00
|
|
|
|
|
|
|
JNIEXPORT jfloat JNICALL
|
|
|
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameAspectRatio(JNIEnv* env, jobject obj)
|
|
|
|
{
|
|
|
|
return g_renderer->CalculateDrawAspectRatio();
|
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimotes(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
|
|
|
WiimoteReal::Refresh();
|
|
|
|
}
|
|
|
|
|
2018-10-13 11:17:14 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadWiimoteConfig(JNIEnv* env,
|
|
|
|
jobject obj)
|
|
|
|
{
|
|
|
|
Wiimote::LoadConfig();
|
|
|
|
}
|
|
|
|
|
2019-01-22 12:45:02 +00:00
|
|
|
// Returns the scale factor for imgui rendering.
|
|
|
|
// Based on the scaledDensity of the device's display metrics.
|
|
|
|
static float GetRenderSurfaceScale(JNIEnv* env)
|
|
|
|
{
|
|
|
|
// NativeLibrary emulation_activity = NativeLibrary.getEmulationActivity();
|
|
|
|
jclass native_library_class = env->FindClass("org/dolphinemu/dolphinemu/NativeLibrary");
|
|
|
|
jmethodID get_emulation_activity_method =
|
|
|
|
env->GetStaticMethodID(native_library_class, "getEmulationActivity",
|
|
|
|
"()Lorg/dolphinemu/dolphinemu/activities/EmulationActivity;");
|
|
|
|
jobject emulation_activity =
|
|
|
|
env->CallStaticObjectMethod(native_library_class, get_emulation_activity_method);
|
|
|
|
|
|
|
|
// WindowManager window_manager = emulation_activity.getWindowManager();
|
|
|
|
jmethodID get_window_manager_method =
|
|
|
|
env->GetMethodID(env->GetObjectClass(emulation_activity), "getWindowManager",
|
|
|
|
"()Landroid/view/WindowManager;");
|
|
|
|
jobject window_manager = env->CallObjectMethod(emulation_activity, get_window_manager_method);
|
|
|
|
|
|
|
|
// Display display = window_manager.getDisplay();
|
|
|
|
jmethodID get_display_method = env->GetMethodID(env->GetObjectClass(window_manager),
|
|
|
|
"getDefaultDisplay", "()Landroid/view/Display;");
|
|
|
|
jobject display = env->CallObjectMethod(window_manager, get_display_method);
|
|
|
|
|
|
|
|
// DisplayMetrics metrics = new DisplayMetrics();
|
|
|
|
jclass display_metrics_class = env->FindClass("android/util/DisplayMetrics");
|
|
|
|
jmethodID display_metrics_constructor = env->GetMethodID(display_metrics_class, "<init>", "()V");
|
|
|
|
jobject metrics = env->NewObject(display_metrics_class, display_metrics_constructor);
|
|
|
|
|
|
|
|
// display.getMetrics(metrics);
|
|
|
|
jmethodID get_metrics_method = env->GetMethodID(env->GetObjectClass(display), "getMetrics",
|
|
|
|
"(Landroid/util/DisplayMetrics;)V");
|
|
|
|
env->CallVoidMethod(display, get_metrics_method, metrics);
|
|
|
|
|
|
|
|
// float scaled_density = metrics.scaledDensity;
|
|
|
|
jfieldID scaled_density_field =
|
|
|
|
env->GetFieldID(env->GetObjectClass(metrics), "scaledDensity", "F");
|
|
|
|
float scaled_density = env->GetFloatField(metrics, scaled_density_field);
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Using %f for render surface scale.",
|
|
|
|
scaled_density);
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
env->DeleteLocalRef(metrics);
|
|
|
|
return scaled_density;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Run(JNIEnv* env, const std::vector<std::string>& paths, bool first_open,
|
2018-08-19 21:38:29 +00:00
|
|
|
std::optional<std::string> savestate_path = {}, bool delete_savestate = false)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2018-12-25 12:33:22 +00:00
|
|
|
ASSERT(!paths.empty());
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", paths[0].c_str());
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2019-06-17 03:45:37 +00:00
|
|
|
Common::RegisterMsgAlertHandler(&MsgAlert);
|
2018-08-19 21:38:29 +00:00
|
|
|
Common::AndroidSetReportHandler(&ReportSend);
|
|
|
|
DolphinAnalytics::AndroidSetGetValFunc(&GetAnalyticValue);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
std::unique_lock<std::mutex> guard(s_host_identity_lock);
|
|
|
|
UICommon::Init();
|
|
|
|
|
2018-08-19 21:38:29 +00:00
|
|
|
if (first_open)
|
|
|
|
{
|
2019-06-23 17:26:07 +00:00
|
|
|
DolphinAnalytics::Instance().ReportDolphinStart(GetAnalyticValue("DEVICE_TYPE"));
|
2018-08-19 21:38:29 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
WiimoteReal::InitAdapterClass();
|
|
|
|
|
|
|
|
// No use running the loop when booting fails
|
|
|
|
s_have_wm_user_stop = false;
|
2018-12-25 12:33:22 +00:00
|
|
|
std::unique_ptr<BootParameters> boot = BootParameters::GenerateFromFile(paths, savestate_path);
|
2017-12-28 09:13:53 +00:00
|
|
|
boot->delete_savestate = delete_savestate;
|
2018-10-03 13:03:22 +00:00
|
|
|
WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf);
|
2019-01-22 12:45:02 +00:00
|
|
|
wsi.render_surface_scale = GetRenderSurfaceScale(env);
|
2018-10-03 13:03:22 +00:00
|
|
|
if (BootManager::BootCore(std::move(boot), wsi))
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2018-08-26 22:27:27 +00:00
|
|
|
ButtonManager::Init(SConfig::GetInstance().GetGameID());
|
2016-06-24 08:43:46 +00:00
|
|
|
static constexpr int TIMEOUT = 10000;
|
|
|
|
static constexpr int WAIT_STEP = 25;
|
|
|
|
int time_waited = 0;
|
|
|
|
// A Core::CORE_ERROR state would be helpful here.
|
|
|
|
while (!Core::IsRunning() && time_waited < TIMEOUT && !s_have_wm_user_stop)
|
|
|
|
{
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP));
|
|
|
|
time_waited += WAIT_STEP;
|
|
|
|
}
|
|
|
|
while (Core::IsRunning())
|
|
|
|
{
|
|
|
|
guard.unlock();
|
2017-05-18 23:33:44 +00:00
|
|
|
s_update_main_frame_event.Wait();
|
2016-06-24 08:43:46 +00:00
|
|
|
guard.lock();
|
|
|
|
Core::HostDispatchJobs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Core::Shutdown();
|
2018-10-09 14:26:31 +00:00
|
|
|
ButtonManager::Shutdown();
|
2016-06-24 08:43:46 +00:00
|
|
|
UICommon::Shutdown();
|
|
|
|
guard.unlock();
|
|
|
|
|
2017-05-18 23:33:44 +00:00
|
|
|
if (s_surf)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-18 23:33:44 +00:00
|
|
|
ANativeWindow_release(s_surf);
|
|
|
|
s_surf = nullptr;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2013-02-26 19:49:00 +00:00
|
|
|
}
|
2013-07-27 20:09:18 +00:00
|
|
|
|
2018-12-25 12:33:22 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2Z(
|
|
|
|
JNIEnv* env, jobject obj, jobjectArray jPaths, jboolean jfirstOpen)
|
2017-12-26 21:08:44 +00:00
|
|
|
{
|
2019-01-22 12:45:02 +00:00
|
|
|
Run(env, JStringArrayToVector(env, jPaths), jfirstOpen);
|
2017-12-26 21:08:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL
|
2018-12-25 12:33:22 +00:00
|
|
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2Ljava_lang_String_2Z(
|
|
|
|
JNIEnv* env, jobject obj, jobjectArray jPaths, jstring jSavestate, jboolean jDeleteSavestate)
|
2017-12-26 21:08:44 +00:00
|
|
|
{
|
2019-01-22 12:45:02 +00:00
|
|
|
Run(env, JStringArrayToVector(env, jPaths), false, GetJString(env, jSavestate), jDeleteSavestate);
|
2017-12-26 21:08:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-21 00:31:53 +00:00
|
|
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(JNIEnv* env,
|
|
|
|
jobject obj,
|
|
|
|
jstring jFile)
|
|
|
|
{
|
|
|
|
const std::string path = GetJString(env, jFile);
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Change Disc: %s", path.c_str());
|
|
|
|
Core::RunAsCPUThread([&path] { DVDInterface::ChangeDisc(path); });
|
|
|
|
}
|
|
|
|
|
2013-02-26 19:49:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|