Pass the touch position correction data to native.

Change-Id: I92958779377a530410d1682100f9d0a2ba267dea
diff --git a/native/src/defines_touch_position_correction.h b/native/src/defines_touch_position_correction.h
deleted file mode 100644
index 1229068..0000000
--- a/native/src/defines_touch_position_correction.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-**
-** Copyright 2011, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-#ifndef LATINIME_DEFINES_TOUCH_POSITION_CORRECTION_H
-#define LATINIME_DEFINES_TOUCH_POSITION_CORRECTION_H
-
-#define OUTER_SWEET_SPOT_RADIUS_RATIO 1.3
-
-static const char* TOUCH_POSITION_CORRECTION_GROUPS[] = {
-        "qwertyuiop",
-        "a",
-        "sdfghjk",
-        "l",
-        "zxcvbnm",
-};
-
-// (center X) / (key width)
-static const float RELATIVE_TOUCH_CENTER_X[] = {
-        0,          // qwertyuiop
-        -0.26871,   // a
-        0,          // sdfghjk
-        0.028050,   // l
-        0,          // zxcvbnm
-};
-
-// (center Y) / (key height)
-static const float RELATIVE_TOUCH_CENTER_Y[] = {
-        0.192088,   // qwertyuiop
-        0.214100,   // a
-        0.216640,   // sdfghjk
-        0.233288,   // l
-        0.286598,   // zxcvbnm
-};
-
-// (sweet spot radius) / ((key width) + (key height))
-static const float SWEET_SPOT_RADIUS[] = {
-        0.148955,   // qwertyuiop
-        0.185437,   // a
-        0.145522,   // sdfghjk
-        0.156882,   // l
-        0.144211,   // zxcvbnm
-};
-
-#define CORRECTION_GROUP_COUNT \
-    ((int)(sizeof(TOUCH_POSITION_CORRECTION_GROUPS) / sizeof(TOUCH_POSITION_CORRECTION_GROUPS[0])))
-
-#endif // LATINIME_DEFINES_TOUCH_POSITION_CORRECTION_H
diff --git a/native/src/proximity_info.cpp b/native/src/proximity_info.cpp
index 58842b9..4ff6e0a 100644
--- a/native/src/proximity_info.cpp
+++ b/native/src/proximity_info.cpp
@@ -20,7 +20,6 @@
 
 #define LOG_TAG "LatinIME: proximity_info.cpp"
 
-#include "defines_touch_position_correction.h"
 #include "dictionary.h"
 #include "proximity_info.h"
 
@@ -38,12 +37,13 @@
         const int keyboardHeight, const int gridWidth, const int gridHeight,
         const uint32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates,
         const int32_t *keyYCoordinates, const int32_t *keyWidths, const int32_t *keyHeights,
-        const int32_t *keyCharCodes, int themeId)
+        const int32_t *keyCharCodes, const float *sweetSpotCenterXs, const float *sweetSpotCenterYs,
+        const float *sweetSpotRadii)
         : MAX_PROXIMITY_CHARS_SIZE(maxProximityCharsSize), KEYBOARD_WIDTH(keyboardWidth),
           KEYBOARD_HEIGHT(keyboardHeight), GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight),
           CELL_WIDTH((keyboardWidth + gridWidth - 1) / gridWidth),
           CELL_HEIGHT((keyboardHeight + gridHeight - 1) / gridHeight),
-          KEY_COUNT(min(keyCount, MAX_KEY_COUNT_IN_A_KEYBOARD)), THEME_ID(themeId) {
+          KEY_COUNT(min(keyCount, MAX_KEY_COUNT_IN_A_KEYBOARD)) {
     const int len = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
     mProximityCharsArray = new uint32_t[len];
     if (DEBUG_PROXIMITY_INFO) {
@@ -56,33 +56,24 @@
     copyOrFillZero(mKeyWidths, keyWidths, KEY_COUNT * sizeof(mKeyWidths[0]));
     copyOrFillZero(mKeyHeights, keyHeights, KEY_COUNT * sizeof(mKeyHeights[0]));
     copyOrFillZero(mKeyCharCodes, keyCharCodes, KEY_COUNT * sizeof(mKeyCharCodes[0]));
+    copyOrFillZero(mSweetSpotCenterXs, sweetSpotCenterXs,
+            KEY_COUNT * sizeof(mSweetSpotCenterXs[0]));
+    copyOrFillZero(mSweetSpotCenterYs, sweetSpotCenterYs,
+            KEY_COUNT * sizeof(mSweetSpotCenterYs[0]));
+    copyOrFillZero(mSweetSpotRadii, sweetSpotRadii, KEY_COUNT * sizeof(mSweetSpotRadii[0]));
 
-    initializeCodeToGroup();
     initializeCodeToKeyIndex();
 }
 
-// Build the reversed look up table from the char code to the index in its group.
-// see TOUCH_POSITION_CORRECTION_GROUPS
-void ProximityInfo::initializeCodeToGroup() {
-    memset(mCodeToGroup, -1, (MAX_GROUPED_CHAR_CODE + 1) * sizeof(mCodeToGroup[0]));
-    for (int i = 0; i < CORRECTION_GROUP_COUNT; ++i) {
-        const char *group = TOUCH_POSITION_CORRECTION_GROUPS[i];
-        for (int j = 0; group[j]; ++j) {
-            const int code = group[j];
-            if (0 <= code && code <= MAX_GROUPED_CHAR_CODE)
-                mCodeToGroup[code] = i;
-        }
-    }
-}
-
 // Build the reversed look up table from the char code to the index in mKeyXCoordinates,
 // mKeyYCoordinates, mKeyWidths, mKeyHeights, mKeyCharCodes.
 void ProximityInfo::initializeCodeToKeyIndex() {
-    memset(mCodeToKeyIndex, -1, (MAX_GROUPED_CHAR_CODE + 1) * sizeof(mCodeToKeyIndex[0]));
+    memset(mCodeToKeyIndex, -1, (MAX_CHAR_CODE + 1) * sizeof(mCodeToKeyIndex[0]));
     for (int i = 0; i < KEY_COUNT; ++i) {
         const int code = mKeyCharCodes[i];
-        if (0 <= code && code <= MAX_GROUPED_CHAR_CODE)
+        if (0 <= code && code <= MAX_CHAR_CODE) {
             mCodeToKeyIndex[code] = i;
+        }
     }
 }
 
@@ -210,6 +201,6 @@
 }
 
 const int ProximityInfo::MAX_KEY_COUNT_IN_A_KEYBOARD;
-const int ProximityInfo::MAX_GROUPED_CHAR_CODE;
+const int ProximityInfo::MAX_CHAR_CODE;
 
 } // namespace latinime
diff --git a/native/src/proximity_info.h b/native/src/proximity_info.h
index 3190e73..b1e8236 100644
--- a/native/src/proximity_info.h
+++ b/native/src/proximity_info.h
@@ -37,7 +37,8 @@
             const int keybaordHeight, const int gridWidth, const int gridHeight,
             const uint32_t *proximityCharsArray, const int keyCount, const int32_t *keyXCoordinates,
             const int32_t *keyYCoordinates, const int32_t *keyWidths, const int32_t *keyHeights,
-            const int32_t *keyCharCodes, int themeId);
+            const int32_t *keyCharCodes, const float *sweetSpotCenterXs,
+            const float *sweetSpotCenterYs, const float *sweetSpotRadii);
     ~ProximityInfo();
     bool hasSpaceProximity(const int x, const int y) const;
     void setInputParams(const int* inputCodes, const int inputLength);
@@ -55,11 +56,10 @@
 private:
     // The max number of the keys in one keyboard layout
     static const int MAX_KEY_COUNT_IN_A_KEYBOARD = 64;
-    // The upper limit of the char code in TOUCH_POSITION_CORRECTION_GROUP
-    static const int MAX_GROUPED_CHAR_CODE = 127;
+    // The upper limit of the char code in mCodeToKeyIndex
+    static const int MAX_CHAR_CODE = 127;
 
     int getStartIndexFromCoordinates(const int x, const int y) const;
-    void initializeCodeToGroup();
     void initializeCodeToKeyIndex();
     const int MAX_PROXIMITY_CHARS_SIZE;
     const int KEYBOARD_WIDTH;
@@ -69,7 +69,6 @@
     const int CELL_WIDTH;
     const int CELL_HEIGHT;
     const int KEY_COUNT;
-    const int THEME_ID;
     const int *mInputCodes;
     uint32_t *mProximityCharsArray;
     int32_t mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
@@ -77,10 +76,12 @@
     int32_t mKeyWidths[MAX_KEY_COUNT_IN_A_KEYBOARD];
     int32_t mKeyHeights[MAX_KEY_COUNT_IN_A_KEYBOARD];
     int32_t mKeyCharCodes[MAX_KEY_COUNT_IN_A_KEYBOARD];
+    float mSweetSpotCenterXs[MAX_KEY_COUNT_IN_A_KEYBOARD];
+    float mSweetSpotCenterYs[MAX_KEY_COUNT_IN_A_KEYBOARD];
+    float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD];
     int mInputLength;
     unsigned short mPrimaryInputWord[MAX_WORD_LENGTH_INTERNAL];
-    int mCodeToGroup[MAX_GROUPED_CHAR_CODE + 1];
-    int mCodeToKeyIndex[MAX_GROUPED_CHAR_CODE + 1];
+    int mCodeToKeyIndex[MAX_CHAR_CODE + 1];
 };
 
 } // namespace latinime