Android: more separate-mouse-and-touch work.

This avoids a hint lookup for each mouse event we get by setting a static Java
variable from native code during our hint watcher callback.

Also attempts to do the right thing with mouse buttons if you happen to be
on an API14 (Ice Cream Sandwich, Android 4.0) or later device. We still
target API12 (Honeycomb MR1, Android 3.1) for SDL 2.0.4 though.

This isn't tested, so I'm pushing to see what the Android buildbot says. Stand
back, I'm a professional!
This commit is contained in:
Ryan C. Gordon
2015-04-01 12:14:56 -04:00
parent 236deab49b
commit f9041771d5
2 changed files with 18 additions and 4 deletions

View File

@@ -57,6 +57,9 @@ SeparateEventsHintWatcher(void *userdata, const char *name,
const char *oldValue, const char *newValue)
{
separate_mouse_and_touch = (newValue && (SDL_strcmp(newValue, "1") == 0));
JNIEnv *env = Android_JNI_GetEnv();
jfieldID fid = (*env)->GetStaticFieldID(env, mActivityClass, "mSeparateMouseAndTouch", "Z");
(*env)->SetStaticBooleanField(env, mActivityClass, fid, separate_mouse_and_touch ? JNI_TRUE : JNI_FALSE);
}
void Android_InitTouch(void)