am 6c22439b: Remove MAX_PROXIMITY_CHARS_SIZE_INTERNAL
* commit '6c22439bf80da08576e86c1282afc5cfa431e235': Remove MAX_PROXIMITY_CHARS_SIZE_INTERNALmain
commit
8a3e8dca21
|
@ -30,8 +30,7 @@ public final class ProximityInfo {
|
||||||
private static final String TAG = ProximityInfo.class.getSimpleName();
|
private static final String TAG = ProximityInfo.class.getSimpleName();
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
/** MAX_PROXIMITY_CHARS_SIZE must be the same as MAX_PROXIMITY_CHARS_SIZE_INTERNAL
|
// Must be equal to MAX_PROXIMITY_CHARS_SIZE in native/jni/src/defines.h
|
||||||
* in defines.h */
|
|
||||||
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
|
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
|
||||||
/** Number of key widths from current touch point to search for nearest keys. */
|
/** Number of key widths from current touch point to search for nearest keys. */
|
||||||
private static final float SEARCH_DISTANCE = 1.2f;
|
private static final float SEARCH_DISTANCE = 1.2f;
|
||||||
|
@ -88,9 +87,13 @@ public final class ProximityInfo {
|
||||||
final int rowSize, final int gridWidth, final int gridHeight) {
|
final int rowSize, final int gridWidth, final int gridHeight) {
|
||||||
final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo();
|
final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo();
|
||||||
spellCheckerProximityInfo.mNativeProximityInfo =
|
spellCheckerProximityInfo.mNativeProximityInfo =
|
||||||
spellCheckerProximityInfo.setProximityInfoNative("",
|
spellCheckerProximityInfo.setProximityInfoNative("" /* locale */,
|
||||||
rowSize, gridWidth, gridHeight, gridWidth, gridHeight,
|
gridWidth /* displayWidth */, gridHeight /* displayHeight */,
|
||||||
1, proximityCharsArray, 0, null, null, null, null, null, null, null, null);
|
gridWidth, gridHeight, 1 /* mostCommonKeyWidth */, proximityCharsArray,
|
||||||
|
0 /* keyCount */, null /*keyXCoordinates */, null /* keyYCoordinates */,
|
||||||
|
null /* keyWidths */, null /* keyHeights */, null /* keyCharCodes */,
|
||||||
|
null /* sweetSpotCenterXs */, null /* sweetSpotCenterYs */,
|
||||||
|
null /* sweetSpotRadii */);
|
||||||
return spellCheckerProximityInfo;
|
return spellCheckerProximityInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,11 +103,11 @@ public final class ProximityInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Stop passing proximityCharsArray
|
// TODO: Stop passing proximityCharsArray
|
||||||
private static native long setProximityInfoNative(String locale, int maxProximityCharsSize,
|
private static native long setProximityInfoNative(String locale,
|
||||||
int displayWidth, int displayHeight, int gridWidth, int gridHeight,
|
int displayWidth, int displayHeight, int gridWidth, int gridHeight,
|
||||||
int mostCommonKeyWidth, int[] proximityCharsArray, int keyCount, int[] keyXCoordinates,
|
int mostCommonKeyWidth, int[] proximityCharsArray, int keyCount, int[] keyXCoordinates,
|
||||||
int[] keyYCoordinates, int[] keyWidths, int[] keyHeights, int[] keyCharCodes,
|
int[] keyYCoordinates, int[] keyWidths, int[] keyHeights, int[] keyCharCodes,
|
||||||
float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii);
|
float[] sweetSpotCenterXs, float[] sweetSpotCenterYs, float[] sweetSpotRadii);
|
||||||
|
|
||||||
private static native void releaseProximityInfoNative(long nativeProximityInfo);
|
private static native void releaseProximityInfoNative(long nativeProximityInfo);
|
||||||
|
|
||||||
|
@ -230,9 +233,9 @@ public final class ProximityInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Stop passing proximityCharsArray
|
// TODO: Stop passing proximityCharsArray
|
||||||
return setProximityInfoNative(mLocaleStr, MAX_PROXIMITY_CHARS_SIZE, mKeyboardMinWidth,
|
return setProximityInfoNative(mLocaleStr, mKeyboardMinWidth, mKeyboardHeight,
|
||||||
mKeyboardHeight, mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray,
|
mGridWidth, mGridHeight, mMostCommonKeyWidth, proximityCharsArray, keyCount,
|
||||||
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
||||||
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
public static final String DICTIONARY_PACK_AUTHORITY =
|
public static final String DICTIONARY_PACK_AUTHORITY =
|
||||||
"com.android.inputmethod.latin.dictionarypack";
|
"com.android.inputmethod.latin.dictionarypack";
|
||||||
|
|
||||||
// Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h
|
// Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
|
||||||
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
|
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
|
||||||
// Must be identical to MAX_RESULTS in native/jni/src/defines.h
|
// Must be equal to MAX_RESULTS in native/jni/src/defines.h
|
||||||
private static final int MAX_RESULTS = 18;
|
private static final int MAX_RESULTS = 18;
|
||||||
|
|
||||||
private long mNativeDict;
|
private long mNativeDict;
|
||||||
|
|
|
@ -127,7 +127,7 @@ public final class Constants {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Dictionary {
|
public static final class Dictionary {
|
||||||
// Must be identical to MAX_WORD_LENGTH in native/jni/src/defines.h
|
// Must be equal to MAX_WORD_LENGTH in native/jni/src/defines.h
|
||||||
public static final int MAX_WORD_LENGTH = 48;
|
public static final int MAX_WORD_LENGTH = 48;
|
||||||
|
|
||||||
private Dictionary() {
|
private Dictionary() {
|
||||||
|
|
|
@ -25,14 +25,14 @@
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
|
|
||||||
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz, jstring localeJStr,
|
static jlong latinime_Keyboard_setProximityInfo(JNIEnv *env, jclass clazz, jstring localeJStr,
|
||||||
jint maxProximityCharsSize, jint displayWidth, jint displayHeight, jint gridWidth,
|
jint displayWidth, jint displayHeight, jint gridWidth, jint gridHeight,
|
||||||
jint gridHeight, jint mostCommonkeyWidth, jintArray proximityChars, jint keyCount,
|
jint mostCommonkeyWidth, jintArray proximityChars, jint keyCount,
|
||||||
jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths,
|
jintArray keyXCoordinates, jintArray keyYCoordinates, jintArray keyWidths,
|
||||||
jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs,
|
jintArray keyHeights, jintArray keyCharCodes, jfloatArray sweetSpotCenterXs,
|
||||||
jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
|
jfloatArray sweetSpotCenterYs, jfloatArray sweetSpotRadii) {
|
||||||
ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, maxProximityCharsSize,
|
ProximityInfo *proximityInfo = new ProximityInfo(env, localeJStr, displayWidth, displayHeight,
|
||||||
displayWidth, displayHeight, gridWidth, gridHeight, mostCommonkeyWidth, proximityChars,
|
gridWidth, gridHeight, mostCommonkeyWidth, proximityChars, keyCount,
|
||||||
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
|
||||||
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
|
||||||
return reinterpret_cast<jlong>(proximityInfo);
|
return reinterpret_cast<jlong>(proximityInfo);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ static void latinime_Keyboard_release(JNIEnv *env, jclass clazz, jlong proximity
|
||||||
}
|
}
|
||||||
|
|
||||||
static JNINativeMethod sMethods[] = {
|
static JNINativeMethod sMethods[] = {
|
||||||
{"setProximityInfoNative", "(Ljava/lang/String;IIIIII[II[I[I[I[I[I[F[F[F)J",
|
{"setProximityInfoNative", "(Ljava/lang/String;IIIII[II[I[I[I[I[I[F[F[F)J",
|
||||||
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)},
|
reinterpret_cast<void *>(latinime_Keyboard_setProximityInfo)},
|
||||||
{"releaseProximityInfoNative", "(J)V", reinterpret_cast<void *>(latinime_Keyboard_release)}
|
{"releaseProximityInfoNative", "(J)V", reinterpret_cast<void *>(latinime_Keyboard_release)}
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,10 +28,13 @@
|
||||||
#define AK_FORCE_INLINE inline
|
#define AK_FORCE_INLINE inline
|
||||||
#endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
|
#endif // defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
|
||||||
|
|
||||||
// Must be identical to Constants.Dictionary.MAX_WORD_LENGTH in Java
|
// Must be equal to Constants.Dictionary.MAX_WORD_LENGTH in Java
|
||||||
#define MAX_WORD_LENGTH 48
|
#define MAX_WORD_LENGTH 48
|
||||||
// Must be identical to BinaryDictionary.MAX_RESULTS in Java
|
// Must be equal to BinaryDictionary.MAX_RESULTS in Java
|
||||||
#define MAX_RESULTS 18
|
#define MAX_RESULTS 18
|
||||||
|
// Must be equal to ProximityInfo.MAX_PROXIMITY_CHARS_SIZE in Java
|
||||||
|
#define MAX_PROXIMITY_CHARS_SIZE 16
|
||||||
|
#define ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE 2
|
||||||
|
|
||||||
#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
|
#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
@ -249,6 +252,7 @@ static inline void prof_out(void) {
|
||||||
#define S_INT_MIN (-2147483647 - 1) // -(1 << 31)
|
#define S_INT_MIN (-2147483647 - 1) // -(1 << 31)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define M_PI_F 3.14159265f
|
||||||
#define MAX_PERCENTILE 100
|
#define MAX_PERCENTILE 100
|
||||||
|
|
||||||
// Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator.
|
// Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator.
|
||||||
|
@ -325,12 +329,6 @@ static inline void prof_out(void) {
|
||||||
#define MAX_FREQ 255
|
#define MAX_FREQ 255
|
||||||
#define MAX_BIGRAM_FREQ 15
|
#define MAX_BIGRAM_FREQ 15
|
||||||
|
|
||||||
// This must be the same as ProximityInfo#MAX_PROXIMITY_CHARS_SIZE, currently it's 16.
|
|
||||||
#define MAX_PROXIMITY_CHARS_SIZE_INTERNAL 16
|
|
||||||
|
|
||||||
// This must be equal to ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE in KeyDetector.java
|
|
||||||
#define ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE 2
|
|
||||||
|
|
||||||
// Assuming locale strings such as en_US, sr-Latn etc.
|
// Assuming locale strings such as en_US, sr-Latn etc.
|
||||||
#define MAX_LOCALE_STRING_LENGTH 10
|
#define MAX_LOCALE_STRING_LENGTH 10
|
||||||
|
|
||||||
|
@ -395,8 +393,6 @@ static inline void prof_out(void) {
|
||||||
template<typename T> inline T min(T a, T b) { return a < b ? a : b; }
|
template<typename T> inline T min(T a, T b) { return a < b ? a : b; }
|
||||||
template<typename T> inline T max(T a, T b) { return a > b ? a : b; }
|
template<typename T> inline T max(T a, T b) { return a > b ? a : b; }
|
||||||
|
|
||||||
#define M_PI_F 3.14159265f
|
|
||||||
|
|
||||||
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
|
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
// The ratio of neutral area radius to sweet spot radius.
|
// The ratio of neutral area radius to sweet spot radius.
|
||||||
|
|
|
@ -47,15 +47,14 @@ static AK_FORCE_INLINE void safeGetOrFillZeroFloatArrayRegion(JNIEnv *env, jfloa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int maxProximityCharsSize,
|
ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr,
|
||||||
const int keyboardWidth, const int keyboardHeight, const int gridWidth,
|
const int keyboardWidth, const int keyboardHeight, const int gridWidth,
|
||||||
const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars,
|
const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars,
|
||||||
const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates,
|
const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates,
|
||||||
const jintArray keyWidths, const jintArray keyHeights, const jintArray keyCharCodes,
|
const jintArray keyWidths, const jintArray keyHeights, const jintArray keyCharCodes,
|
||||||
const jfloatArray sweetSpotCenterXs, const jfloatArray sweetSpotCenterYs,
|
const jfloatArray sweetSpotCenterXs, const jfloatArray sweetSpotCenterYs,
|
||||||
const jfloatArray sweetSpotRadii)
|
const jfloatArray sweetSpotRadii)
|
||||||
: MAX_PROXIMITY_CHARS_SIZE(maxProximityCharsSize), GRID_WIDTH(gridWidth),
|
: GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth),
|
||||||
GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth),
|
|
||||||
MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth),
|
MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth),
|
||||||
CELL_WIDTH((keyboardWidth + gridWidth - 1) / gridWidth),
|
CELL_WIDTH((keyboardWidth + gridWidth - 1) / gridWidth),
|
||||||
CELL_HEIGHT((keyboardHeight + gridHeight - 1) / gridHeight),
|
CELL_HEIGHT((keyboardHeight + gridHeight - 1) / gridHeight),
|
||||||
|
@ -65,11 +64,17 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int ma
|
||||||
&& keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs
|
&& keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs
|
||||||
&& sweetSpotCenterYs && sweetSpotRadii),
|
&& sweetSpotCenterYs && sweetSpotRadii),
|
||||||
mProximityCharsArray(new int[GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE
|
mProximityCharsArray(new int[GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE
|
||||||
/* proximityGridLength */]),
|
/* proximityCharsLength */]),
|
||||||
mCodeToKeyMap() {
|
mCodeToKeyMap() {
|
||||||
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
/* Let's check the input array length here to make sure */
|
||||||
|
const jsize proximityCharsLength = env->GetArrayLength(proximityChars);
|
||||||
|
if (proximityCharsLength != GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE) {
|
||||||
|
AKLOGE("Invalid proximityCharsLength: %d", proximityCharsLength);
|
||||||
|
ASSERT(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (DEBUG_PROXIMITY_INFO) {
|
if (DEBUG_PROXIMITY_INFO) {
|
||||||
AKLOGI("Create proximity info array %d", proximityGridLength);
|
AKLOGI("Create proximity info array %d", proximityCharsLength);
|
||||||
}
|
}
|
||||||
const jsize localeCStrUtf8Length = env->GetStringUTFLength(localeJStr);
|
const jsize localeCStrUtf8Length = env->GetStringUTFLength(localeJStr);
|
||||||
if (localeCStrUtf8Length >= MAX_LOCALE_STRING_LENGTH) {
|
if (localeCStrUtf8Length >= MAX_LOCALE_STRING_LENGTH) {
|
||||||
|
@ -78,7 +83,8 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int ma
|
||||||
}
|
}
|
||||||
memset(mLocaleStr, 0, sizeof(mLocaleStr));
|
memset(mLocaleStr, 0, sizeof(mLocaleStr));
|
||||||
env->GetStringUTFRegion(localeJStr, 0, env->GetStringLength(localeJStr), mLocaleStr);
|
env->GetStringUTFRegion(localeJStr, 0, env->GetStringLength(localeJStr), mLocaleStr);
|
||||||
safeGetOrFillZeroIntArrayRegion(env, proximityChars, proximityGridLength, mProximityCharsArray);
|
safeGetOrFillZeroIntArrayRegion(env, proximityChars, proximityCharsLength,
|
||||||
|
mProximityCharsArray);
|
||||||
safeGetOrFillZeroIntArrayRegion(env, keyXCoordinates, KEY_COUNT, mKeyXCoordinates);
|
safeGetOrFillZeroIntArrayRegion(env, keyXCoordinates, KEY_COUNT, mKeyXCoordinates);
|
||||||
safeGetOrFillZeroIntArrayRegion(env, keyYCoordinates, KEY_COUNT, mKeyYCoordinates);
|
safeGetOrFillZeroIntArrayRegion(env, keyYCoordinates, KEY_COUNT, mKeyYCoordinates);
|
||||||
safeGetOrFillZeroIntArrayRegion(env, keyWidths, KEY_COUNT, mKeyWidths);
|
safeGetOrFillZeroIntArrayRegion(env, keyWidths, KEY_COUNT, mKeyWidths);
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Correction;
|
||||||
|
|
||||||
class ProximityInfo {
|
class ProximityInfo {
|
||||||
public:
|
public:
|
||||||
ProximityInfo(JNIEnv *env, const jstring localeJStr, const int maxProximityCharsSize,
|
ProximityInfo(JNIEnv *env, const jstring localeJStr,
|
||||||
const int keyboardWidth, const int keyboardHeight, const int gridWidth,
|
const int keyboardWidth, const int keyboardHeight, const int gridWidth,
|
||||||
const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars,
|
const int gridHeight, const int mostCommonKeyWidth, const jintArray proximityChars,
|
||||||
const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates,
|
const int keyCount, const jintArray keyXCoordinates, const jintArray keyYCoordinates,
|
||||||
|
@ -126,7 +126,6 @@ class ProximityInfo {
|
||||||
float calculateNormalizedSquaredDistance(const int keyIndex, const int inputIndex) const;
|
float calculateNormalizedSquaredDistance(const int keyIndex, const int inputIndex) const;
|
||||||
bool hasInputCoordinates() const;
|
bool hasInputCoordinates() const;
|
||||||
|
|
||||||
const int MAX_PROXIMITY_CHARS_SIZE;
|
|
||||||
const int GRID_WIDTH;
|
const int GRID_WIDTH;
|
||||||
const int GRID_HEIGHT;
|
const int GRID_HEIGHT;
|
||||||
const int MOST_COMMON_KEY_WIDTH;
|
const int MOST_COMMON_KEY_WIDTH;
|
||||||
|
|
|
@ -208,7 +208,7 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
a += 0;
|
a += 0;
|
||||||
AKLOGI("--- Primary = %c, x = %d, y = %d", primaryKey, x, y);
|
AKLOGI("--- Primary = %c, x = %d, y = %d", primaryKey, x, y);
|
||||||
}
|
}
|
||||||
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL && proximityCodePoints[j] > 0;
|
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE && proximityCodePoints[j] > 0;
|
||||||
++j) {
|
++j) {
|
||||||
const int currentCodePoint = proximityCodePoints[j];
|
const int currentCodePoint = proximityCodePoints[j];
|
||||||
const float squaredDistance =
|
const float squaredDistance =
|
||||||
|
@ -216,10 +216,10 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
|
||||||
mProximityInfo->getKeyIndexOf(currentCodePoint), i) :
|
mProximityInfo->getKeyIndexOf(currentCodePoint), i) :
|
||||||
NOT_A_DISTANCE_FLOAT;
|
NOT_A_DISTANCE_FLOAT;
|
||||||
if (squaredDistance >= 0.0f) {
|
if (squaredDistance >= 0.0f) {
|
||||||
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] =
|
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE + j] =
|
||||||
(int) (squaredDistance * NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR);
|
(int) (squaredDistance * NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR);
|
||||||
} else {
|
} else {
|
||||||
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j] =
|
mNormalizedSquaredDistances[i * MAX_PROXIMITY_CHARS_SIZE + j] =
|
||||||
(j == 0) ? EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO :
|
(j == 0) ? EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO :
|
||||||
PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO;
|
PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ ProximityType ProximityInfoState::getMatchedProximityId(const int index, const i
|
||||||
|
|
||||||
// Not an exact nor an accent-alike match: search the list of close keys
|
// Not an exact nor an accent-alike match: search the list of close keys
|
||||||
int j = 1;
|
int j = 1;
|
||||||
while (j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL
|
while (j < MAX_PROXIMITY_CHARS_SIZE
|
||||||
&& currentCodePoints[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) {
|
&& currentCodePoints[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) {
|
||||||
const bool matched = (currentCodePoints[j] == baseLowerC || currentCodePoints[j] == c);
|
const bool matched = (currentCodePoints[j] == baseLowerC || currentCodePoints[j] == c);
|
||||||
if (matched) {
|
if (matched) {
|
||||||
|
@ -366,10 +366,10 @@ ProximityType ProximityInfoState::getMatchedProximityId(const int index, const i
|
||||||
}
|
}
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
if (j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL
|
if (j < MAX_PROXIMITY_CHARS_SIZE
|
||||||
&& currentCodePoints[j] == ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) {
|
&& currentCodePoints[j] == ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) {
|
||||||
++j;
|
++j;
|
||||||
while (j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL
|
while (j < MAX_PROXIMITY_CHARS_SIZE
|
||||||
&& currentCodePoints[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) {
|
&& currentCodePoints[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) {
|
||||||
const bool matched = (currentCodePoints[j] == baseLowerC || currentCodePoints[j] == c);
|
const bool matched = (currentCodePoints[j] == baseLowerC || currentCodePoints[j] == c);
|
||||||
if (matched) {
|
if (matched) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ class ProximityInfoState {
|
||||||
AK_FORCE_INLINE bool existsCodePointInProximityAt(const int index, const int c) const {
|
AK_FORCE_INLINE bool existsCodePointInProximityAt(const int index, const int c) const {
|
||||||
const int *codePoints = getProximityCodePointsAt(index);
|
const int *codePoints = getProximityCodePointsAt(index);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (codePoints[i] > 0 && i < MAX_PROXIMITY_CHARS_SIZE_INTERNAL) {
|
while (codePoints[i] > 0 && i < MAX_PROXIMITY_CHARS_SIZE) {
|
||||||
if (codePoints[i++] == c) {
|
if (codePoints[i++] == c) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class ProximityInfoState {
|
||||||
inline int getNormalizedSquaredDistance(
|
inline int getNormalizedSquaredDistance(
|
||||||
const int inputIndex, const int proximityIndex) const {
|
const int inputIndex, const int proximityIndex) const {
|
||||||
return mNormalizedSquaredDistances[
|
return mNormalizedSquaredDistances[
|
||||||
inputIndex * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + proximityIndex];
|
inputIndex * MAX_PROXIMITY_CHARS_SIZE + proximityIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const int *getPrimaryInputWord() const {
|
inline const int *getPrimaryInputWord() const {
|
||||||
|
@ -119,7 +119,7 @@ class ProximityInfoState {
|
||||||
if (*inputProximities != *word) {
|
if (*inputProximities != *word) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
inputProximities += MAX_PROXIMITY_CHARS_SIZE_INTERNAL;
|
inputProximities += MAX_PROXIMITY_CHARS_SIZE;
|
||||||
word++;
|
word++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -214,11 +214,6 @@ class ProximityInfoState {
|
||||||
float calculateSquaredDistanceFromSweetSpotCenter(
|
float calculateSquaredDistanceFromSweetSpotCenter(
|
||||||
const int keyIndex, const int inputIndex) const;
|
const int keyIndex, const int inputIndex) const;
|
||||||
|
|
||||||
bool pushTouchPoint(const int inputIndex, const int nodeCodePoint, int x, int y, const int time,
|
|
||||||
const bool sample, const bool isLastPoint, const float sumAngle,
|
|
||||||
NearKeysDistanceMap *const currentNearKeysDistances,
|
|
||||||
const NearKeysDistanceMap *const prevNearKeysDistances,
|
|
||||||
const NearKeysDistanceMap *const prevPrevNearKeysDistances);
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// Defined here //
|
// Defined here //
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
|
@ -284,8 +279,8 @@ class ProximityInfoState {
|
||||||
// inputs including the current input point.
|
// inputs including the current input point.
|
||||||
std::vector<NearKeycodesSet> mSearchKeysVector;
|
std::vector<NearKeycodesSet> mSearchKeysVector;
|
||||||
bool mTouchPositionCorrectionEnabled;
|
bool mTouchPositionCorrectionEnabled;
|
||||||
int mInputProximities[MAX_PROXIMITY_CHARS_SIZE_INTERNAL * MAX_WORD_LENGTH];
|
int mInputProximities[MAX_PROXIMITY_CHARS_SIZE * MAX_WORD_LENGTH];
|
||||||
int mNormalizedSquaredDistances[MAX_PROXIMITY_CHARS_SIZE_INTERNAL * MAX_WORD_LENGTH];
|
int mNormalizedSquaredDistances[MAX_PROXIMITY_CHARS_SIZE * MAX_WORD_LENGTH];
|
||||||
int mSampledInputSize;
|
int mSampledInputSize;
|
||||||
int mPrimaryInputWord[MAX_WORD_LENGTH];
|
int mPrimaryInputWord[MAX_WORD_LENGTH];
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "defines.h"
|
||||||
#include "geometry_utils.h"
|
#include "geometry_utils.h"
|
||||||
#include "proximity_info.h"
|
#include "proximity_info.h"
|
||||||
#include "proximity_info_params.h"
|
#include "proximity_info_params.h"
|
||||||
|
@ -24,13 +25,12 @@
|
||||||
namespace latinime {
|
namespace latinime {
|
||||||
/* static */ int ProximityInfoStateUtils::updateTouchPoints(const int mostCommonKeyWidth,
|
/* static */ int ProximityInfoStateUtils::updateTouchPoints(const int mostCommonKeyWidth,
|
||||||
const ProximityInfo *const proximityInfo, const int maxPointToKeyLength,
|
const ProximityInfo *const proximityInfo, const int maxPointToKeyLength,
|
||||||
const int *const inputProximities,
|
const int *const inputProximities, const int *const inputXCoordinates,
|
||||||
const int *const inputXCoordinates, const int *const inputYCoordinates,
|
const int *const inputYCoordinates, const int *const times, const int *const pointerIds,
|
||||||
const int *const times, const int *const pointerIds, const int inputSize,
|
const int inputSize, const bool isGeometric, const int pointerId,
|
||||||
const bool isGeometric, const int pointerId, const int pushTouchPointStartIndex,
|
const int pushTouchPointStartIndex, std::vector<int> *sampledInputXs,
|
||||||
std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs,
|
std::vector<int> *sampledInputYs, std::vector<int> *sampledInputTimes,
|
||||||
std::vector<int> *sampledInputTimes, std::vector<int> *sampledLengthCache,
|
std::vector<int> *sampledLengthCache, std::vector<int> *sampledInputIndice) {
|
||||||
std::vector<int> *sampledInputIndice) {
|
|
||||||
if (DEBUG_SAMPLING_POINTS) {
|
if (DEBUG_SAMPLING_POINTS) {
|
||||||
if (times) {
|
if (times) {
|
||||||
for (int i = 0; i < inputSize; ++i) {
|
for (int i = 0; i < inputSize; ++i) {
|
||||||
|
@ -94,7 +94,7 @@ namespace latinime {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pushTouchPoint(mostCommonKeyWidth, proximityInfo, maxPointToKeyLength,
|
if (pushTouchPoint(mostCommonKeyWidth, proximityInfo, maxPointToKeyLength,
|
||||||
i, c, x, y, time, isGeometric /* do sampling */,
|
i, c, x, y, time, isGeometric /* doSampling */,
|
||||||
i == lastInputIndex, sumAngle, currentNearKeysDistances,
|
i == lastInputIndex, sumAngle, currentNearKeysDistances,
|
||||||
prevNearKeysDistances, prevPrevNearKeysDistances,
|
prevNearKeysDistances, prevPrevNearKeysDistances,
|
||||||
sampledInputXs, sampledInputYs, sampledInputTimes, sampledLengthCache,
|
sampledInputXs, sampledInputYs, sampledInputTimes, sampledLengthCache,
|
||||||
|
@ -117,7 +117,7 @@ namespace latinime {
|
||||||
|
|
||||||
/* static */ const int *ProximityInfoStateUtils::getProximityCodePointsAt(
|
/* static */ const int *ProximityInfoStateUtils::getProximityCodePointsAt(
|
||||||
const int *const inputProximities, const int index) {
|
const int *const inputProximities, const int index) {
|
||||||
return inputProximities + (index * MAX_PROXIMITY_CHARS_SIZE_INTERNAL);
|
return inputProximities + (index * MAX_PROXIMITY_CHARS_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int ProximityInfoStateUtils::getPrimaryCodePointAt(
|
/* static */ int ProximityInfoStateUtils::getPrimaryCodePointAt(
|
||||||
|
@ -325,7 +325,7 @@ namespace latinime {
|
||||||
/* static */ bool ProximityInfoStateUtils::pushTouchPoint(const int mostCommonKeyWidth,
|
/* static */ bool ProximityInfoStateUtils::pushTouchPoint(const int mostCommonKeyWidth,
|
||||||
const ProximityInfo *const proximityInfo, const int maxPointToKeyLength,
|
const ProximityInfo *const proximityInfo, const int maxPointToKeyLength,
|
||||||
const int inputIndex, const int nodeCodePoint, int x, int y,
|
const int inputIndex, const int nodeCodePoint, int x, int y,
|
||||||
const int time, const bool sample, const bool isLastPoint, const float sumAngle,
|
const int time, const bool doSampling, const bool isLastPoint, const float sumAngle,
|
||||||
NearKeysDistanceMap *const currentNearKeysDistances,
|
NearKeysDistanceMap *const currentNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevNearKeysDistances,
|
const NearKeysDistanceMap *const prevNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevPrevNearKeysDistances,
|
const NearKeysDistanceMap *const prevPrevNearKeysDistances,
|
||||||
|
@ -336,7 +336,7 @@ namespace latinime {
|
||||||
|
|
||||||
size_t size = sampledInputXs->size();
|
size_t size = sampledInputXs->size();
|
||||||
bool popped = false;
|
bool popped = false;
|
||||||
if (nodeCodePoint < 0 && sample) {
|
if (nodeCodePoint < 0 && doSampling) {
|
||||||
const float nearest = updateNearKeysDistances(
|
const float nearest = updateNearKeysDistances(
|
||||||
proximityInfo, maxPointToKeyLength, x, y, currentNearKeysDistances);
|
proximityInfo, maxPointToKeyLength, x, y, currentNearKeysDistances);
|
||||||
const float score = getPointScore(mostCommonKeyWidth, x, y, time, isLastPoint, nearest,
|
const float score = getPointScore(mostCommonKeyWidth, x, y, time, isLastPoint, nearest,
|
||||||
|
|
|
@ -36,8 +36,7 @@ class ProximityInfoStateUtils {
|
||||||
std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs,
|
std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs,
|
||||||
std::vector<int> *sampledInputTimes, std::vector<int> *sampledLengthCache,
|
std::vector<int> *sampledInputTimes, std::vector<int> *sampledLengthCache,
|
||||||
std::vector<int> *sampledInputIndice);
|
std::vector<int> *sampledInputIndice);
|
||||||
static const int *getProximityCodePointsAt(
|
static const int *getProximityCodePointsAt(const int *const inputProximities, const int index);
|
||||||
const int *const inputProximities, const int index);
|
|
||||||
static int getPrimaryCodePointAt(const int *const inputProximities, const int index);
|
static int getPrimaryCodePointAt(const int *const inputProximities, const int index);
|
||||||
static void popInputData(std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs,
|
static void popInputData(std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs,
|
||||||
std::vector<int> *sampledInputTimes, std::vector<int> *sampledLengthCache,
|
std::vector<int> *sampledInputTimes, std::vector<int> *sampledLengthCache,
|
||||||
|
@ -57,8 +56,7 @@ class ProximityInfoStateUtils {
|
||||||
const std::vector<int> *const sampledInputYs, const std::vector<int> *const inputIndice,
|
const std::vector<int> *const sampledInputYs, const std::vector<int> *const inputIndice,
|
||||||
std::vector<int> *beelineSpeedPercentiles);
|
std::vector<int> *beelineSpeedPercentiles);
|
||||||
static float getDirection(const std::vector<int> *const sampledInputXs,
|
static float getDirection(const std::vector<int> *const sampledInputXs,
|
||||||
const std::vector<int> *const sampledInputYs,
|
const std::vector<int> *const sampledInputYs, const int index0, const int index1);
|
||||||
const int index0, const int index1);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfoStateUtils);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(ProximityInfoStateUtils);
|
||||||
|
@ -71,16 +69,16 @@ class ProximityInfoStateUtils {
|
||||||
static bool isPrevLocalMin(const NearKeysDistanceMap *const currentNearKeysDistances,
|
static bool isPrevLocalMin(const NearKeysDistanceMap *const currentNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevNearKeysDistances,
|
const NearKeysDistanceMap *const prevNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevPrevNearKeysDistances);
|
const NearKeysDistanceMap *const prevPrevNearKeysDistances);
|
||||||
static float getPointScore(const int mostCommonKeyWidth,
|
static float getPointScore(const int mostCommonKeyWidth, const int x, const int y,
|
||||||
const int x, const int y, const int time, const bool lastPoint, const float nearest,
|
const int time, const bool lastPoint, const float nearest, const float sumAngle,
|
||||||
const float sumAngle, const NearKeysDistanceMap *const currentNearKeysDistances,
|
const NearKeysDistanceMap *const currentNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevNearKeysDistances,
|
const NearKeysDistanceMap *const prevNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevPrevNearKeysDistances,
|
const NearKeysDistanceMap *const prevPrevNearKeysDistances,
|
||||||
std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs);
|
std::vector<int> *sampledInputXs, std::vector<int> *sampledInputYs);
|
||||||
static bool pushTouchPoint(const int mostCommonKeyWidth,
|
static bool pushTouchPoint(const int mostCommonKeyWidth,
|
||||||
const ProximityInfo *const proximityInfo, const int maxPointToKeyLength,
|
const ProximityInfo *const proximityInfo, const int maxPointToKeyLength,
|
||||||
const int inputIndex, const int nodeCodePoint, int x, int y,
|
const int inputIndex, const int nodeCodePoint, int x, int y, const int time,
|
||||||
const int time, const bool sample, const bool isLastPoint, const float sumAngle,
|
const bool doSampling, const bool isLastPoint, const float sumAngle,
|
||||||
NearKeysDistanceMap *const currentNearKeysDistances,
|
NearKeysDistanceMap *const currentNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevNearKeysDistances,
|
const NearKeysDistanceMap *const prevNearKeysDistances,
|
||||||
const NearKeysDistanceMap *const prevPrevNearKeysDistances,
|
const NearKeysDistanceMap *const prevPrevNearKeysDistances,
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ProximityInfoUtils {
|
||||||
const int primaryKey = inputCodes[i];
|
const int primaryKey = inputCodes[i];
|
||||||
const int x = inputXCoordinates[i];
|
const int x = inputXCoordinates[i];
|
||||||
const int y = inputYCoordinates[i];
|
const int y = inputYCoordinates[i];
|
||||||
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL];
|
int *proximities = &inputProximities[i * MAX_PROXIMITY_CHARS_SIZE];
|
||||||
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
|
calculateProximities(keyXCoordinates, keyYCoordinates, keyWidths, keyHeights,
|
||||||
proximityCharsArray, maxProximityCharsSize, cellHeight, cellWidth, gridWidth,
|
proximityCharsArray, maxProximityCharsSize, cellHeight, cellWidth, gridWidth,
|
||||||
mostCommonKeyWidth, keyCount, x, y, primaryKey, localeStr, codeToKeyMap,
|
mostCommonKeyWidth, keyCount, x, y, primaryKey, localeStr, codeToKeyMap,
|
||||||
|
@ -71,9 +71,9 @@ class ProximityInfoUtils {
|
||||||
if (DEBUG_PROXIMITY_CHARS) {
|
if (DEBUG_PROXIMITY_CHARS) {
|
||||||
for (int i = 0; i < inputSize; ++i) {
|
for (int i = 0; i < inputSize; ++i) {
|
||||||
AKLOGI("---");
|
AKLOGI("---");
|
||||||
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE_INTERNAL; ++j) {
|
for (int j = 0; j < MAX_PROXIMITY_CHARS_SIZE; ++j) {
|
||||||
int proximityChar =
|
int proximityChar =
|
||||||
inputProximities[i * MAX_PROXIMITY_CHARS_SIZE_INTERNAL + j];
|
inputProximities[i * MAX_PROXIMITY_CHARS_SIZE + j];
|
||||||
proximityChar += 0;
|
proximityChar += 0;
|
||||||
AKLOGI("--- (%d)%c", i, proximityChar);
|
AKLOGI("--- (%d)%c", i, proximityChar);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue