diff options
author | 2012-06-27 00:30:29 -0700 | |
---|---|---|
committer | 2012-06-27 00:30:29 -0700 | |
commit | 1850551d6dcdeada1500bc310fa1d1cc56e0cab6 (patch) | |
tree | 8a3df2270faaf0a6e96bc6b66f679053f085dd6e /native/jni/src/proximity_info.cpp | |
parent | 2db27bcd06dc56f93ed92e056a7f7dc2e0e2dcf0 (diff) | |
parent | efb63246c2e5df29d62416d48f62e2b57b14de7c (diff) | |
download | latinime-1850551d6dcdeada1500bc310fa1d1cc56e0cab6.tar.gz latinime-1850551d6dcdeada1500bc310fa1d1cc56e0cab6.tar.xz latinime-1850551d6dcdeada1500bc310fa1d1cc56e0cab6.zip |
Merge "Change native functions' interface for gesture"
Diffstat (limited to 'native/jni/src/proximity_info.cpp')
-rw-r--r-- | native/jni/src/proximity_info.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp index 2ba244a7c..a4a641160 100644 --- a/native/jni/src/proximity_info.cpp +++ b/native/jni/src/proximity_info.cpp @@ -15,6 +15,7 @@ */ #include <assert.h> +#include <math.h> #include <stdio.h> #include <string> @@ -210,4 +211,25 @@ int ProximityInfo::getKeyIndex(const int c) const { } return mCodeToKeyIndex[baseLowerC]; } + +// TODO: [Staging] Optimize +void ProximityInfo::getCenters(int *centerXs, int *centerYs, int *codeToKeyIndex, + int *keyToCodeIndex, int *keyCount, int *keyWidth) const { + *keyCount = KEY_COUNT; + *keyWidth = sqrt((float)MOST_COMMON_KEY_WIDTH_SQUARE); + + for (int i = 0; i < KEY_COUNT; ++i) { + const int code = mKeyCharCodes[i]; + const int lowerCode = toBaseLowerCase(code); + centerXs[i] = mKeyXCoordinates[i] + mKeyWidths[i] / 2; + centerYs[i] = mKeyYCoordinates[i] + mKeyHeights[i] / 2; + codeToKeyIndex[code] = i; + if (code != lowerCode && lowerCode >= 0 && lowerCode <= MAX_CHAR_CODE) { + codeToKeyIndex[lowerCode] = i; + keyToCodeIndex[i] = lowerCode; + } else { + keyToCodeIndex[i] = code; + } + } +} } // namespace latinime |