Merge pull request #7726 from zackhow/rumfast
Android: Optimize rumble call
This commit is contained in:
commit
9340ddc7c9
|
@ -25,6 +25,8 @@ static jclass s_analytics_class;
|
||||||
static jmethodID s_send_analytics_report;
|
static jmethodID s_send_analytics_report;
|
||||||
static jmethodID s_get_analytics_value;
|
static jmethodID s_get_analytics_value;
|
||||||
|
|
||||||
|
static jmethodID s_do_rumble;
|
||||||
|
|
||||||
namespace IDCache
|
namespace IDCache
|
||||||
{
|
{
|
||||||
JavaVM* GetJavaVM()
|
JavaVM* GetJavaVM()
|
||||||
|
@ -86,6 +88,11 @@ jfieldID GetGameFileCachePointer()
|
||||||
return s_game_file_cache_pointer;
|
return s_game_file_cache_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jmethodID GetDoRumble()
|
||||||
|
{
|
||||||
|
return s_do_rumble;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace IDCache
|
} // namespace IDCache
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -104,8 +111,9 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||||
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
s_native_library_class = reinterpret_cast<jclass>(env->NewGlobalRef(native_library_class));
|
||||||
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
s_display_alert_msg = env->GetStaticMethodID(s_native_library_class, "displayAlertMsg",
|
||||||
"(Ljava/lang/String;Ljava/lang/String;Z)Z");
|
"(Ljava/lang/String;Ljava/lang/String;Z)Z");
|
||||||
|
s_do_rumble = env->GetStaticMethodID(s_native_library_class, "rumble", "(ID)V");
|
||||||
s_get_update_touch_pointer =
|
s_get_update_touch_pointer =
|
||||||
env->GetStaticMethodID(IDCache::GetNativeLibraryClass(), "updateTouchPointer", "()V");
|
env->GetStaticMethodID(s_native_library_class, "updateTouchPointer", "()V");
|
||||||
|
|
||||||
const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
|
const jclass game_file_class = env->FindClass("org/dolphinemu/dolphinemu/model/GameFile");
|
||||||
s_game_file_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_file_class));
|
s_game_file_class = reinterpret_cast<jclass>(env->NewGlobalRef(game_file_class));
|
||||||
|
|
|
@ -14,6 +14,7 @@ JavaVM* GetJavaVM();
|
||||||
|
|
||||||
jclass GetNativeLibraryClass();
|
jclass GetNativeLibraryClass();
|
||||||
jmethodID GetDisplayAlertMsg();
|
jmethodID GetDisplayAlertMsg();
|
||||||
|
jmethodID GetDoRumble();
|
||||||
jmethodID GetUpdateTouchPointer();
|
jmethodID GetUpdateTouchPointer();
|
||||||
|
|
||||||
jclass GetAnalyticsClass();
|
jclass GetAnalyticsClass();
|
||||||
|
|
|
@ -239,9 +239,7 @@ void Touchscreen::Motor::Rumble(int padID, double state)
|
||||||
{
|
{
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
IDCache::GetJavaVM()->AttachCurrentThread(&env, nullptr);
|
IDCache::GetJavaVM()->AttachCurrentThread(&env, nullptr);
|
||||||
jmethodID rumbleMethod =
|
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetDoRumble(), padID, state);
|
||||||
env->GetStaticMethodID(IDCache::GetNativeLibraryClass(), "rumble", "(ID)V");
|
|
||||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), rumbleMethod, padID, state);
|
|
||||||
IDCache::GetJavaVM()->DetachCurrentThread();
|
IDCache::GetJavaVM()->DetachCurrentThread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue