mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 12:19:12 +00:00
[Android] Gamepad input. Refactor JNI native functions to all pull from a single class instead of everywhere willy-nilly
This commit is contained in:
parent
a518a1cbdc
commit
7223778520
19 changed files with 946 additions and 395 deletions
|
@ -200,26 +200,39 @@ std::string GetName(std::string filename)
|
|||
extern "C"
|
||||
{
|
||||
#endif
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_UnPauseEmulation(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj)
|
||||
{
|
||||
PowerPC::Start();
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_PauseEmulation(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv *env, jobject obj)
|
||||
{
|
||||
PowerPC::Pause();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_StopEmulation(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv *env, jobject obj)
|
||||
{
|
||||
PowerPC::Stop();
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_onTouchEvent(JNIEnv *env, jobject obj, jint Action, jfloat X, jfloat Y)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onTouchEvent(JNIEnv *env, jobject obj, jint Action, jfloat X, jfloat Y)
|
||||
{
|
||||
ButtonManager::TouchEvent(Action, X, Y);
|
||||
}
|
||||
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, NULL);
|
||||
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)
|
||||
{
|
||||
const char *Device = env->GetStringUTFChars(jDevice, NULL);
|
||||
std::string strDevice = std::string(Device);
|
||||
ButtonManager::GamepadAxisEvent(strDevice, Axis, Value);
|
||||
env->ReleaseStringUTFChars(jDevice, Device);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_GameListItem_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, NULL);
|
||||
jintArray Banner = env->NewIntArray(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT);
|
||||
|
@ -231,7 +244,7 @@ JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_GameListItem_GetBanne
|
|||
env->ReleaseStringUTFChars(jFile, File);
|
||||
return Banner;
|
||||
}
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_GameListItem_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, NULL);
|
||||
std::string Name = GetName(File);
|
||||
|
@ -241,41 +254,46 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_GameListItem_GetTitle(J
|
|||
env->ReleaseStringUTFChars(jFile, File);
|
||||
return env->NewStringUTF(Name.c_str());
|
||||
}
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_GameListView_GetConfig(JNIEnv *env, jobject obj, jstring jKey, jstring jValue, jstring jDefault)
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jKey, jstring jValue, jstring jDefault)
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
const char *File = env->GetStringUTFChars(jFile, NULL);
|
||||
const char *Key = env->GetStringUTFChars(jKey, NULL);
|
||||
const char *Value = env->GetStringUTFChars(jValue, NULL);
|
||||
const char *Default = env->GetStringUTFChars(jDefault, NULL);
|
||||
|
||||
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);
|
||||
|
||||
return env->NewStringUTF(value.c_str());
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_GameListView_SetConfig(JNIEnv *env, jobject obj, jstring jKey, jstring jValue, jstring jDefault)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jKey, jstring jValue, jstring jDefault)
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
const char *File = env->GetStringUTFChars(jFile, NULL);
|
||||
const char *Key = env->GetStringUTFChars(jKey, NULL);
|
||||
const char *Value = env->GetStringUTFChars(jValue, NULL);
|
||||
const char *Default = env->GetStringUTFChars(jDefault, NULL);
|
||||
|
||||
ini.Set(Key, Value, Default);
|
||||
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string(File));
|
||||
|
||||
ini.Set(Key, Value, Default);
|
||||
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_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height)
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height)
|
||||
{
|
||||
surf = ANativeWindow_fromSurface(env, _surf);
|
||||
g_width = (int)_width;
|
||||
|
@ -283,7 +301,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(J
|
|||
|
||||
// Install our callbacks
|
||||
OSD::AddCallback(OSD::OSD_INIT, OSDCallbacks, 0);
|
||||
OSD::AddCallback(OSD::OSD_ONFRAME, OSDCallbacks, 1);
|
||||
OSD::AddCallback(OSD::OSD_SHUTDOWN, OSDCallbacks, 2);
|
||||
|
||||
LogManager::Init();
|
||||
|
@ -292,6 +309,15 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(J
|
|||
VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend);
|
||||
WiimoteReal::LoadSettings();
|
||||
|
||||
// Load our Android specific settings
|
||||
IniFile ini;
|
||||
bool onscreencontrols = true;
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + std::string("Dolphin.ini"));
|
||||
ini.Get("Android", "ScreenControls", &onscreencontrols, true);
|
||||
|
||||
if (onscreencontrols)
|
||||
OSD::AddCallback(OSD::OSD_ONFRAME, OSDCallbacks, 1);
|
||||
|
||||
const char *File = env->GetStringUTFChars(jFile, NULL);
|
||||
// No use running the loop when booting fails
|
||||
if ( BootManager::BootCore( File ) )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue