parent
f9898d05f7
commit
1d516fb1b0
|
@ -21,23 +21,23 @@ namespace latinime {
|
||||||
// TODO: Have proximity character informations in each language's binary dictionary.
|
// TODO: Have proximity character informations in each language's binary dictionary.
|
||||||
const char *AdditionalProximityChars::LOCALE_EN_US = "en";
|
const char *AdditionalProximityChars::LOCALE_EN_US = "en";
|
||||||
|
|
||||||
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
|
const int AdditionalProximityChars::EN_US_ADDITIONAL_A[EN_US_ADDITIONAL_A_SIZE] = {
|
||||||
'e', 'i', 'o', 'u'
|
'e', 'i', 'o', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_E[EN_US_ADDITIONAL_E_SIZE] = {
|
const int AdditionalProximityChars::EN_US_ADDITIONAL_E[EN_US_ADDITIONAL_E_SIZE] = {
|
||||||
'a', 'i', 'o', 'u'
|
'a', 'i', 'o', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_I[EN_US_ADDITIONAL_I_SIZE] = {
|
const int AdditionalProximityChars::EN_US_ADDITIONAL_I[EN_US_ADDITIONAL_I_SIZE] = {
|
||||||
'a', 'e', 'o', 'u'
|
'a', 'e', 'o', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_O[EN_US_ADDITIONAL_O_SIZE] = {
|
const int AdditionalProximityChars::EN_US_ADDITIONAL_O[EN_US_ADDITIONAL_O_SIZE] = {
|
||||||
'a', 'e', 'i', 'u'
|
'a', 'e', 'i', 'u'
|
||||||
};
|
};
|
||||||
|
|
||||||
const int32_t AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = {
|
const int AdditionalProximityChars::EN_US_ADDITIONAL_U[EN_US_ADDITIONAL_U_SIZE] = {
|
||||||
'a', 'e', 'i', 'o'
|
'a', 'e', 'i', 'o'
|
||||||
};
|
};
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#define LATINIME_ADDITIONAL_PROXIMITY_CHARS_H
|
#define LATINIME_ADDITIONAL_PROXIMITY_CHARS_H
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
|
@ -29,15 +28,15 @@ class AdditionalProximityChars {
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(AdditionalProximityChars);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(AdditionalProximityChars);
|
||||||
static const char *LOCALE_EN_US;
|
static const char *LOCALE_EN_US;
|
||||||
static const int EN_US_ADDITIONAL_A_SIZE = 4;
|
static const int EN_US_ADDITIONAL_A_SIZE = 4;
|
||||||
static const int32_t EN_US_ADDITIONAL_A[];
|
static const int EN_US_ADDITIONAL_A[];
|
||||||
static const int EN_US_ADDITIONAL_E_SIZE = 4;
|
static const int EN_US_ADDITIONAL_E_SIZE = 4;
|
||||||
static const int32_t EN_US_ADDITIONAL_E[];
|
static const int EN_US_ADDITIONAL_E[];
|
||||||
static const int EN_US_ADDITIONAL_I_SIZE = 4;
|
static const int EN_US_ADDITIONAL_I_SIZE = 4;
|
||||||
static const int32_t EN_US_ADDITIONAL_I[];
|
static const int EN_US_ADDITIONAL_I[];
|
||||||
static const int EN_US_ADDITIONAL_O_SIZE = 4;
|
static const int EN_US_ADDITIONAL_O_SIZE = 4;
|
||||||
static const int32_t EN_US_ADDITIONAL_O[];
|
static const int EN_US_ADDITIONAL_O[];
|
||||||
static const int EN_US_ADDITIONAL_U_SIZE = 4;
|
static const int EN_US_ADDITIONAL_U_SIZE = 4;
|
||||||
static const int32_t EN_US_ADDITIONAL_U[];
|
static const int EN_US_ADDITIONAL_U[];
|
||||||
|
|
||||||
AK_FORCE_INLINE static bool isEnLocale(const char *localeStr) {
|
AK_FORCE_INLINE static bool isEnLocale(const char *localeStr) {
|
||||||
const size_t LOCALE_EN_US_SIZE = strlen(LOCALE_EN_US);
|
const size_t LOCALE_EN_US_SIZE = strlen(LOCALE_EN_US);
|
||||||
|
@ -46,7 +45,7 @@ class AdditionalProximityChars {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int getAdditionalCharsSize(const char *localeStr, const int32_t c) {
|
static int getAdditionalCharsSize(const char *localeStr, const int c) {
|
||||||
if (!isEnLocale(localeStr)) {
|
if (!isEnLocale(localeStr)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +65,7 @@ class AdditionalProximityChars {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int32_t *getAdditionalChars(const char *localeStr, const int32_t c) {
|
static const int *getAdditionalChars(const char *localeStr, const int c) {
|
||||||
if (!isEnLocale(localeStr)) {
|
if (!isEnLocale(localeStr)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ ProximityInfo::ProximityInfo(JNIEnv *env, const jstring localeJStr, const int ma
|
||||||
HAS_TOUCH_POSITION_CORRECTION_DATA(keyCount > 0 && keyXCoordinates && keyYCoordinates
|
HAS_TOUCH_POSITION_CORRECTION_DATA(keyCount > 0 && keyXCoordinates && keyYCoordinates
|
||||||
&& keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs
|
&& keyWidths && keyHeights && keyCharCodes && sweetSpotCenterXs
|
||||||
&& sweetSpotCenterYs && sweetSpotRadii),
|
&& sweetSpotCenterYs && sweetSpotRadii),
|
||||||
mProximityCharsArray(new int32_t[GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE
|
mProximityCharsArray(new int[GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE
|
||||||
/* proximityGridLength */]),
|
/* proximityGridLength */]),
|
||||||
mCodeToKeyMap() {
|
mCodeToKeyMap() {
|
||||||
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
const int proximityGridLength = GRID_WIDTH * GRID_HEIGHT * MAX_PROXIMITY_CHARS_SIZE;
|
||||||
|
@ -115,7 +115,7 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const {
|
||||||
if (DEBUG_PROXIMITY_INFO) {
|
if (DEBUG_PROXIMITY_INFO) {
|
||||||
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
|
AKLOGI("hasSpaceProximity: index %d, %d, %d", startIndex, x, y);
|
||||||
}
|
}
|
||||||
int32_t *proximityCharsArray = mProximityCharsArray;
|
int *proximityCharsArray = mProximityCharsArray;
|
||||||
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
|
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
|
||||||
if (DEBUG_PROXIMITY_INFO) {
|
if (DEBUG_PROXIMITY_INFO) {
|
||||||
AKLOGI("Index: %d", mProximityCharsArray[startIndex + i]);
|
AKLOGI("Index: %d", mProximityCharsArray[startIndex + i]);
|
||||||
|
@ -163,14 +163,14 @@ int ProximityInfo::squaredDistanceToEdge(const int keyId, const int x, const int
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProximityInfo::calculateNearbyKeyCodes(
|
void ProximityInfo::calculateNearbyKeyCodes(
|
||||||
const int x, const int y, const int32_t primaryKey, int *inputCodes) const {
|
const int x, const int y, const int primaryKey, int *inputCodes) const {
|
||||||
int32_t *proximityCharsArray = mProximityCharsArray;
|
int *proximityCharsArray = mProximityCharsArray;
|
||||||
int insertPos = 0;
|
int insertPos = 0;
|
||||||
inputCodes[insertPos++] = primaryKey;
|
inputCodes[insertPos++] = primaryKey;
|
||||||
const int startIndex = getStartIndexFromCoordinates(x, y);
|
const int startIndex = getStartIndexFromCoordinates(x, y);
|
||||||
if (startIndex >= 0) {
|
if (startIndex >= 0) {
|
||||||
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
|
for (int i = 0; i < MAX_PROXIMITY_CHARS_SIZE; ++i) {
|
||||||
const int32_t c = proximityCharsArray[startIndex + i];
|
const int c = proximityCharsArray[startIndex + i];
|
||||||
if (c < KEYCODE_SPACE || c == primaryKey) {
|
if (c < KEYCODE_SPACE || c == primaryKey) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -198,13 +198,13 @@ void ProximityInfo::calculateNearbyKeyCodes(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int32_t *additionalProximityChars =
|
const int *additionalProximityChars =
|
||||||
AdditionalProximityChars::getAdditionalChars(mLocaleStr, primaryKey);
|
AdditionalProximityChars::getAdditionalChars(mLocaleStr, primaryKey);
|
||||||
for (int j = 0; j < additionalProximitySize; ++j) {
|
for (int j = 0; j < additionalProximitySize; ++j) {
|
||||||
const int32_t ac = additionalProximityChars[j];
|
const int ac = additionalProximityChars[j];
|
||||||
int k = 0;
|
int k = 0;
|
||||||
for (; k < insertPos; ++k) {
|
for (; k < insertPos; ++k) {
|
||||||
if (static_cast<int>(ac) == inputCodes[k]) {
|
if (ac == inputCodes[k]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ int ProximityInfo::getKeyIndexOf(const int c) const {
|
||||||
if (c == NOT_A_CODE_POINT) {
|
if (c == NOT_A_CODE_POINT) {
|
||||||
return NOT_AN_INDEX;
|
return NOT_AN_INDEX;
|
||||||
}
|
}
|
||||||
const int lowerCode = static_cast<int>(toLowerCase(c));
|
const int lowerCode = toLowerCase(c);
|
||||||
hash_map_compat<int, int>::const_iterator mapPos = mCodeToKeyMap.find(lowerCode);
|
hash_map_compat<int, int>::const_iterator mapPos = mCodeToKeyMap.find(lowerCode);
|
||||||
if (mapPos != mCodeToKeyMap.end()) {
|
if (mapPos != mCodeToKeyMap.end()) {
|
||||||
return mapPos->second;
|
return mapPos->second;
|
||||||
|
@ -254,7 +254,7 @@ void ProximityInfo::initializeG() {
|
||||||
// TODO: Optimize
|
// TODO: Optimize
|
||||||
for (int i = 0; i < KEY_COUNT; ++i) {
|
for (int i = 0; i < KEY_COUNT; ++i) {
|
||||||
const int code = mKeyCodePoints[i];
|
const int code = mKeyCodePoints[i];
|
||||||
const int lowerCode = static_cast<int>(toLowerCase(code));
|
const int lowerCode = toLowerCase(code);
|
||||||
mCenterXsG[i] = mKeyXCoordinates[i] + mKeyWidths[i] / 2;
|
mCenterXsG[i] = mKeyXCoordinates[i] + mKeyWidths[i] / 2;
|
||||||
mCenterYsG[i] = mKeyYCoordinates[i] + mKeyHeights[i] / 2;
|
mCenterYsG[i] = mKeyYCoordinates[i] + mKeyHeights[i] / 2;
|
||||||
mCodeToKeyMap[lowerCode] = i;
|
mCodeToKeyMap[lowerCode] = i;
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#ifndef LATINIME_PROXIMITY_INFO_H
|
#ifndef LATINIME_PROXIMITY_INFO_H
|
||||||
#define LATINIME_PROXIMITY_INFO_H
|
#define LATINIME_PROXIMITY_INFO_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "hash_map_compat.h"
|
#include "hash_map_compat.h"
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
|
@ -59,7 +57,7 @@ class ProximityInfo {
|
||||||
return mSweetSpotCenterYs[keyIndex];
|
return mSweetSpotCenterYs[keyIndex];
|
||||||
}
|
}
|
||||||
void calculateNearbyKeyCodes(
|
void calculateNearbyKeyCodes(
|
||||||
const int x, const int y, const int32_t primaryKey, int *inputCodes) const;
|
const int x, const int y, const int primaryKey, int *inputCodes) const;
|
||||||
|
|
||||||
bool hasTouchPositionCorrectionData() const {
|
bool hasTouchPositionCorrectionData() const {
|
||||||
return HAS_TOUCH_POSITION_CORRECTION_DATA;
|
return HAS_TOUCH_POSITION_CORRECTION_DATA;
|
||||||
|
@ -141,12 +139,12 @@ class ProximityInfo {
|
||||||
const int KEYBOARD_HEIGHT;
|
const int KEYBOARD_HEIGHT;
|
||||||
const bool HAS_TOUCH_POSITION_CORRECTION_DATA;
|
const bool HAS_TOUCH_POSITION_CORRECTION_DATA;
|
||||||
char mLocaleStr[MAX_LOCALE_STRING_LENGTH];
|
char mLocaleStr[MAX_LOCALE_STRING_LENGTH];
|
||||||
int32_t *mProximityCharsArray;
|
int *mProximityCharsArray;
|
||||||
int32_t mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyXCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
int32_t mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyYCoordinates[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
int32_t mKeyWidths[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyWidths[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
int32_t mKeyHeights[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyHeights[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
int32_t mKeyCodePoints[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
int mKeyCodePoints[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
float mSweetSpotCenterXs[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
float mSweetSpotCenterXs[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
float mSweetSpotCenterYs[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
float mSweetSpotCenterYs[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD];
|
||||||
|
|
Loading…
Reference in New Issue