Pass the touch position correction data to native.
Change-Id: I92958779377a530410d1682100f9d0a2ba267dea
diff --git a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
index 07cee40..595ea2f 100644
--- a/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
+++ b/native/jni/com_android_inputmethod_keyboard_ProximityInfo.cpp
@@ -32,18 +32,27 @@
jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth,
jint gridHeight, jintArray proximityCharsArray, jint keyCount,
jintArray keyXCoordinateArray, jintArray keyYCoordinateArray, jintArray keyWidthArray,
- jintArray keyHeightArray, jintArray keyCharCodeArray, jint themeId) {
+ jintArray keyHeightArray, jintArray keyCharCodeArray,
+ jfloatArray sweetSpotCenterXArray, jfloatArray sweetSpotCenterYArray,
+ jfloatArray sweetSpotRadiusArray) {
jint *proximityChars = env->GetIntArrayElements(proximityCharsArray, NULL);
jint *keyXCoordinates = safeGetIntArrayElements(env, keyXCoordinateArray);
jint *keyYCoordinates = safeGetIntArrayElements(env, keyYCoordinateArray);
jint *keyWidths = safeGetIntArrayElements(env, keyWidthArray);
jint *keyHeights = safeGetIntArrayElements(env, keyHeightArray);
jint *keyCharCodes = safeGetIntArrayElements(env, keyCharCodeArray);
+ jfloat *sweetSpotCenterXs = safeGetFloatArrayElements(env, sweetSpotCenterXArray);
+ jfloat *sweetSpotCenterYs = safeGetFloatArrayElements(env, sweetSpotCenterYArray);
+ jfloat *sweetSpotRadii = safeGetFloatArrayElements(env, sweetSpotRadiusArray);
ProximityInfo *proximityInfo = new ProximityInfo(maxProximityCharsSize, displayWidth,
displayHeight, gridWidth, gridHeight, (const uint32_t*)proximityChars,
keyCount, (const int32_t*)keyXCoordinates, (const int32_t*)keyYCoordinates,
(const int32_t*)keyWidths, (const int32_t*)keyHeights, (const int32_t*)keyCharCodes,
- themeId);
+ (const float*)sweetSpotCenterXs, (const float*)sweetSpotCenterYs,
+ (const float*)sweetSpotRadii);
+ safeReleaseFloatArrayElements(env, sweetSpotRadiusArray, sweetSpotRadii);
+ safeReleaseFloatArrayElements(env, sweetSpotCenterYArray, sweetSpotCenterYs);
+ safeReleaseFloatArrayElements(env, sweetSpotCenterXArray, sweetSpotCenterXs);
safeReleaseIntArrayElements(env, keyCharCodeArray, keyCharCodes);
safeReleaseIntArrayElements(env, keyHeightArray, keyHeights);
safeReleaseIntArrayElements(env, keyWidthArray, keyWidths);
@@ -60,7 +69,8 @@
}
static JNINativeMethod sKeyboardMethods[] = {
- {"setProximityInfoNative", "(IIIII[II[I[I[I[I[II)I", (void*)latinime_Keyboard_setProximityInfo},
+ {"setProximityInfoNative", "(IIIII[II[I[I[I[I[I[F[F[F)I",
+ (void*)latinime_Keyboard_setProximityInfo},
{"releaseProximityInfoNative", "(I)V", (void*)latinime_Keyboard_release}
};
diff --git a/native/jni/jni_common.h b/native/jni/jni_common.h
index dbf6d3e..9548e1b 100644
--- a/native/jni/jni_common.h
+++ b/native/jni/jni_common.h
@@ -35,12 +35,26 @@
}
}
+inline jfloat *safeGetFloatArrayElements(JNIEnv *env, jfloatArray jArray) {
+ if (jArray) {
+ return env->GetFloatArrayElements(jArray, NULL);
+ } else {
+ return NULL;
+ }
+}
+
inline void safeReleaseIntArrayElements(JNIEnv *env, jintArray jArray, jint *cArray) {
if (jArray) {
env->ReleaseIntArrayElements(jArray, cArray, 0);
}
}
+inline void safeReleaseFloatArrayElements(JNIEnv *env, jfloatArray jArray, jfloat *cArray) {
+ if (jArray) {
+ env->ReleaseFloatArrayElements(jArray, cArray, 0);
+ }
+}
+
} // namespace latinime
#endif // LATINIME_JNI_COMMON_H