summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/MainAndroid.cpp
diff options
context:
space:
mode:
authorRyan Houdek <ryan.houdek@codethink.co.uk>2014-03-14 16:20:44 -0500
committerRyan Houdek <ryan.houdek@codethink.co.uk>2014-03-15 12:09:49 -0500
commit7b86716c6558c060b56af32ff374a89400a4c6e9 (patch)
treee23d852f7b121e72fe9075a7efc3b67507cfbf77 /Source/Core/DolphinWX/MainAndroid.cpp
parent450bde27bb2d7a47335c9800d3a29e012c9d67e9 (diff)
Due to the removal of our char* IniFile setters/getters this broke Android build which relied on that.
Convert our C-strings to std::strings before using
Diffstat (limited to 'Source/Core/DolphinWX/MainAndroid.cpp')
-rw-r--r--Source/Core/DolphinWX/MainAndroid.cpp84
1 files changed, 38 insertions, 46 deletions
diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp
index d50438f083..4dbafd1ff5 100644
--- a/Source/Core/DolphinWX/MainAndroid.cpp
+++ b/Source/Core/DolphinWX/MainAndroid.cpp
@@ -218,11 +218,23 @@ std::string GetName(std::string filename)
return name;
}
+std::string GetJString(JNIEnv *env, jstring jstr)
+{
+ std::string result = "";
+ if (!jstr)
+ return result;
+
+ const char *s = env->GetStringUTFChars(jstr, nullptr);
+ result = s;
+ env->ReleaseStringUTFChars(jstr, s);
+ return result;
+}
#ifdef __cplusplus
extern "C"
{
#endif
+
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj)
{
PowerPC::Start();
@@ -247,40 +259,33 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onTouchAxisE
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Button, jint Action)
{
- const char *Device = env->GetStringUTFChars(jDevice, nullptr);
- std::string strDevice = std::string(Device);
- ButtonManager::GamepadEvent(strDevice, Button, Action);
- env->ReleaseStringUTFChars(jDevice, Device);
+ 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)
{
- const char *Device = env->GetStringUTFChars(jDevice, nullptr);
- std::string strDevice = std::string(Device);
- ButtonManager::GamepadAxisEvent(strDevice, Axis, Value);
- env->ReleaseStringUTFChars(jDevice, Device);
+ ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
}
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv *env, jobject obj, jstring jFile)
{
- const char *File = env->GetStringUTFChars(jFile, nullptr);
- jintArray Banner = env->NewIntArray(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT);
+ std::string file = GetJString(env, jFile);
u32 uBanner[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
- if (LoadBanner(File, uBanner))
+ jintArray Banner = env->NewIntArray(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT);
+
+ if (LoadBanner(file, uBanner))
{
env->SetIntArrayRegion(Banner, 0, DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT, (jint*)uBanner);
}
- env->ReleaseStringUTFChars(jFile, File);
return Banner;
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv *env, jobject obj, jstring jFile)
{
- const char *File = env->GetStringUTFChars(jFile, nullptr);
- std::string Name = GetName(File);
+ std::string file = GetJString(env, jFile);
+ std::string name = GetName(file);
m_names.clear();
m_volume_names.clear();
- env->ReleaseStringUTFChars(jFile, File);
- return env->NewStringUTF(Name.c_str());
+ return env->NewStringUTF(name.c_str());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv *env, jobject obj)
@@ -303,52 +308,39 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(J
eglBindAPI(api);
}
-JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jKey, jstring jValue, jstring jDefault)
+JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault)
{
IniFile ini;
- const char *File = env->GetStringUTFChars(jFile, nullptr);
- const char *Key = env->GetStringUTFChars(jKey, nullptr);
- const char *Value = env->GetStringUTFChars(jValue, nullptr);
- const char *Default = env->GetStringUTFChars(jDefault, nullptr);
+ 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));
+ ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
std::string value;
- ini.Get(Key, Value, &value, Default);
-
- env->ReleaseStringUTFChars(jFile, File);
- env->ReleaseStringUTFChars(jKey, Key);
- env->ReleaseStringUTFChars(jValue, Value);
- env->ReleaseStringUTFChars(jDefault, Default);
+ ini.Get(section, key, &value, defaultValue);
return env->NewStringUTF(value.c_str());
}
-JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jKey, jstring jValue, jstring jDefault)
+JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey,
+jstring jValue)
{
IniFile ini;
- const char *File = env->GetStringUTFChars(jFile, nullptr);
- const char *Key = env->GetStringUTFChars(jKey, nullptr);
- const char *Value = env->GetStringUTFChars(jValue, nullptr);
- const char *Default = env->GetStringUTFChars(jDefault, nullptr);
-
- ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(File));
+ 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.Set(Key, Value, Default);
- ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(File));
+ ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
- env->ReleaseStringUTFChars(jFile, File);
- env->ReleaseStringUTFChars(jKey, Key);
- env->ReleaseStringUTFChars(jValue, Value);
- env->ReleaseStringUTFChars(jDefault, Default);
+ ini.Set(section, key, value);
+ ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv *env, jobject obj, jstring jFile)
{
- const char *File = env->GetStringUTFChars(jFile, nullptr);
-
- g_filename = std::string(File);
-
- env->ReleaseStringUTFChars(jFile, File);
+ g_filename = GetJString(env, jFile);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetDimensions(JNIEnv *env, jobject obj, jint _width, jint _height)
{