mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-15 08:49:20 +01:00
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
This commit is contained in:
parent
450bde27bb
commit
7b86716c65
@ -218,11 +218,23 @@ std::string GetName(std::string filename)
|
|||||||
return name;
|
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
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj)
|
||||||
{
|
{
|
||||||
PowerPC::Start();
|
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)
|
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);
|
ButtonManager::GamepadEvent(GetJString(env, jDevice), Button, Action);
|
||||||
std::string strDevice = std::string(Device);
|
|
||||||
ButtonManager::GamepadEvent(strDevice, Button, Action);
|
|
||||||
env->ReleaseStringUTFChars(jDevice, Device);
|
|
||||||
}
|
}
|
||||||
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_onGamePadMoveEvent(JNIEnv *env, jobject obj, jstring jDevice, jint Axis, jfloat Value)
|
||||||
{
|
{
|
||||||
const char *Device = env->GetStringUTFChars(jDevice, nullptr);
|
ButtonManager::GamepadAxisEvent(GetJString(env, jDevice), Axis, Value);
|
||||||
std::string strDevice = std::string(Device);
|
|
||||||
ButtonManager::GamepadAxisEvent(strDevice, Axis, Value);
|
|
||||||
env->ReleaseStringUTFChars(jDevice, Device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv *env, jobject obj, jstring jFile)
|
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv *env, jobject obj, jstring jFile)
|
||||||
{
|
{
|
||||||
const char *File = env->GetStringUTFChars(jFile, nullptr);
|
std::string file = GetJString(env, jFile);
|
||||||
jintArray Banner = env->NewIntArray(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT);
|
|
||||||
u32 uBanner[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
|
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->SetIntArrayRegion(Banner, 0, DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT, (jint*)uBanner);
|
||||||
}
|
}
|
||||||
env->ReleaseStringUTFChars(jFile, File);
|
|
||||||
return Banner;
|
return Banner;
|
||||||
}
|
}
|
||||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv *env, jobject obj, jstring jFile)
|
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv *env, jobject obj, jstring jFile)
|
||||||
{
|
{
|
||||||
const char *File = env->GetStringUTFChars(jFile, nullptr);
|
std::string file = GetJString(env, jFile);
|
||||||
std::string Name = GetName(File);
|
std::string name = GetName(file);
|
||||||
m_names.clear();
|
m_names.clear();
|
||||||
m_volume_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)
|
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);
|
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;
|
IniFile ini;
|
||||||
const char *File = env->GetStringUTFChars(jFile, nullptr);
|
std::string file = GetJString(env, jFile);
|
||||||
const char *Key = env->GetStringUTFChars(jKey, nullptr);
|
std::string section = GetJString(env, jSection);
|
||||||
const char *Value = env->GetStringUTFChars(jValue, nullptr);
|
std::string key = GetJString(env, jKey);
|
||||||
const char *Default = env->GetStringUTFChars(jDefault, nullptr);
|
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;
|
std::string value;
|
||||||
|
|
||||||
ini.Get(Key, Value, &value, Default);
|
ini.Get(section, key, &value, defaultValue);
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(jFile, File);
|
|
||||||
env->ReleaseStringUTFChars(jKey, Key);
|
|
||||||
env->ReleaseStringUTFChars(jValue, Value);
|
|
||||||
env->ReleaseStringUTFChars(jDefault, Default);
|
|
||||||
|
|
||||||
return env->NewStringUTF(value.c_str());
|
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;
|
IniFile ini;
|
||||||
const char *File = env->GetStringUTFChars(jFile, nullptr);
|
std::string file = GetJString(env, jFile);
|
||||||
const char *Key = env->GetStringUTFChars(jKey, nullptr);
|
std::string section = GetJString(env, jSection);
|
||||||
const char *Value = env->GetStringUTFChars(jValue, nullptr);
|
std::string key = GetJString(env, jKey);
|
||||||
const char *Default = env->GetStringUTFChars(jDefault, nullptr);
|
std::string value = GetJString(env, jValue);
|
||||||
|
|
||||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(File));
|
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||||
|
|
||||||
ini.Set(Key, Value, Default);
|
ini.Set(section, key, value);
|
||||||
ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(File));
|
ini.Save(File::GetUserPath(D_CONFIG_IDX) + std::string(file));
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(jFile, File);
|
|
||||||
env->ReleaseStringUTFChars(jKey, Key);
|
|
||||||
env->ReleaseStringUTFChars(jValue, Value);
|
|
||||||
env->ReleaseStringUTFChars(jDefault, Default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv *env, jobject obj, jstring jFile)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetFilename(JNIEnv *env, jobject obj, jstring jFile)
|
||||||
{
|
{
|
||||||
const char *File = env->GetStringUTFChars(jFile, nullptr);
|
g_filename = GetJString(env, jFile);
|
||||||
|
|
||||||
g_filename = std::string(File);
|
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(jFile, File);
|
|
||||||
}
|
}
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetDimensions(JNIEnv *env, jobject obj, jint _width, jint _height)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetDimensions(JNIEnv *env, jobject obj, jint _width, jint _height)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user