summaryrefslogtreecommitdiff
path: root/Source/Android/jni/MainAndroid.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2019-01-31 22:43:59 +0100
committerGitHub <noreply@github.com>2019-01-31 22:43:59 +0100
commit9c38772301101c4cd0f2a7912c9314ce6492cb62 (patch)
tree1fb43ff765bf0822108b507e16ebead1b835bbcc /Source/Android/jni/MainAndroid.cpp
parent36cb7ba9eff37de5106ad8c054832536778b6e5f (diff)
parent3cc10dcaf9468504e3ff8e9a091cb36a9937afc7 (diff)
Merge pull request #7755 from zackhow/score
Android: Update touch pointer from thread.
Diffstat (limited to 'Source/Android/jni/MainAndroid.cpp')
-rw-r--r--Source/Android/jni/MainAndroid.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp
index 9ffa7d2b0d..bb148f6578 100644
--- a/Source/Android/jni/MainAndroid.cpp
+++ b/Source/Android/jni/MainAndroid.cpp
@@ -72,6 +72,22 @@ Common::Event s_update_main_frame_event;
bool s_have_wm_user_stop = false;
} // Anonymous namespace
+void UpdatePointer()
+{
+ // Update touch pointer
+ JNIEnv* env;
+ int get_env_status =
+ IDCache::GetJavaVM()->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
+
+ if (get_env_status == JNI_EDETACHED)
+ IDCache::GetJavaVM()->AttachCurrentThread(&env, nullptr);
+
+ env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetUpdateTouchPointer());
+
+ if (get_env_status == JNI_EDETACHED)
+ IDCache::GetJavaVM()->DetachCurrentThread();
+}
+
void Host_NotifyMapLoaded()
{
}
@@ -108,11 +124,8 @@ void Host_UpdateMainFrame()
void Host_RequestRenderWindowSize(int width, int height)
{
- // Update touch pointer
- JNIEnv* env;
- IDCache::GetJavaVM()->AttachCurrentThread(&env, nullptr);
- env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetUpdateTouchPointer());
- IDCache::GetJavaVM()->DetachCurrentThread();
+ std::thread jnicall(UpdatePointer);
+ jnicall.join();
}
bool Host_UINeedsControllerState()