mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-10-06 08:09:20 +00:00
Merge remote-tracking branch 'upstream/master' into merge-upstream
# Conflicts: # CMakeLists.txt # CMakeSettings.json # Data/Sys/GameSettings/GLR.ini # Data/Sys/GameSettings/HA9.ini # Data/Sys/GameSettings/MB3.ini # Data/Sys/GameSettings/MBA.ini # Data/Sys/GameSettings/MCV.ini # Data/Sys/GameSettings/MCY.ini # Data/Sys/GameSettings/NAK.ini # Data/Sys/GameSettings/NAL.ini # Data/Sys/GameSettings/NAT.ini # Data/Sys/GameSettings/R8P.ini # Data/Sys/GameSettings/R9I.ini # Data/Sys/GameSettings/REF.ini # Data/Sys/GameSettings/RES.ini # Data/Sys/GameSettings/RMHE08.ini # Data/Sys/GameSettings/RMHP08.ini # Data/Sys/GameSettings/SE2.ini # Data/Sys/GameSettings/WW2.ini # Data/Sys/GameSettings/WW3.ini # Data/Sys/GameSettings/WWI.ini # Externals/Bochs_disasm/Bochs_disasm.vcxproj # Externals/FreeSurround/FreeSurround.vcxproj # Externals/LZO/LZO.vcxproj # Externals/SFML/build/vc2010/SFML_Network.vcxproj # Externals/bzip2/bzip2.vcxproj # Externals/cpp-optparse/cpp-optparse.vcxproj # Externals/cubeb/msvc/cubeb.vcxproj # Externals/curl/curl.vcxproj # Externals/curl/lib/CMakeLists.txt # Externals/discord-rpc/src/discord-rpc.vcxproj # Externals/ed25519/ed25519.vcxproj # Externals/enet/enet.vcxproj # Externals/glslang/glslang.vcxproj # Externals/imgui/imgui.vcxproj # Externals/liblzma/liblzma.vcxproj # Externals/libpng/png/png.vcxproj # Externals/libusb/libusb_static_2013.vcxproj # Externals/mbedtls/mbedTLS.vcxproj # Externals/miniupnpc/miniupnpc.vcxproj # Externals/minizip/minizip.vcxproj # Externals/picojson/picojson.vcxproj # Externals/pugixml/pugixml.vcxproj # Externals/soundtouch/SoundTouch.vcxproj # Externals/xxhash/xxhash.vcxproj # Externals/zlib/zlib.vcxproj # Externals/zstd/zstd.vcxproj # Languages/Languages.vcxproj # Source/Android/jni/MainAndroid.cpp # Source/Core/AudioCommon/AudioCommon.vcxproj # Source/Core/Common/Common.vcxproj # Source/Core/Common/Common.vcxproj.filters # Source/Core/Common/Logging/Log.h # Source/Core/Common/StringUtil.cpp # Source/Core/Core/CMakeLists.txt # Source/Core/Core/ConfigManager.cpp # Source/Core/Core/ConfigManager.h # Source/Core/Core/Core.vcxproj # Source/Core/Core/Core.vcxproj.filters # Source/Core/Core/HotkeyManager.cpp # Source/Core/Core/State.cpp # Source/Core/DiscIO/DiscIO.vcxproj # Source/Core/DolphinNoGUI/DolphinNoGUI.vcxproj # Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp # Source/Core/DolphinQt/DolphinQt.vcxproj # Source/Core/InputCommon/InputCommon.vcxproj # Source/Core/InputCommon/InputCommon.vcxproj.filters # Source/Core/UICommon/UICommon.vcxproj # Source/Core/UpdaterCommon/UpdaterCommon.vcxproj # Source/Core/VideoBackends/D3D/D3D.vcxproj # Source/Core/VideoBackends/D3D12/D3D12.vcxproj # Source/Core/VideoBackends/D3DCommon/D3DCommon.vcxproj # Source/Core/VideoBackends/Null/Null.vcxproj # Source/Core/VideoBackends/OGL/OGL.vcxproj # Source/Core/VideoBackends/Software/Software.vcxproj # Source/Core/VideoBackends/Vulkan/Vulkan.vcxproj # Source/Core/VideoCommon/OnScreenDisplay.cpp # Source/Core/VideoCommon/OnScreenDisplay.h # Source/Core/VideoCommon/VideoCommon.vcxproj # Source/Core/WinUpdater/WinUpdater.vcxproj # Source/DSPTool/DSPTool.vcxproj # Source/PCH/pch.vcxproj # Source/UnitTests/UnitTests.vcxproj
This commit is contained in:
commit
24a62eec41
970 changed files with 99364 additions and 88078 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "Common/AndroidAnalytics.h"
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -26,6 +27,7 @@
|
|||
#include "Common/IniFile.h"
|
||||
#include "Common/Logging/LogManager.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/ScopeGuard.h"
|
||||
#include "Common/Version.h"
|
||||
#include "Common/WindowSystemInfo.h"
|
||||
|
||||
|
@ -45,11 +47,14 @@
|
|||
#include "Core/State.h"
|
||||
#include "Core/WiiUtils.h"
|
||||
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/ScrubbedBlob.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
#include "InputCommon/ControllerInterface/Android/Android.h"
|
||||
#include "InputCommon/ControllerInterface/Touch/ButtonManager.h"
|
||||
#include "InputCommon/GCAdapter.h"
|
||||
|
||||
#include "UICommon/UICommon.h"
|
||||
|
||||
|
@ -63,17 +68,23 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
static constexpr char DOLPHIN_TAG[] = "DolphinEmuNative";
|
||||
constexpr char DOLPHIN_TAG[] = "DolphinEmuNative";
|
||||
|
||||
ANativeWindow* s_surf;
|
||||
IniFile s_ini;
|
||||
|
||||
// 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;
|
||||
|
||||
// This exists to prevent surfaces from being destroyed during the boot process,
|
||||
// as that can lead to the boot process dereferencing nullptr.
|
||||
std::mutex s_surface_lock;
|
||||
bool s_need_nonblocking_alert_msg;
|
||||
|
||||
bool s_have_wm_user_stop = false;
|
||||
bool s_game_metadata_is_valid = false;
|
||||
} // Anonymous namespace
|
||||
|
||||
void UpdatePointer()
|
||||
|
@ -143,6 +154,10 @@ void Host_YieldToUI()
|
|||
|
||||
void Host_TitleChanged()
|
||||
{
|
||||
s_game_metadata_is_valid = true;
|
||||
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetOnTitleChanged());
|
||||
}
|
||||
|
||||
void Host_LowerWindow()
|
||||
|
@ -161,19 +176,20 @@ void Host_Fullscreen()
|
|||
{
|
||||
}
|
||||
|
||||
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType /*style*/)
|
||||
static bool MsgAlert(const char* caption, const char* text, bool yes_no, Common::MsgType style)
|
||||
{
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
|
||||
// Execute the Java method.
|
||||
jboolean result = env->CallStaticBooleanMethod(
|
||||
IDCache::GetNativeLibraryClass(), IDCache::GetDisplayAlertMsg(), ToJString(env, caption),
|
||||
ToJString(env, text), yes_no ? JNI_TRUE : JNI_FALSE);
|
||||
jboolean result =
|
||||
env->CallStaticBooleanMethod(IDCache::GetNativeLibraryClass(), IDCache::GetDisplayAlertMsg(),
|
||||
ToJString(env, caption), ToJString(env, text), yes_no,
|
||||
style == Common::MsgType::Warning, s_need_nonblocking_alert_msg);
|
||||
|
||||
return result != JNI_FALSE;
|
||||
}
|
||||
|
||||
static void ReportSend(std::string endpoint, std::string report)
|
||||
static void ReportSend(const std::string& endpoint, const std::string& report)
|
||||
{
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
|
||||
|
@ -185,11 +201,11 @@ static void ReportSend(std::string endpoint, std::string report)
|
|||
ToJString(env, endpoint), output_array);
|
||||
}
|
||||
|
||||
static std::string GetAnalyticValue(std::string key)
|
||||
static std::string GetAnalyticValue(const std::string& key)
|
||||
{
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
|
||||
jstring value = reinterpret_cast<jstring>(env->CallStaticObjectMethod(
|
||||
auto value = reinterpret_cast<jstring>(env->CallStaticObjectMethod(
|
||||
IDCache::GetAnalyticsClass(), IDCache::GetAnalyticsValue(), ToJString(env, key)));
|
||||
|
||||
std::string stdvalue = GetJString(env, value);
|
||||
|
@ -201,298 +217,89 @@ static std::string GetAnalyticValue(std::string key)
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
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);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_WaitUntilDoneBooting(JNIEnv* env, jobject obj);
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv* env,
|
||||
jobject obj);
|
||||
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 void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetMotionSensorsEnabled(
|
||||
JNIEnv* env, jobject obj, jboolean accelerometer_enabled, jboolean gyroscope_enabled);
|
||||
JNIEXPORT double JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetInputRadiusAtAngle(
|
||||
JNIEnv* env, jobject obj, int emu_pad_id, int stick, double angle);
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jobject obj);
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env,
|
||||
jobject obj);
|
||||
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,
|
||||
jint slot,
|
||||
jboolean wait);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveStateAs(JNIEnv* env,
|
||||
jobject obj,
|
||||
jstring path,
|
||||
jboolean wait);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv* env,
|
||||
jobject obj,
|
||||
jint slot);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadStateAs(JNIEnv* env,
|
||||
jobject obj,
|
||||
jstring path);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_CreateUserDirectories(JNIEnv* env,
|
||||
jobject obj);
|
||||
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);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetCacheDirectory(
|
||||
JNIEnv* env, jobject obj, jstring jDirectory);
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
|
||||
jobject obj);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env,
|
||||
jobject obj,
|
||||
jboolean enable);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Initialize(JNIEnv* env,
|
||||
jobject obj);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_ReportStartToAnalytics(JNIEnv* env, jobject obj);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env, jobject obj);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2(
|
||||
JNIEnv* env, jobject obj, jstring jFile);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2Z(
|
||||
JNIEnv* env, jobject obj, jstring jFile, jstring jSavestate, jboolean jDeleteSavestate);
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChanged(JNIEnv* env,
|
||||
jobject obj,
|
||||
jobject surf);
|
||||
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)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
Core::SetState(Core::State::Running);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv* env,
|
||||
jobject obj)
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv*, jclass)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
Core::SetState(Core::State::Paused);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv*, jclass)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
Core::Stop();
|
||||
s_update_main_frame_event.Set(); // Kick the waiting event
|
||||
|
||||
// Kick the waiting event
|
||||
s_update_main_frame_event.Set();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_WaitUntilDoneBooting(JNIEnv* env, jobject obj)
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv*, jclass)
|
||||
{
|
||||
Core::WaitUntilDoneBooting();
|
||||
return static_cast<jboolean>(Core::IsRunning());
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndStarted(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
return Core::IsRunning();
|
||||
return static_cast<jboolean>(Core::IsRunningAndStarted());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(JNIEnv* env,
|
||||
jobject obj,
|
||||
jstring jFile);
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(
|
||||
JNIEnv* env, jobject obj, jstring jDevice, jint Button, jint Action)
|
||||
JNIEnv* env, jclass, jstring jDevice, jint Button, jint Action)
|
||||
{
|
||||
return ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMoveEvent(
|
||||
JNIEnv* env, jobject obj, jstring jDevice, jint Axis, jfloat Value)
|
||||
JNIEnv* env, jclass, jstring jDevice, jint Axis, jfloat Value)
|
||||
{
|
||||
ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetMotionSensorsEnabled(
|
||||
JNIEnv* env, jobject obj, jboolean accelerometer_enabled, jboolean gyroscope_enabled)
|
||||
JNIEnv*, jclass, jboolean accelerometer_enabled, jboolean gyroscope_enabled)
|
||||
{
|
||||
ciface::Android::SetMotionSensorsEnabled(accelerometer_enabled, gyroscope_enabled);
|
||||
}
|
||||
|
||||
JNIEXPORT double JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetInputRadiusAtAngle(
|
||||
JNIEnv* env, jobject obj, int emu_pad_id, int stick, double angle)
|
||||
JNIEnv*, jclass, int emu_pad_id, int stick, double angle)
|
||||
{
|
||||
const auto casted_stick = static_cast<ButtonManager::ButtonType>(stick);
|
||||
return ButtonManager::GetInputRadiusAtAngle(emu_pad_id, casted_stick, angle);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env,
|
||||
jobject obj)
|
||||
jclass)
|
||||
{
|
||||
return ToJString(env, Common::scm_rev_str.c_str());
|
||||
return ToJString(env, Common::scm_rev_str);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGitRevision(JNIEnv* env,
|
||||
jobject obj)
|
||||
jclass)
|
||||
{
|
||||
return ToJString(env, Common::scm_rev_git_str.c_str());
|
||||
return ToJString(env, Common::scm_rev_git_str);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveScreenShot(JNIEnv*, jclass)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
Core::SaveScreenShot();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv* env,
|
||||
jobject obj,
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(JNIEnv*, jclass,
|
||||
jint api)
|
||||
{
|
||||
eglBindAPI(api);
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
return ToJString(env, value.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_NewGameIniFile(JNIEnv* env,
|
||||
jobject obj)
|
||||
{
|
||||
s_ini = IniFile();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
s_ini.GetOrCreateSection(section)->Set(key, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_ini.GetOrCreateSection(section)->Delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
ini.Save(File::GetUserPath(D_CONFIG_IDX) + "Profiles/Wiimote/" + profile + ".ini");
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(
|
||||
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault)
|
||||
{
|
||||
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);
|
||||
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||
std::string value;
|
||||
|
||||
ini.GetOrCreateSection(section)->Get(key, &value, defaultValue);
|
||||
|
||||
return ToJString(env, value.c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(
|
||||
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue)
|
||||
{
|
||||
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);
|
||||
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||
|
||||
ini.GetOrCreateSection(section)->Set(key, value);
|
||||
ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv* env,
|
||||
jobject obj,
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv*, jclass,
|
||||
jint slot,
|
||||
jboolean wait)
|
||||
{
|
||||
|
@ -500,8 +307,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JN
|
|||
State::Save(slot, wait);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveStateAs(JNIEnv* env,
|
||||
jobject obj,
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveStateAs(JNIEnv* env, jclass,
|
||||
jstring path,
|
||||
jboolean wait)
|
||||
{
|
||||
|
@ -509,64 +315,76 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveStateAs(
|
|||
State::SaveAs(GetJString(env, path), wait);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv* env,
|
||||
jobject obj,
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv*, jclass,
|
||||
jint slot)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
State::Load(slot);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadStateAs(JNIEnv* env,
|
||||
jobject obj,
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadStateAs(JNIEnv* env, jclass,
|
||||
jstring path)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
State::LoadAs(GetJString(env, path));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUnixTimeOfStateSlot(JNIEnv*, jclass, jint slot)
|
||||
{
|
||||
return static_cast<jlong>(State::GetUnixTimeOfSlot(slot));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_SetSysDirectory(
|
||||
JNIEnv* env, jobject obj, jstring jPath)
|
||||
JNIEnv* env, jclass, jstring jPath)
|
||||
{
|
||||
const std::string path = GetJString(env, jPath);
|
||||
File::SetSysDirectory(path);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_CreateUserDirectories(JNIEnv* env,
|
||||
jobject obj)
|
||||
Java_org_dolphinemu_dolphinemu_utils_DirectoryInitialization_CreateUserDirectories(JNIEnv*, jclass)
|
||||
{
|
||||
UICommon::CreateDirectories();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserDirectory(
|
||||
JNIEnv* env, jobject obj, jstring jDirectory)
|
||||
JNIEnv* env, jclass, jstring jDirectory)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
UICommon::SetUserDirectory(GetJString(env, jDirectory));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetUserDirectory(JNIEnv* env,
|
||||
jobject obj)
|
||||
jclass)
|
||||
{
|
||||
return ToJString(env, File::GetUserPath(D_USER_IDX).c_str());
|
||||
return ToJString(env, File::GetUserPath(D_USER_IDX));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetCacheDirectory(
|
||||
JNIEnv* env, jobject obj, jstring jDirectory)
|
||||
JNIEnv* env, jclass, jstring jDirectory)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
File::SetUserPath(D_CACHE_IDX, GetJString(env, jDirectory) + DIR_SEP);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_DefaultCPUCore(JNIEnv*, jclass)
|
||||
{
|
||||
return static_cast<jint>(PowerPC::DefaultCPUCore());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv* env,
|
||||
jobject obj,
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDefaultGraphicsBackendName(JNIEnv* env, jclass)
|
||||
{
|
||||
return ToJString(env, VideoBackendBase::GetDefaultBackendName());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetMaxLogLevel(JNIEnv*, jclass)
|
||||
{
|
||||
return static_cast<jint>(MAX_LOGLEVEL);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling(JNIEnv*, jclass,
|
||||
jboolean enable)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
|
@ -577,8 +395,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling
|
|||
Core::SetState(Core::State::Running);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt";
|
||||
|
@ -588,9 +406,11 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfile
|
|||
|
||||
// Surface Handling
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChanged(JNIEnv* env,
|
||||
jobject obj,
|
||||
jclass,
|
||||
jobject surf)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_surface_lock);
|
||||
|
||||
s_surf = ANativeWindow_fromSurface(env, surf);
|
||||
if (s_surf == nullptr)
|
||||
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "Error: Surface is null.");
|
||||
|
@ -599,9 +419,11 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChang
|
|||
g_renderer->ChangeSurface(s_surf);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_surface_lock);
|
||||
|
||||
if (g_renderer)
|
||||
g_renderer->ChangeSurface(nullptr);
|
||||
|
||||
|
@ -612,34 +434,44 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestr
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameAspectRatio(JNIEnv* env, jobject obj)
|
||||
JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameAspectRatio(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
return g_renderer->CalculateDrawAspectRatio();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimotes(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimotes(JNIEnv*, jclass)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_host_identity_lock);
|
||||
WiimoteReal::Refresh();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadWiimoteConfig(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadWiimoteConfig(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
WiimoteReal::LoadSettings();
|
||||
Wiimote::LoadConfig();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadConfig(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadConfig(JNIEnv*, jclass)
|
||||
{
|
||||
SConfig::GetInstance().LoadSettings();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Initialize(JNIEnv* env,
|
||||
jobject obj)
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_UpdateGCAdapterScanThread(JNIEnv*, jclass)
|
||||
{
|
||||
if (GCAdapter::UseAdapter())
|
||||
{
|
||||
GCAdapter::StartScanThread();
|
||||
}
|
||||
else
|
||||
{
|
||||
GCAdapter::StopScanThread();
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Initialize(JNIEnv*, jclass)
|
||||
{
|
||||
Common::RegisterMsgAlertHandler(&MsgAlert);
|
||||
Common::AndroidSetReportHandler(&ReportSend);
|
||||
|
@ -647,8 +479,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Initialize(J
|
|||
UICommon::Init();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_ReportStartToAnalytics(JNIEnv* env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReportStartToAnalytics(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
DolphinAnalytics::Instance().ReportDolphinStart(GetAnalyticValue("DEVICE_TYPE"));
|
||||
}
|
||||
|
@ -657,110 +489,94 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_ReportStartToAnalytics(JNIEnv* env,
|
|||
// 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;
|
||||
jmethodID get_render_surface_scale_method =
|
||||
env->GetStaticMethodID(native_library_class, "getRenderSurfaceScale", "()F");
|
||||
return env->CallStaticFloatMethod(native_library_class, get_render_surface_scale_method);
|
||||
}
|
||||
|
||||
static void Run(JNIEnv* env, const std::vector<std::string>& paths,
|
||||
std::optional<std::string> savestate_path = {}, bool delete_savestate = false)
|
||||
const std::optional<std::string>& savestate_path = {},
|
||||
bool delete_savestate = false)
|
||||
{
|
||||
ASSERT(!paths.empty());
|
||||
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", paths[0].c_str());
|
||||
|
||||
std::unique_lock<std::mutex> guard(s_host_identity_lock);
|
||||
std::unique_lock<std::mutex> host_identity_guard(s_host_identity_lock);
|
||||
|
||||
WiimoteReal::InitAdapterClass();
|
||||
|
||||
// No use running the loop when booting fails
|
||||
s_have_wm_user_stop = false;
|
||||
|
||||
std::unique_ptr<BootParameters> boot = BootParameters::GenerateFromFile(paths, savestate_path);
|
||||
boot->delete_savestate = delete_savestate;
|
||||
if (boot)
|
||||
boot->delete_savestate = delete_savestate;
|
||||
|
||||
WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf, s_surf);
|
||||
wsi.render_surface_scale = GetRenderSurfaceScale(env);
|
||||
if (BootManager::BootCore(std::move(boot), wsi))
|
||||
|
||||
s_need_nonblocking_alert_msg = true;
|
||||
std::unique_lock<std::mutex> surface_guard(s_surface_lock);
|
||||
|
||||
bool successful_boot = BootManager::BootCore(std::move(boot), wsi);
|
||||
if (successful_boot)
|
||||
{
|
||||
ButtonManager::Init(SConfig::GetInstance().GetGameID());
|
||||
|
||||
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)
|
||||
while (!Core::IsRunningAndStarted())
|
||||
{
|
||||
if (time_waited >= TIMEOUT || s_have_wm_user_stop)
|
||||
{
|
||||
successful_boot = false;
|
||||
break;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP));
|
||||
time_waited += WAIT_STEP;
|
||||
}
|
||||
while (Core::IsRunning())
|
||||
}
|
||||
|
||||
s_need_nonblocking_alert_msg = false;
|
||||
surface_guard.unlock();
|
||||
|
||||
if (successful_boot)
|
||||
{
|
||||
while (Core::IsRunningAndStarted())
|
||||
{
|
||||
guard.unlock();
|
||||
host_identity_guard.unlock();
|
||||
s_update_main_frame_event.Wait();
|
||||
guard.lock();
|
||||
host_identity_guard.lock();
|
||||
Core::HostDispatchJobs();
|
||||
}
|
||||
}
|
||||
|
||||
s_game_metadata_is_valid = false;
|
||||
Core::Shutdown();
|
||||
ButtonManager::Shutdown();
|
||||
guard.unlock();
|
||||
host_identity_guard.unlock();
|
||||
|
||||
if (s_surf)
|
||||
{
|
||||
ANativeWindow_release(s_surf);
|
||||
s_surf = nullptr;
|
||||
}
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(),
|
||||
IDCache::GetFinishEmulationActivity());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2(
|
||||
JNIEnv* env, jobject obj, jobjectArray jPaths)
|
||||
JNIEnv* env, jclass, jobjectArray jPaths)
|
||||
{
|
||||
Run(env, JStringArrayToVector(env, jPaths));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2Ljava_lang_String_2Z(
|
||||
JNIEnv* env, jobject obj, jobjectArray jPaths, jstring jSavestate, jboolean jDeleteSavestate)
|
||||
JNIEnv* env, jclass, jobjectArray jPaths, jstring jSavestate, jboolean jDeleteSavestate)
|
||||
{
|
||||
Run(env, JStringArrayToVector(env, jPaths), GetJString(env, jSavestate), jDeleteSavestate);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(JNIEnv* env,
|
||||
jobject obj,
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(JNIEnv* env, jclass,
|
||||
jstring jFile)
|
||||
{
|
||||
const std::string path = GetJString(env, jFile);
|
||||
|
@ -768,22 +584,145 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(J
|
|||
Core::RunAsCPUThread([&path] { DVDInterface::ChangeDisc(path); });
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetLogTypeNames(JNIEnv* env,
|
||||
jclass)
|
||||
{
|
||||
std::map<std::string, std::string> map = Common::Log::LogManager::GetInstance()->GetLogTypes();
|
||||
|
||||
auto map_size = static_cast<jsize>(map.size());
|
||||
jobject linked_hash_map =
|
||||
env->NewObject(IDCache::GetLinkedHashMapClass(), IDCache::GetLinkedHashMapInit(), map_size);
|
||||
for (const auto& entry : map)
|
||||
{
|
||||
env->CallObjectMethod(linked_hash_map, IDCache::GetLinkedHashMapPut(),
|
||||
ToJString(env, entry.first), ToJString(env, entry.second));
|
||||
}
|
||||
return linked_hash_map;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadLoggerConfig(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
Common::Log::LogManager::Init();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InstallWAD(JNIEnv* env,
|
||||
jobject obj,
|
||||
jclass,
|
||||
jstring jFile)
|
||||
{
|
||||
const std::string path = GetJString(env, jFile);
|
||||
return static_cast<jboolean>(WiiUtils::InstallWAD(path));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ConvertDiscImage(
|
||||
JNIEnv* env, jclass, jstring jInPath, jstring jOutPath, jint jPlatform, jint jFormat,
|
||||
jint jBlockSize, jint jCompression, jint jCompressionLevel, jboolean jScrub, jobject jCallback)
|
||||
{
|
||||
const std::string in_path = GetJString(env, jInPath);
|
||||
const std::string out_path = GetJString(env, jOutPath);
|
||||
const DiscIO::Platform platform = static_cast<DiscIO::Platform>(jPlatform);
|
||||
const DiscIO::BlobType format = static_cast<DiscIO::BlobType>(jFormat);
|
||||
const DiscIO::WIARVZCompressionType compression =
|
||||
static_cast<DiscIO::WIARVZCompressionType>(jCompression);
|
||||
const bool scrub = static_cast<bool>(jScrub);
|
||||
|
||||
std::unique_ptr<DiscIO::BlobReader> blob_reader;
|
||||
if (scrub)
|
||||
blob_reader = DiscIO::ScrubbedBlob::Create(in_path);
|
||||
else
|
||||
blob_reader = DiscIO::CreateBlobReader(in_path);
|
||||
|
||||
if (!blob_reader)
|
||||
return static_cast<jboolean>(false);
|
||||
|
||||
jobject jCallbackGlobal = env->NewGlobalRef(jCallback);
|
||||
Common::ScopeGuard scope_guard([jCallbackGlobal, env] { env->DeleteGlobalRef(jCallbackGlobal); });
|
||||
|
||||
const auto callback = [&jCallbackGlobal](const std::string& text, float completion) {
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
return static_cast<bool>(env->CallBooleanMethod(
|
||||
jCallbackGlobal, IDCache::GetCompressCallbackRun(), ToJString(env, text), completion));
|
||||
};
|
||||
|
||||
bool success = false;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case DiscIO::BlobType::PLAIN:
|
||||
success = DiscIO::ConvertToPlain(blob_reader.get(), in_path, out_path, callback);
|
||||
break;
|
||||
|
||||
case DiscIO::BlobType::GCZ:
|
||||
success =
|
||||
DiscIO::ConvertToGCZ(blob_reader.get(), in_path, out_path,
|
||||
platform == DiscIO::Platform::WiiDisc ? 1 : 0, jBlockSize, callback);
|
||||
break;
|
||||
|
||||
case DiscIO::BlobType::WIA:
|
||||
case DiscIO::BlobType::RVZ:
|
||||
success = DiscIO::ConvertToWIAOrRVZ(blob_reader.get(), in_path, out_path,
|
||||
format == DiscIO::BlobType::RVZ, compression,
|
||||
jCompressionLevel, jBlockSize, callback);
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return static_cast<jboolean>(success);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_FormatSize(JNIEnv* env,
|
||||
jobject obj,
|
||||
jclass,
|
||||
jlong bytes,
|
||||
jint decimals)
|
||||
{
|
||||
return ToJString(env, UICommon::FormatSize(bytes, decimals));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_SetObscuredPixelsLeft(JNIEnv*, jclass, jint width)
|
||||
{
|
||||
OSD::SetObscuredPixelsLeft(width);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_SetObscuredPixelsTop(JNIEnv*, jclass, jint height)
|
||||
{
|
||||
OSD::SetObscuredPixelsTop(height);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsGameMetadataValid(JNIEnv*,
|
||||
jclass)
|
||||
{
|
||||
return s_game_metadata_is_valid;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_IsEmulatingWiiUnchecked(JNIEnv*, jclass)
|
||||
{
|
||||
return SConfig::GetInstance().bWii;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCurrentGameIDUnchecked(JNIEnv* env, jclass)
|
||||
{
|
||||
return ToJString(env, SConfig::GetInstance().GetGameID());
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCurrentTitleDescriptionUnchecked(JNIEnv* env,
|
||||
jclass)
|
||||
{
|
||||
// Prefer showing just the name. If no name is available, show just the game ID.
|
||||
std::string description = SConfig::GetInstance().GetTitleName();
|
||||
if (description.empty())
|
||||
description = SConfig::GetInstance().GetTitleDescription();
|
||||
|
||||
return ToJString(env, description);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue